studentId = $request->input('student_id', 'student_001'); } public function loadDashboardData(): void { $this->isLoading = true; $this->errorMessage = ''; try { $service = new LearningAnalyticsService(); // 检查服务健康状态 if (!$service->checkHealth()) { $this->errorMessage = '学习分析系统当前不可用,请稍后重试'; $this->isLoading = false; return; } // 获取各项数据 $masteryOverview = $service->getStudentMasteryOverview($this->studentId); $skillProficiency = $service->getStudentSkillProficiency($this->studentId); $skillSummary = $service->getStudentSkillSummary($this->studentId); $predictions = $service->getStudentPredictions($this->studentId, 5); $learningPaths = $service->getStudentLearningPaths($this->studentId, 3); $predictionAnalytics = $service->getPredictionAnalytics($this->studentId); $pathAnalytics = $service->getLearningPathAnalytics($this->studentId); $quickPrediction = $service->quickScorePrediction($this->studentId); $recommendations = $service->recommendLearningPaths($this->studentId, 3); // 组合数据 $this->dashboardData = [ 'mastery' => [ 'overview' => $masteryOverview, 'list' => $service->getStudentMasteryList($this->studentId), ], 'skill' => [ 'proficiency' => $skillProficiency, 'summary' => $skillSummary, ], 'prediction' => [ 'list' => $predictions, 'analytics' => $predictionAnalytics, 'quick' => $quickPrediction, ], 'learning_path' => [ 'list' => $learningPaths, 'analytics' => $pathAnalytics, 'recommendations' => $recommendations, ], ]; } catch (\Exception $e) { $this->errorMessage = '加载数据时发生错误:' . $e->getMessage(); Log::error('学生仪表板数据加载失败', [ 'student_id' => $this->studentId, 'error' => $e->getMessage() ]); } finally { $this->isLoading = false; } } public function updatedStudentId(): void { // 学生ID更新后自动刷新数据 $this->loadDashboardData(); } public function recalculateMastery(string $kpCode): void { try { $service = new LearningAnalyticsService(); $result = $service->recalculateMastery($this->studentId, $kpCode); if ($result) { $this->dispatch('notify', message: '掌握度重新计算完成', type: 'success'); $this->loadDashboardData(); // 刷新数据 } else { $this->dispatch('notify', message: '掌握度重新计算失败', type: 'danger'); } } catch (\Exception $e) { Log::error('重新计算掌握度失败', [ 'student_id' => $this->studentId, 'kp_code' => $kpCode, 'error' => $e->getMessage() ]); $this->dispatch('notify', message: '操作失败:' . $e->getMessage(), type: 'danger'); } } public function batchUpdateSkills(): void { try { $service = new LearningAnalyticsService(); $result = $service->batchUpdateSkillProficiency($this->studentId); if ($result) { $this->dispatch('notify', message: '技能熟练度更新完成', type: 'success'); $this->loadDashboardData(); // 刷新数据 } else { $this->dispatch('notify', message: '技能熟练度更新失败', type: 'danger'); } } catch (\Exception $e) { Log::error('批量更新技能熟练度失败', [ 'student_id' => $this->studentId, 'error' => $e->getMessage() ]); $this->dispatch('notify', message: '操作失败:' . $e->getMessage(), type: 'danger'); } } public function generateQuickPrediction(): void { try { $service = new LearningAnalyticsService(); $result = $service->quickScorePrediction($this->studentId); if ($result) { $this->dispatch('notify', message: '快速预测生成完成', type: 'success'); $this->loadDashboardData(); // 刷新数据 } else { $this->dispatch('notify', message: '快速预测生成失败', type: 'danger'); } } catch (\Exception $e) { Log::error('生成快速预测失败', [ 'student_id' => $this->studentId, 'error' => $e->getMessage() ]); $this->dispatch('notify', message: '操作失败:' . $e->getMessage(), type: 'danger'); } } }