@php $v3 = $v3 ?? []; $summary = $v3['summary'] ?? []; $radar = $v3['radar'] ?? []; $modules = $v3['modules'] ?? []; $paths = $v3['paths'] ?? ['keep' => [], 'boost' => [], 'key' => []]; $rawPaperId = $paper['id'] ?? $paper['paper_id'] ?? 'unknown'; preg_match('/paper_(\d{15})/', $rawPaperId, $matches); $reportCode = $matches[1] ?? preg_replace('/[^0-9]/', '', (string) $rawPaperId); $generateDateTime = now()->format('Y年m月d日 H:i:s'); $scoreObtained = $summary['score_obtained'] ?? null; $scoreTotal = $summary['score_total'] ?? null; $scoreRate = $summary['score_rate'] ?? null; $averageMastery = $summary['average_mastery'] ?? null; $overallLabel = $summary['overall_label'] ?? '待评估'; $difficultySummary = $summary['difficulty'] ?? []; $comparisonSummary = $summary['comparison'] ?? []; $overallLabelDetail = $summary['overall_label_detail'] ?? []; $historySummary = $comparisonSummary['history'] ?? []; $peerSummary = $comparisonSummary['peers'] ?? []; $overallScore = isset($overallLabelDetail['composite_score']) ? (float) $overallLabelDetail['composite_score'] : null; $overallGrade = (string) ($overallLabelDetail['grade'] ?? 'D'); $currentPart = (float) ($overallLabelDetail['current_score'] ?? 0); $historyPart = (float) ($overallLabelDetail['history_score'] ?? 0); $peerPart = (float) ($overallLabelDetail['peer_score'] ?? 0); $adjustPart = (float) ($overallLabelDetail['difficulty_adjust'] ?? 0); $compositeFormulaResult = (0.50 * $currentPart) + (0.25 * $historyPart) + (0.25 * $peerPart) + $adjustPart; $overallBadge = function (string $grade): array { return match ($grade) { 'S' => ['bg' => '#f5f3ff', 'border' => '#6d28d9', 'text' => '#6d28d9', 'class' => 'badge-s'], 'A' => ['bg' => '#ecfdf3', 'border' => '#22c55e', 'text' => '#166534', 'class' => 'badge-excellent'], 'B' => ['bg' => '#eff6ff', 'border' => '#3b82f6', 'text' => '#1d4ed8', 'class' => 'badge-good'], 'C' => ['bg' => '#fff7ed', 'border' => '#f59e0b', 'text' => '#b45309', 'class' => 'badge-average'], default => ['bg' => '#fef2f2', 'border' => '#ef4444', 'text' => '#b91c1c', 'class' => 'badge-weak'], }; }; $overallVisual = $overallBadge((string) $overallGrade); $trendVisual = function (string $trend): array { return match ($trend) { '显著提升' => ['icon' => '▲', 'color' => '#16a34a'], '小幅提升' => ['icon' => '↗', 'color' => '#0ea5e9'], '基本持平' => ['icon' => '•', 'color' => '#64748b'], '小幅回落' => ['icon' => '↘', 'color' => '#f59e0b'], '明显回落' => ['icon' => '▼', 'color' => '#ef4444'], default => ['icon' => '•', 'color' => '#64748b'], }; }; $statusColor = function (string $status): string { return match ($status) { '良好' => '#16a34a', '一般' => '#f97316', '薄弱' => '#e11d48', default => '#64748b', }; }; $n = max(1, count($radar)); $cx = 210; $cy = 155; $r = 108; $outer = []; $inner = []; for ($i = 0; $i < $n; $i++) { $angle = -M_PI / 2 + (2 * M_PI * $i / $n); $ox = $cx + $r * cos($angle); $oy = $cy + $r * sin($angle); $outer[] = [$ox, $oy]; $value = isset($radar[$i]['value']) ? (float) $radar[$i]['value'] : 0.0; $ratio = max(0.0, min(1.0, $value / 5)); $ix = $cx + $r * $ratio * cos($angle); $iy = $cy + $r * $ratio * sin($angle); $inner[] = [$ix, $iy]; } $outerPoints = implode(' ', array_map(fn ($p) => round($p[0], 2).','.round($p[1], 2), $outer)); $innerPoints = implode(' ', array_map(fn ($p) => round($p[0], 2).','.round($p[1], 2), $inner)); $insightMap = []; foreach (($question_insights ?? []) as $insight) { $no = $insight['question_number'] ?? $insight['question_id'] ?? null; if ($no !== null) { $insightMap[$no] = $insight; } } $analysisWrongMap = []; foreach (($analysis_data['question_analysis'] ?? []) as $qa) { $qid = $qa['question_bank_id'] ?? $qa['question_id'] ?? null; if ($qid === null || $qid === '') { continue; } $rawCorrect = $qa['is_correct'] ?? null; $isWrongFromAnalysis = false; if (is_array($rawCorrect)) { $isWrongFromAnalysis = in_array(0, $rawCorrect, true); } elseif ($rawCorrect !== null) { $isWrongFromAnalysis = !boolval($rawCorrect); } if ($isWrongFromAnalysis) { $analysisWrongMap[(string) $qid] = true; } } $wrongQuestions = []; foreach (($questions ?? []) as $qItem) { $isCorrectProbe = $qItem['is_correct'] ?? null; $studentAnswerProbe = $qItem['student_answer'] ?? null; $correctAnswerProbe = $qItem['answer'] ?? ($qItem['correct_answer'] ?? null); if ($isCorrectProbe === null && !empty($studentAnswerProbe) && !empty($correctAnswerProbe)) { $isCorrectProbe = (trim((string) $studentAnswerProbe) === trim((string) $correctAnswerProbe)) ? 1 : 0; } $normalizedCorrect = $isCorrectProbe; if ($isCorrectProbe !== null) { $normalizedCorrect = is_bool($isCorrectProbe) ? ($isCorrectProbe ? 1 : 0) : intval($isCorrectProbe); } $qidProbe = (string) ($qItem['question_bank_id'] ?? $qItem['question_id'] ?? ''); $isWrongByAnalysis = ($qidProbe !== '' && isset($analysisWrongMap[$qidProbe])); if ($normalizedCorrect === 0 || $isWrongByAnalysis) { $wrongQuestions[] = $qItem; } } $kpStats = []; foreach (($questions ?? []) as $qItem) { $kpName = trim((string) ($qItem['knowledge_point_name'] ?? $qItem['knowledge_point'] ?? '未标注知识点')); $kpName = $kpName === '' ? '未标注知识点' : $kpName; if (!isset($kpStats[$kpName])) { $kpStats[$kpName] = ['total' => 0, 'wrong' => 0]; } $kpStats[$kpName]['total']++; } foreach ($wrongQuestions as $qItem) { $kpName = trim((string) ($qItem['knowledge_point_name'] ?? $qItem['knowledge_point'] ?? '未标注知识点')); $kpName = $kpName === '' ? '未标注知识点' : $kpName; if (!isset($kpStats[$kpName])) { $kpStats[$kpName] = ['total' => 0, 'wrong' => 0]; } $kpStats[$kpName]['wrong']++; } $kpWrongStats = []; foreach ($kpStats as $kpName => $stat) { if (($stat['wrong'] ?? 0) <= 0) { continue; } $total = max(1, intval($stat['total'] ?? 0)); $wrong = intval($stat['wrong'] ?? 0); $kpWrongStats[] = [ 'kp_name' => $kpName, 'wrong' => $wrong, 'total' => $total, 'rate' => $wrong / $total, ]; } usort($kpWrongStats, function ($a, $b) { if ($a['rate'] === $b['rate']) { return $b['wrong'] <=> $a['wrong']; } return $b['rate'] <=> $a['rate']; }); $childMasteryStatus = function ($mastery): string { if ($mastery === null) { return '未学习'; } $m = (float) $mastery * 100; // 与 math.client-pc 统一:0-100 阈值(85/60) if ($m >= 85) { return '已掌握'; } if ($m >= 60) { return '薄弱'; } return '未入门'; }; $childStatusColor = function ($status): string { return match ($status) { '已掌握' => '#52c41a', '薄弱' => '#faad14', '未入门' => '#f5222d', default => '#d9d9d9', }; }; $calcStats = function (array $points): array { $total = count($points); $learned = 0; $mastered = 0; $weak = 0; $beginner = 0; $unlearned = 0; foreach ($points as $p) { if (($p['mastery_level'] ?? null) !== null) { $learned++; } $status = (string) ($p['status'] ?? '未学习'); if ($status === '已掌握') { $mastered++; } elseif ($status === '薄弱') { $weak++; } elseif ($status === '未入门') { $beginner++; } else { $unlearned++; } } return [ 'total' => $total, 'learned' => $learned, 'mastered' => $mastered, 'weak' => $weak, 'beginner' => $beginner, 'unlearned' => $unlearned, ]; }; $clusterCards = []; $allClusterPoints = []; foreach ($radar as $moduleItem) { $children = is_array($moduleItem['children'] ?? null) ? $moduleItem['children'] : []; $greatMap = []; foreach ($children as $child) { $greatKey = trim((string) ($child['great_grand_parent_name'] ?? '')); $greatKey = $greatKey !== '' ? $greatKey : '未分组'; $grandKey = trim((string) ($child['grand_parent_name'] ?? '')); $grandKey = $grandKey !== '' ? $grandKey : '未分组'; $parentName = trim((string) ($child['parent_name'] ?? '')); if ($parentName === '') { $parentCode = trim((string) ($child['parent_code'] ?? '')); $parentName = $parentCode !== '' ? $parentCode : '未分组'; } $mastery = isset($child['mastery_level']) ? (float) $child['mastery_level'] : null; $status = $childMasteryStatus($mastery); if (!isset($greatMap[$greatKey])) { $greatMap[$greatKey] = []; } if (!isset($greatMap[$greatKey][$grandKey])) { $greatMap[$greatKey][$grandKey] = []; } if (!isset($greatMap[$greatKey][$grandKey][$parentName])) { $greatMap[$greatKey][$grandKey][$parentName] = []; } $greatMap[$greatKey][$grandKey][$parentName][] = [ 'code' => (string) ($child['code'] ?? ''), 'name' => (string) ($child['name'] ?? '未命名知识点'), 'path' => (string) ($child['path'] ?? ''), 'mastery_level' => $mastery, 'change' => isset($child['change']) ? (float) $child['change'] : null, 'status' => $status, 'color' => $childStatusColor($status), 'is_hit' => !empty($child['is_hit']), ]; } $greatGroups = []; foreach ($greatMap as $greatName => $grandMap) { $grandGroups = []; foreach ($grandMap as $grandName => $parentMap) { $parentGroups = []; foreach ($parentMap as $parentName => $points) { usort($points, function ($a, $b) { $am = $a['mastery_level'] ?? -1; $bm = $b['mastery_level'] ?? -1; if ($am === $bm) { return strcmp((string) ($a['name'] ?? ''), (string) ($b['name'] ?? '')); } return $bm <=> $am; }); $parentGroups[] = [ 'parent_name' => $parentName, 'points' => $points, 'stats' => $calcStats($points), ]; } // 子模块级过滤:整行没有任何掌握度数字则不显示 $parentGroups = array_values(array_filter($parentGroups, function ($pg) { return (($pg['stats']['learned'] ?? 0) > 0); })); if (empty($parentGroups)) { continue; } usort($parentGroups, function ($a, $b) { $sa = $a['stats']; $sb = $b['stats']; return ($sb['learned'] <=> $sa['learned']) ?: ($sb['total'] <=> $sa['total']); }); $allGrandPoints = []; foreach ($parentGroups as $pg) { $allGrandPoints = array_merge($allGrandPoints, $pg['points']); } $grandGroups[] = [ 'grand_name' => $grandName, 'parent_groups' => $parentGroups, 'stats' => $calcStats($allGrandPoints), ]; } // 大块级过滤:整块没有任何掌握度数字则不显示 $grandGroups = array_values(array_filter($grandGroups, function ($gg) { return (($gg['stats']['learned'] ?? 0) > 0); })); if (empty($grandGroups)) { continue; } usort($grandGroups, function ($a, $b) { $sa = $a['stats']; $sb = $b['stats']; return ($sb['learned'] <=> $sa['learned']) ?: ($sb['total'] <=> $sa['total']); }); $allGreatPoints = []; foreach ($grandGroups as $gg) { foreach ($gg['parent_groups'] as $pg) { $allGreatPoints = array_merge($allGreatPoints, $pg['points']); } } $greatGroups[] = [ 'great_name' => $greatName, 'grand_groups' => $grandGroups, 'stats' => $calcStats($allGreatPoints), ]; } usort($greatGroups, function ($a, $b) { $sa = $a['stats']; $sb = $b['stats']; return ($sb['learned'] <=> $sa['learned']) ?: ($sb['total'] <=> $sa['total']); }); // 严格参考 math.client-pc:扁平化为“grand 层卡片”(展示大块) foreach ($greatGroups as $great) { foreach (($great['grand_groups'] ?? []) as $grand) { $gStats = $grand['stats'] ?? ['learned' => 0, 'total' => 0]; $clusterCards[] = [ 'great_name' => $great['great_name'] ?? '未分组', 'grand_name' => $grand['grand_name'] ?? '未分组', 'parent_groups' => $grand['parent_groups'] ?? [], 'stats' => $gStats, ]; } } } usort($clusterCards, function ($a, $b) { $sa = $a['stats'] ?? ['learned' => 0, 'total' => 0]; $sb = $b['stats'] ?? ['learned' => 0, 'total' => 0]; return (($sb['learned'] ?? 0) <=> ($sa['learned'] ?? 0)) ?: (($sb['total'] ?? 0) <=> ($sa['total'] ?? 0)); }); foreach ($clusterCards as $card) { foreach (($card['parent_groups'] ?? []) as $pg) { foreach (($pg['points'] ?? []) as $p) { $allClusterPoints[] = $p; } } } $kpStatsTotal = [ 'total' => count($allClusterPoints), 'mastered' => 0, 'weak' => 0, 'beginner' => 0, 'unlearned' => 0, ]; foreach ($allClusterPoints as $p) { $st = (string) ($p['status'] ?? '未学习'); if ($st === '已掌握') { $kpStatsTotal['mastered']++; } elseif ($st === '薄弱') { $kpStatsTotal['weak']++; } elseif ($st === '未入门') { $kpStatsTotal['beginner']++; } else { $kpStatsTotal['unlearned']++; } } $moduleRowsWithStatus = array_values(array_filter($modules, function ($m) { $status = trim((string) ($m['status'] ?? '')); $masteryLevel = $m['mastery_level'] ?? null; if ($masteryLevel !== null) { return true; } return $status !== '' && ! in_array($status, ['暂无', '-', '未涉及'], true); })); $pathTagByModuleName = []; foreach (['keep' => '保分不错', 'boost' => '需要加强', 'key' => '优先加强'] as $bucket => $tagName) { foreach (($paths[$bucket] ?? []) as $item) { $n = trim((string) ($item['name'] ?? '')); if ($n === '') { continue; } $pathTagByModuleName[$n] = $tagName; } } $impactedModules = array_values(array_filter($moduleRowsWithStatus, function ($m) { return ((int) ($m['question_count'] ?? 0)) > 0; })); $radarModuleMap = []; foreach ($radar as $moduleItem) { $code = (string) ($moduleItem['code'] ?? ''); if ($code !== '') { $radarModuleMap[$code] = $moduleItem; } } $moduleImpactChangeMap = []; foreach ($radarModuleMap as $moduleCode => $moduleItem) { $hitChanges = []; foreach (($moduleItem['children'] ?? []) as $child) { if (empty($child['is_hit'])) { continue; } $change = $child['change'] ?? null; if ($change === null || ! is_numeric($change)) { continue; } $hitChanges[] = (float) $change; } if (empty($hitChanges)) { continue; } $moduleImpactChangeMap[$moduleCode] = array_sum($hitChanges) / count($hitChanges); } $questionTypeLabelMap = [ 'choice' => '选择题', 'multiple_choice' => '选择题', 'single_choice' => '选择题', 'select' => '选择题', 'fill' => '填空题', 'blank' => '填空题', 'answer' => '解答题', 'solution' => '解答题', ]; $kpQuestionTypeMap = []; foreach (($questions ?? []) as $qItem) { $kpName = trim((string) ($qItem['knowledge_point_name'] ?? $qItem['knowledge_point'] ?? '')); if ($kpName === '') { continue; } $rawType = strtolower(trim((string) ($qItem['question_type'] ?? ''))); $typeLabel = $questionTypeLabelMap[$rawType] ?? ((string) ($qItem['question_type'] ?? '未知题型')); if ($typeLabel === '') { $typeLabel = '未知题型'; } if (! isset($kpQuestionTypeMap[$kpName])) { $kpQuestionTypeMap[$kpName] = []; } $kpQuestionTypeMap[$kpName][$typeLabel] = true; } $moduleKpSuggestions = []; foreach ($moduleRowsWithStatus as $m) { $moduleCode = (string) ($m['module_code'] ?? ''); $moduleName = (string) ($m['module_name'] ?? '-'); $moduleChildren = $radarModuleMap[$moduleCode]['children'] ?? []; if (! is_array($moduleChildren) || empty($moduleChildren)) { continue; } $started = array_values(array_filter($moduleChildren, function ($c) { return isset($c['mastery_level']) && $c['mastery_level'] !== null; })); usort($started, function ($a, $b) { $am = (float) ($a['mastery_level'] ?? 0); $bm = (float) ($b['mastery_level'] ?? 0); if ($am === $bm) { return strcmp((string) ($a['name'] ?? ''), (string) ($b['name'] ?? '')); } return $am <=> $bm; }); $weakest = null; if (! empty($started)) { $lowestStarted = $started[0]; $lowestStartedLevel = isset($lowestStarted['mastery_level']) ? (float) $lowestStarted['mastery_level'] : null; if ($lowestStartedLevel !== null && $lowestStartedLevel < 0.85) { // 规则1:已开始学习中掌握度最低 $weakest = $lowestStarted; } else { // 规则2:若已开始学习均达标(>=85%),取“最近的未学习” $unlearned = array_values(array_filter($moduleChildren, function ($c) { return !isset($c['mastery_level']) || $c['mastery_level'] === null; })); if (! empty($unlearned)) { $anchorParent = (string) ($lowestStarted['parent_name'] ?? ''); $anchorGrand = (string) ($lowestStarted['grand_parent_name'] ?? ''); usort($unlearned, function ($a, $b) use ($anchorParent, $anchorGrand) { $score = function ($node) use ($anchorParent, $anchorGrand) { $parent = (string) ($node['parent_name'] ?? ''); $grand = (string) ($node['grand_parent_name'] ?? ''); if ($anchorParent !== '' && $parent === $anchorParent) { return 0; } if ($anchorGrand !== '' && $grand === $anchorGrand) { return 1; } return 2; }; $sa = $score($a); $sb = $score($b); if ($sa === $sb) { return strcmp((string) ($a['name'] ?? ''), (string) ($b['name'] ?? '')); } return $sa <=> $sb; }); $weakest = $unlearned[0]; } else { $weakest = $lowestStarted; } } } else { // 没有已开始学习数据时,回退到模块内任一未学习点 $unlearned = array_values(array_filter($moduleChildren, function ($c) { return !isset($c['mastery_level']) || $c['mastery_level'] === null; })); if (! empty($unlearned)) { usort($unlearned, fn ($a, $b) => strcmp((string) ($a['name'] ?? ''), (string) ($b['name'] ?? ''))); $weakest = $unlearned[0]; } } if (! is_array($weakest)) { continue; } $kpName = (string) ($weakest['name'] ?? ''); if ($kpName === '') { continue; } $types = array_keys($kpQuestionTypeMap[$kpName] ?? []); $moduleKpSuggestions[] = [ 'module_name' => $moduleName, 'path_tag' => $pathTagByModuleName[$moduleName] ?? '待观察', 'kp_name' => $kpName, 'mastery_level' => $weakest['mastery_level'] ?? null, 'status' => $childMasteryStatus($weakest['mastery_level'] ?? null), 'question_types' => $types, ]; } $moduleSuggestionByName = []; foreach ($moduleKpSuggestions as $sug) { $name = trim((string) ($sug['module_name'] ?? '')); if ($name !== '') { $moduleSuggestionByName[$name] = $sug; } } $kpChangeItems = array_values(array_filter($allClusterPoints, function ($p) { $change = $p['change'] ?? null; return $change !== null && is_numeric($change) && !empty($p['is_hit']); })); if (empty($kpChangeItems)) { $kpChangeItems = array_values(array_filter($allClusterPoints, function ($p) { $change = $p['change'] ?? null; return $change !== null && is_numeric($change); })); } usort($kpChangeItems, function ($a, $b) { return abs((float) ($b['change'] ?? 0)) <=> abs((float) ($a['change'] ?? 0)); }); $kpPct = function (int $count, int $total): string { if ($total <= 0) { return '0.0%'; } return number_format(($count * 100.0) / $total, 1) . '%'; }; @endphp 学情分析报告

学情分析报告

一、总体评估
{{ $overallGrade }}
  • 本次诊断得分: @if($scoreObtained !== null && $scoreTotal !== null && $scoreTotal > 0) {{ rtrim(rtrim(number_format((float) $scoreObtained, 1), '0'), '.') }}/{{ rtrim(rtrim(number_format((float) $scoreTotal, 1), '0'), '.') }} @else 暂无得分数据 @endif
  • 得分率:{{ $scoreRate !== null ? number_format((float) $scoreRate * 100, 1) . '%' : '暂无得分率' }}
  • 平均掌握度:{{ $averageMastery !== null ? number_format((float) $averageMastery * 100, 1) . '%' : '暂无掌握度' }}
  • 难度匹配: @if(!empty($difficultySummary['target_label']) && isset($difficultySummary['actual_average_difficulty'])) 目标 {{ $difficultySummary['target_label'] }} @if(!empty($difficultySummary['target_range'])) ({{ number_format((float)($difficultySummary['target_range']['min'] ?? 0), 2) }}~{{ number_format((float)($difficultySummary['target_range']['max'] ?? 0), 2) }}) @endif ,实际 {{ number_format((float)($difficultySummary['actual_average_difficulty'] ?? 0), 3) }} ({{ $difficultySummary['status'] ?? '暂无' }}) @else 暂无难度匹配数据 @endif
  • @if(!empty($difficultySummary['explain']))
  • 难度说明:{{ $difficultySummary['explain'] }}
  • @endif
  • 与历史自己对比: @if(!empty($historySummary['is_first_exam'])) {{ $historySummary['message'] ?? '这是你的第一次分析报告,先积累样本再看趋势。' }} @elseif(!empty($historySummary['low_baseline_guard'])) {{ $historySummary['message'] ?? '历史基线偏低,建议看连续趋势。' }} @elseif(!empty($historySummary['has_data'])) @php $trendText = (string)($historySummary['trend'] ?? '—'); $tVisual = $trendVisual($trendText); @endphp 近几次均值对比: {{ number_format((float)($historySummary['baseline_score_rate'] ?? 0) * 100, 1) }}%, 本次{{ ($historySummary['delta_score_rate'] ?? 0) >= 0 ? '提升' : '回落' }} {{ number_format(abs((float)($historySummary['delta_score_rate'] ?? 0)) * 100, 1) }}% ({{ $tVisual['icon'] ?? '•' }} {{ $trendText }}) @else {{ $historySummary['message'] ?? '历史样本不足' }} @endif
  • @if(!empty($peerSummary['show_line']))
  • 与同群体对比: {{ $peerSummary['message'] ?? '' }} ({{ $peerSummary['band_icon'] ?? '•' }} {{ $peerSummary['band'] ?? '—' }}
  • @endif
  • 整体水平: @if($overallScore !== null) {{ number_format($overallScore, 1) }} 分({{ $overallGrade }}) @else 待计算 @endif
规则:综合分 = 当前50% + 历史25% + 同群体25% + 难度校正,即:(({{ number_format($scoreRate !== null ? (float)$scoreRate * 100 : 0, 1) }}×70% + {{ number_format($averageMastery !== null ? (float)$averageMastery * 100 : 0, 1) }}×30%)×50%) + {{ number_format($historyPart, 1) }}×25% + {{ number_format($peerPart, 1) }}×25% + {{ number_format($adjustPart, 1) }} = {{ number_format($overallScore ?? $compositeFormulaResult, 1) }}
二、知识点掌握聚类视图
已掌握 薄弱 未入门 未学习 按“模块 → 子模块 → 知识点”聚类展示
@foreach($clusterCards as $cluster)
{{ $cluster['grand_name'] }}
@if(!empty($cluster['parent_groups'])) @foreach($cluster['parent_groups'] as $parent)
{{ $parent['parent_name'] }}
@foreach($parent['points'] as $point) @endforeach
@endforeach @else
当前模块暂无可展示的子知识点。
@endif
@endforeach
总知识点数
{{ $kpStatsTotal['total'] }}
已掌握
{{ $kpStatsTotal['mastered'] }}({{ $kpPct($kpStatsTotal['mastered'], $kpStatsTotal['total']) }})
薄弱
{{ $kpStatsTotal['weak'] }}({{ $kpPct($kpStatsTotal['weak'], $kpStatsTotal['total']) }})
未入门
{{ $kpStatsTotal['beginner'] }}({{ $kpPct($kpStatsTotal['beginner'], $kpStatsTotal['total']) }})
未学习
{{ $kpStatsTotal['unlearned'] }}({{ $kpPct($kpStatsTotal['unlearned'], $kpStatsTotal['total']) }})
三、模块现状与提分路径(全局+本学案影响)
本学案知识点变化情况
@if(!empty($kpChangeItems))
    @foreach($kpChangeItems as $item) @php $delta = (float) ($item['change'] ?? 0); $deltaText = ($delta >= 0 ? '+' : '') . number_format($delta * 100, 1) . '%'; $deltaColor = $delta > 0 ? '#16a34a' : ($delta < 0 ? '#dc2626' : '#64748b'); $masteryText = isset($item['mastery_level']) && $item['mastery_level'] !== null ? number_format((float) $item['mastery_level'] * 100, 1) . '%' : '--'; @endphp
  • {{ $item['name'] ?? '-' }}: {{ $deltaText }} (掌握度{{ $masteryText }},{{ $item['status'] ?? '未学习' }})
  • @endforeach
@else
暂无可用的知识点变化数据
@endif
本次学案影响模块: @if(!empty($impactedModules)) @foreach($impactedModules as $idx => $im) @php $mName = $im['module_name'] ?? '-'; @endphp {{ $mName }}({{ $im['question_count'] ?? 0 }}题) @endforeach @else 暂无命中模块 @endif
@forelse($moduleRowsWithStatus as $m) @php $status = (string) ($m['status'] ?? '暂无'); $color = $statusColor($status); $rate = $m['exam_score_rate'] ?? null; $qCount = (int) ($m['question_count'] ?? 0); $isImpacted = $qCount > 0; $pathTag = $pathTagByModuleName[(string) ($m['module_name'] ?? '')] ?? '待观察'; $pathColor = match ($pathTag) { '优先加强' => '#ef4444', '需要加强' => '#f59e0b', '保分不错' => '#16a34a', default => '#64748b', }; $moduleCode = (string) ($m['module_code'] ?? ''); $impactDelta = $moduleImpactChangeMap[$moduleCode] ?? null; $impactArrow = $impactDelta === null ? '' : ($impactDelta > 0.0005 ? '↑' : ($impactDelta < -0.0005 ? '↓' : '→')); $impactColor = $impactDelta === null ? '#64748b' : ($impactDelta > 0.0005 ? '#16a34a' : ($impactDelta < -0.0005 ? '#dc2626' : '#64748b')); $impactText = $impactDelta === null ? '' : number_format(abs($impactDelta) * 100, 1) . '%'; $impactSuffix = $impactArrow === '→' ? '' : $impactText; $moduleName = (string) ($m['module_name'] ?? ''); $focus = $moduleSuggestionByName[$moduleName] ?? null; $focusText = '-'; if (is_array($focus)) { $focusName = (string) ($focus['kp_name'] ?? ''); $focusTypes = !empty($focus['question_types']) ? implode('、', $focus['question_types']) : ''; $focusMastery = isset($focus['mastery_level']) && $focus['mastery_level'] !== null ? number_format((float) $focus['mastery_level'] * 100, 1) . '%' : '--'; $focusSuffix = $focusTypes !== '' ? (',' . $focusTypes) : ''; $focusText = $focusName !== '' ? ($focusName . '(' . $focusMastery . $focusSuffix . ')') : '-'; } @endphp @empty @endforelse
模块 本次影响 掌握度
(学案影响)
掌握状态 题目数 得分率 路径建议 关注知识点
{{ $m['module_name'] ?? '-' }} @if($isImpacted) @else @endif {{ isset($m['mastery_level']) && $m['mastery_level'] !== null ? number_format((float) $m['mastery_level'] * 100, 1) . '%' : '-' }} @if($impactArrow !== '') {{ $impactArrow }}{{ $impactSuffix }} @endif {{ $status }} {{ $m['question_count'] ?? 0 }} {{ $rate !== null ? number_format((float) $rate * 100, 1) . '%' : '-' }} {{ $pathTag }} {{ $focusText }}
暂无掌握状态数据
@if(!empty($wrongQuestions))
四、这次错题记录
@if(!empty($kpWrongStats))
知识点错误率
@foreach($kpWrongStats as $item) {{ $item['kp_name'] }}:{{ $item['wrong'] }}/{{ $item['total'] }}({{ number_format($item['rate'] * 100, 1) }}%) @endforeach
@endif @foreach($wrongQuestions as $q) @php $studentAnswer = $q['student_answer'] ?? null; $correctAnswer = $q['answer'] ?? $q['correct_answer'] ?? null; $isCorrect = $q['is_correct'] ?? null; if ($isCorrect === null && !empty($studentAnswer) && !empty($correctAnswer)) { $isCorrect = (trim($studentAnswer) === trim($correctAnswer)) ? 1 : 0; } $statusText = ''; $statusColorValue = ''; if ($isCorrect === 1) { $statusText = '正确'; $statusColorValue = '#10b981'; } elseif ($isCorrect === 0) { $statusText = '错误'; $statusColorValue = '#ef4444'; } $showStatus = $statusText !== ''; $insight = $insightMap[$q['question_number']] ?? ($insightMap[$q['display_number'] ?? null] ?? []); $fullScore = $insight['full_score'] ?? ($q['score'] ?? null); if ($isCorrect === 1) { $score = $fullScore; } elseif ($isCorrect === 0) { $score = $q['score_obtained'] ?? 0; } else { $score = null; } $analysisRaw = $insight['analysis'] ?? $insight['thinking_process'] ?? $insight['feedback'] ?? $insight['suggestions'] ?? $insight['reason'] ?? ($insight['correct_solution'] ?? null); if (empty($analysisRaw) && !empty($insight['next_steps'])) { $analysisRaw = '后续建议:' . (is_array($insight['next_steps']) ? implode(';', $insight['next_steps']) : $insight['next_steps']); } $analysis = is_array($analysisRaw) ? json_encode($analysisRaw, JSON_UNESCAPED_UNICODE) : $analysisRaw; if ($analysis === null || $analysis === '') { $analysis = '暂无解题思路,待补充'; } if (is_string($analysis)) { $analysis = preg_replace('/^【?\s*解题思路\s*】?\s*[::]?\s*/u', '', $analysis); } $formatSolutionLikeGrading = function ($text) { if (!is_string($text) || trim($text) === '') { return $text; } $normalized = preg_replace('/\s*;\s*步骤\s*(\d+)/u', ";\n步骤$1", $text); $normalized = preg_replace('/\s*。\s*步骤\s*(\d+)/u', "。\n步骤$1", $normalized); $normalized = preg_replace('/(? '选择题', 'fill' => '填空题', 'answer' => '解答题']; $typeLabel = $typeMap[$q['question_type'] ?? ''] ?? ($q['question_type'] ?? '题型未标注'); $questionText = is_string($q['question_text']) ? $q['question_text'] : json_encode($q['question_text'], JSON_UNESCAPED_UNICODE); $solution = $q['solution'] ?? null; if (is_string($solution)) { $solution = preg_replace('/^【?\s*解题思路\s*】?\s*[::]?\s*/u', '', $solution); } $solution = $formatSolutionLikeGrading($solution); $analysis = $formatSolutionLikeGrading($analysis); $renderLikeGrading = function ($text) { if (is_array($text)) { $text = json_encode($text, JSON_UNESCAPED_UNICODE); } $text = is_string($text) ? trim($text) : ''; if ($text === '') { return ''; } // 兼容题库里常见的转义写法:\$x\$、\$\frac{...}\$ $text = preg_replace('/\\\\\\$/u', '$', $text); return \App\Services\MathFormulaProcessor::processFormulas($text); }; $questionTextRendered = $renderLikeGrading($questionText); $displayCorrectAnswer = is_array($correctAnswer) ? json_encode($correctAnswer, JSON_UNESCAPED_UNICODE) : (string) $correctAnswer; $questionTypeRaw = strtolower(trim((string) ($q['question_type'] ?? ''))); $isChoiceQuestion = in_array($questionTypeRaw, ['choice', 'multiple_choice', 'single_choice', '选择题', 'select'], true); $normalizedOptions = []; $correctAnswerLetters = []; if ($isChoiceQuestion) { $rawOptions = $q['options'] ?? []; if (is_string($rawOptions)) { $decodedOptions = json_decode($rawOptions, true); $rawOptions = is_array($decodedOptions) ? $decodedOptions : []; } if (is_array($rawOptions)) { foreach ($rawOptions as $optKey => $optValue) { $letter = null; if (is_string($optKey) && preg_match('/([A-H])/i', $optKey, $m)) { $letter = strtoupper($m[1]); } elseif (is_array($optValue)) { $candidate = $optValue['label'] ?? $optValue['key'] ?? $optValue['option'] ?? null; if (is_string($candidate) && preg_match('/([A-H])/i', $candidate, $m)) { $letter = strtoupper($m[1]); } } if ($letter === null) { continue; } $content = is_array($optValue) ? ($optValue['content'] ?? $optValue['text'] ?? $optValue['value'] ?? '') : $optValue; if (!is_string($content)) { $content = json_encode($content, JSON_UNESCAPED_UNICODE); } $content = trim((string) $content); if ($content !== '') { $normalizedOptions[$letter] = $content; } } } if (trim((string) $correctAnswer) !== '') { preg_match_all('/[A-H]/i', strtoupper((string) $correctAnswer), $answerMatches); $correctAnswerLetters = array_values(array_unique($answerMatches[0] ?? [])); } if (!empty($normalizedOptions) && !empty($correctAnswerLetters)) { $mappedAnswers = []; foreach ($correctAnswerLetters as $letter) { if (isset($normalizedOptions[$letter])) { $mappedAnswers[] = $letter . '. ' . $normalizedOptions[$letter]; } } if (!empty($mappedAnswers)) { $displayCorrectAnswer = implode(';', $mappedAnswers); } } } $choiceOptionLetters = !empty($normalizedOptions) ? array_keys($normalizedOptions) : []; sort($choiceOptionLetters); $choiceLayoutClass = 'options-grid-1'; $layoutDecider = app(\App\Support\OptionLayoutDecider::class); if (! empty($normalizedOptions) && ! empty($choiceOptionLetters)) { $optValuesForLayout = []; foreach ($choiceOptionLetters as $L) { $optValuesForLayout[] = $normalizedOptions[$L]; } $layoutMeta = $layoutDecider->decide($optValuesForLayout, 'grading'); $choiceLayoutClass = $layoutMeta['class'] ?? 'options-grid-1'; } @endphp
题号 {{ $q['display_number'] ?? $q['question_number'] }} · {{ $typeLabel }} @php $kpName = $q['knowledge_point_name'] ?? $q['knowledge_point'] ?? null; if (!empty($kpName) && $kpName !== '-' && $kpName !== '未标注') { echo '' . e($kpName) . ''; } @endphp @if($showStatus) {{ $statusText }} @endif
@if($score !== null && $fullScore !== null)
得分 {{ $score }} / {{ $fullScore }}
@endif
{!! $questionTextRendered !!}
@if(!empty($isChoiceQuestion) && !empty($normalizedOptions))
@foreach($choiceOptionLetters as $optLetter) @php $isCorrectOpt = in_array($optLetter, $correctAnswerLetters ?? [], true); $rawOpt = (string) ($normalizedOptions[$optLetter] ?? ''); $normalizedOpt = str_replace('\\dfrac', '\\frac', $rawOpt); $normalizedOpt = str_replace('\\displaystyle', '', $normalizedOpt); $normalizedOpt = $layoutDecider->normalizeCompactMathForDisplay($normalizedOpt); $rawOptPlain = html_entity_decode(strip_tags($rawOpt), ENT_QUOTES | ENT_HTML5, 'UTF-8'); $rawOptPlain = preg_replace('/\s+/u', '', $rawOptPlain ?? ''); $isShortOption = mb_strlen((string) $rawOptPlain, 'UTF-8') <= 8; $valClass = $isShortOption ? 'option-short' : 'option-long'; $renderedOpt = $renderLikeGrading($normalizedOpt); @endphp
{{ $optLetter }}. {!! $renderedOpt !!} @if($isCorrectOpt) @endif
@endforeach
@endif @if(!empty($correctAnswer) && (!$isChoiceQuestion || empty($normalizedOptions)))
正确答案
{!! $renderLikeGrading($displayCorrectAnswer) !!}
@endif @if(!empty($solution))
解题思路: {!! $renderLikeGrading($solution) !!}
@elseif(!empty($analysis) && $analysis !== '暂无解题思路记录')
解题思路: {!! $renderLikeGrading($analysis) !!}
@endif @if(!empty($steps))
解题步骤
    @foreach($steps as $s) @php $stepText = is_array($s) ? json_encode($s, JSON_UNESCAPED_UNICODE) : (string) $s; @endphp
  1. {!! nl2br($renderLikeGrading($stepText)) !!}
  2. @endforeach
@endif
@endforeach
@endif