baseUrl = config('services.learning_analytics.url', 'http://localhost:5016'); $this->timeout = config('services.learning_analytics.timeout', 30); } /** * 获取学生掌握度概览 */ public function getStudentMasteryOverview(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/api/v1/mastery/student/{$studentId}/overview"); if ($response->successful()) { return $response->json(); } Log::warning("获取学生掌握度概览失败", [ 'student_id' => $studentId, 'status' => $response->status(), 'response' => $response->body() ]); return null; } catch (\Exception $e) { Log::error("获取学生掌握度概览异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 获取学生掌握度列表 */ public function getStudentMasteryList(string $studentId, array $filters = []): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/api/v1/mastery/student/{$studentId}", $filters); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取学生掌握度列表异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 获取学生技能熟练度 */ public function getStudentSkillProficiency(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/api/v1/skill/proficiency/student/{$studentId}"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取学生技能熟练度异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 获取学生技能摘要 */ public function getStudentSkillSummary(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/api/v1/skill/proficiency/student/{$studentId}/summary"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取学生技能摘要异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 创建提分预测 */ public function createScorePrediction(array $data): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/api/v1/prediction/score", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("创建提分预测异常", [ 'data' => $data, 'error' => $e->getMessage() ]); return null; } } /** * 获取学生历史预测 */ public function getStudentPredictions(string $studentId, int $limit = 10): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/api/v1/prediction/student/{$studentId}", [ 'limit' => $limit ]); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取学生预测记录异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 生成学习路径 */ public function generateLearningPath(array $data): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/api/v1/learning-path/generate", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("生成学习路径异常", [ 'data' => $data, 'error' => $e->getMessage() ]); return null; } } /** * 获取学生学习路径 */ public function getStudentLearningPaths(string $studentId, int $limit = 10): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/api/v1/learning-path/student/{$studentId}", [ 'limit' => $limit ]); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取学生学习路径异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 获取预测分析统计 */ public function getPredictionAnalytics(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/api/v1/prediction/student/{$studentId}/analytics"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取预测分析统计异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 获取学习路径分析统计 */ public function getLearningPathAnalytics(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/api/v1/learning-path/student/{$studentId}/analytics"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取学习路径分析统计异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 重新计算掌握度 */ public function recalculateMastery(string $studentId, string $kpCode): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/api/v1/mastery/student/{$studentId}/update?kp_code={$kpCode}"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("重新计算掌握度异常", [ 'student_id' => $studentId, 'kp_code' => $kpCode, 'error' => $e->getMessage() ]); return null; } } /** * 批量更新技能熟练度 */ public function batchUpdateSkillProficiency(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/api/v1/skill/proficiency/student/{$studentId}/batch-update"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("批量更新技能熟练度异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 快速提分预测 */ public function quickScorePrediction(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/api/v1/prediction/student/{$studentId}/quick-prediction"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("快速提分预测异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 推荐学习路径 */ public function recommendLearningPaths(string $studentId, int $limit = 3): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/api/v1/learning-path/student/{$studentId}/recommend", [ 'limit' => $limit ]); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("推荐学习路径异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * ==================== 新增:从MathRecSys迁移的功能 ==================== */ /** * 获取学生能力画像 */ public function getStudentProfile(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/student/{$studentId}/profile"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取学生能力画像异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 智能分析题目/学习 */ public function smartAnalyze(string $studentId, array $data): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/student/{$studentId}/analysis", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("智能分析异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 获取学习轨迹 */ public function getLearningTrajectory(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/student/{$studentId}/trajectory"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取学习轨迹异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 获取薄弱知识点 */ public function getWeakPoints(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/student/{$studentId}/weak-points"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取薄弱知识点异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 获取学习进度 */ public function getLearningProgress(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/student/{$studentId}/progress"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取学习进度异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 获取个性化推荐 */ public function getRecommendations(string $studentId, array $data = []): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/student/{$studentId}/recommendations", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取个性化推荐异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 获取班级整体分析 */ public function getClassAnalysis(string $classId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/class/{$classId}/analysis"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取班级分析异常", [ 'class_id' => $classId, 'error' => $e->getMessage() ]); return null; } } /** * 批量分析学生 */ public function batchAnalyzeStudents(string $classId, array $data): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/class/{$classId}/batch-analysis", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("批量分析学生异常", [ 'class_id' => $classId, 'error' => $e->getMessage() ]); return null; } } /** * 获取班级排名 */ public function getClassRanking(string $classId, string $metric = 'mastery'): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/class/{$classId}/ranking", [ 'metric' => $metric ]); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取班级排名异常", [ 'class_id' => $classId, 'error' => $e->getMessage() ]); return null; } } /** * 与其他班级对比 */ public function compareWithOtherClasses(string $classId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/class/{$classId}/comparison"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取班级对比异常", [ 'class_id' => $classId, 'error' => $e->getMessage() ]); return null; } } /** * 提分潜力估算 */ public function estimateScoreGain(array $data): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/ability/gain-estimation", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("提分潜力估算异常", [ 'data' => $data, 'error' => $e->getMessage() ]); return null; } } /** * 评估学生能力 */ public function evaluateStudentAbility(array $data): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/ability/evaluate-student-ability", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("评估学生能力异常", [ 'data' => $data, 'error' => $e->getMessage() ]); return null; } } /** * 获取学生能力档案 */ public function getAbilityProfile(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/ability/student/{$studentId}/ability-profile"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取学生能力档案异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 比较学生能力 */ public function compareAbilities(array $data): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/ability/compare-abilities", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("比较学生能力异常", [ 'data' => $data, 'error' => $e->getMessage() ]); return null; } } /** * 学习问题诊断 */ public function diagnosticAnalyze(array $data): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/diagnostic/analyze", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("学习问题诊断异常", [ 'data' => $data, 'error' => $e->getMessage() ]); return null; } } /** * 学习障碍检测 */ public function detectLearningBarriers(array $data): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/diagnostic/learning-barrier-detection", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("学习障碍检测异常", [ 'data' => $data, 'error' => $e->getMessage() ]); return null; } } /** * 错误概念检测 */ public function detectMisconceptions(array $data): ?array { try { $response = Http::timeout($this->timeout) ->post("{$this->baseUrl}/diagnostic/misconception-detection", $data); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("错误概念检测异常", [ 'data' => $data, 'error' => $e->getMessage() ]); return null; } } /** * 获取诊断历史 */ public function getDiagnosisHistory(string $studentId): ?array { try { $response = Http::timeout($this->timeout) ->get("{$this->baseUrl}/diagnostic/student/{$studentId}/learning-diagnosis-history"); if ($response->successful()) { return $response->json(); } return null; } catch (\Exception $e) { Log::error("获取诊断历史异常", [ 'student_id' => $studentId, 'error' => $e->getMessage() ]); return null; } } /** * 检查服务健康状态 */ public function checkHealth(): bool { try { $response = Http::timeout(5) ->get("{$this->baseUrl}/health"); return $response->successful(); } catch (\Exception $e) { Log::warning("学习分析系统健康检查失败", [ 'error' => $e->getMessage() ]); return false; } } }