studentId = $studentId; $this->loadRadarData(); } public function loadRadarData(): void { $this->isLoading = true; $this->errorMessage = ''; try { $service = new LearningAnalyticsService(); $skillProficiency = $service->getStudentSkillProficiency($this->studentId); if ($skillProficiency && isset($skillProficiency['data'])) { $this->radarData = $this->processRadarData($skillProficiency['data']); } else { $this->radarData = []; } } catch (\Exception $e) { $this->errorMessage = '加载雷达图数据失败:' . $e->getMessage(); $this->radarData = []; } finally { $this->isLoading = false; } } /** * 处理雷达图数据 */ private function processRadarData(array $skillData): array { $processedData = []; $maxValue = 1.0; // 技能熟练度最大值为1 foreach ($skillData as $skill) { $processedData[] = [ 'skill_name' => $skill['skill_name'], 'proficiency_level' => $skill['proficiency_level'], 'skill_level' => $skill['skill_level'], 'total_questions_attempted' => $skill['total_questions_attempted'], 'simple_accuracy' => $skill['simple_accuracy'] ?? 0, 'intermediate_accuracy' => $skill['intermediate_accuracy'] ?? 0, 'advanced_accuracy' => $skill['advanced_accuracy'] ?? 0, 'practice_streak' => $skill['practice_streak'] ?? 0, 'max_value' => $maxValue, ]; } return [ 'data' => $processedData, 'max_value' => $maxValue, ]; } /** * 获取技能等级颜色 */ public function getSkillLevelColor(string $skillLevel): string { return match ($skillLevel) { 'beginner' => '#ef4444', // 红色 - 初学者 'elementary' => '#f97316', // 橙色 - 入门 'intermediate' => '#eab308', // 黄色 - 进阶 'advanced' => '#22c55e', // 绿色 - 熟练 'proficient' => '#3b82f6', // 蓝色 - 精通 default => '#9ca3af', // 灰色 - 未知 }; } /** * 获取技能等级中文名称 */ public function getSkillLevelName(string $skillLevel): string { return match ($skillLevel) { 'beginner' => '初学者', 'elementary' => '入门', 'intermediate' => '进阶', 'advanced' => '熟练', 'proficient' => '精通', default => '未知', }; } /** * 获取难度标签 */ public function getDifficultyLabel(string $difficulty): string { return match ($difficulty) { 'simple' => '简单', 'intermediate' => '中等', 'advanced' => '困难', default => $difficulty, }; } public function render() { return view('livewire.skill-proficiency-radar'); } }