@php // 【参考试卷和判卷格式】学情报告以3开头 + 12位paper_id数字部分 $rawPaperId = $paper['id'] ?? $paper['paper_id'] ?? 'unknown'; // 从 paper_id 提取12位数字部分(格式: paper_xxxxxxxxxxxx) if (preg_match('/paper_(\d{12})/', $rawPaperId, $matches)) { $paperIdNum = $matches[1]; } else { // 兼容旧格式,取数字部分或生成哈希 $paperIdNum = preg_replace('/[^0-9]/', '', $rawPaperId); $paperIdNum = str_pad(substr($paperIdNum, 0, 12), 12, '0', STR_PAD_LEFT); } $reportCode = '3' . $paperIdNum; // 学情报告识别码:3 + 12位数字 $averageMastery = isset($mastery['average']) ? number_format($mastery['average'] * 100, 1) . '%' : '无数据'; // 【修复】从insights中获取AI分析结果(而不是从analysis_data) $questionAnalysis = $insights ?? []; @endphp 学情报告 - {{ $paper['name'] ?? '试卷' }}

学情分析报告

试卷:{{ $paper['name'] ?? '-' }} | 学生:{{ $student['name'] ?? '-' }} | 年级:{{ $student['grade'] ?? '-' }}
题目数:{{ is_array($questions ?? null) ? count($questions) : ($paper['total_questions'] ?? '-') }}
知识点掌握度
@php // 【修复】过滤掉K-GENERAL等通用知识点,只显示有值的知识点 $filteredMasteryItems = []; if (!empty($mastery['items'])) { foreach ($mastery['items'] as $item) { $kpCode = $item['kp_code'] ?? ''; $masteryLevel = $item['mastery_level'] ?? 0; // 过滤条件:不是通用知识点,且掌握度>0 if (!in_array($kpCode, ['K-GENERAL', 'GENERAL', 'DEFAULT']) && $masteryLevel > 0) { $filteredMasteryItems[] = $item; } } } @endphp @if(!empty($filteredMasteryItems)) @foreach($filteredMasteryItems as $item) @php $pct = min(100, max(0, ($item['mastery_level'] ?? 0) * 100)); $barColor = $pct >= 80 ? '#10b981' : ($pct >= 60 ? '#f59e0b' : '#ef4444'); $delta = $item['mastery_change'] ?? null; // 只有当有变化值时才显示变化信息 $changeText = ''; if ($delta !== null && $delta !== '' && abs($delta) > 0.001) { $changeText = ($delta > 0 ? '↑ ' : '↓ ') . number_format(abs($delta) * 100, 1) . '%'; } @endphp
{{ $item['kp_name'] ?? $item['kp_code'] ?? '未知知识点' }}
{{ number_format($pct, 1) }}% {{ $changeText }}
@endforeach @else
暂无有效掌握度数据(已过滤通用知识点和零值)
@endif
📊 知识点层级掌握度分析
@php $parentMasteryLevels = $parent_mastery_levels ?? []; $hasParentMastery = !empty($parentMasteryLevels); @endphp @if($hasParentMastery) @foreach($parentMasteryLevels as $parentData) @php $pct = $parentData['mastery_percentage'] ?? 0; $barColor = $pct >= 80 ? '#10b981' : ($pct >= 60 ? '#f59e0b' : '#ef4444'); $parentName = $parentData['kp_name'] ?? $parentData['kp_code']; $children = $parentData['children'] ?? []; $level = $parentData['level'] ?? 1; $delta = $parentData['mastery_change'] ?? null; // 只有当有变化值时才显示变化信息 $changeText = ''; if ($delta !== null && $delta !== '' && abs($delta) > 0.001) { $changeText = ($delta > 0 ? '↑ ' : '↓ ') . number_format(abs($delta) * 100, 1) . '%'; } @endphp
【第{{ $level }}级】{{ $parentName }} ({{ $parentData['kp_code'] }})
{{ number_format($pct, 1) }}% @if(!empty($changeText)) {{ $changeText }} @endif
@if(!empty($children))
包含子知识点({{ count($children) }}个): @foreach($children as $index => $child) @if($index < 8) {{ $child['kp_name'] }} @endif @endforeach @if(count($children) > 8) ...等{{ count($children) }}个知识点 @endif
@else
无直接子知识点或子知识点掌握度为0
@endif
@endforeach
学习建议: 建议重点关注掌握度较低的知识点,通过专项练习提升整体学习水平。优先练习掌握度低于60%的知识点。
@else
暂无父节点掌握度数据
当前分析主要基于具体知识点掌握度。完整的层级掌握度分析需要在系统中建立完整的知识点层级关系。
@endif
题目列表
@php $insightMap = []; foreach (($question_insights ?? []) as $insight) { $no = $insight['question_number'] ?? $insight['question_id'] ?? null; if ($no !== null) { $insightMap[$no] = $insight; } } @endphp @foreach($questions as $q) @php // 【修复】从题目数据中获取学生答案、正确答案和判分结果 $studentAnswer = $q['student_answer'] ?? $q['student_answer'] ?? null; $correctAnswer = $q['answer'] ?? $q['correct_answer'] ?? null; $isCorrect = $q['is_correct'] ?? null; // 1=正确,0=错误,null=未判 // 如果未判分但有学生答案和正确答案,自动比较判断 if ($isCorrect === null && !empty($studentAnswer) && !empty($correctAnswer)) { $isCorrect = (trim($studentAnswer) === trim($correctAnswer)) ? 1 : 0; } // 判分状态显示逻辑 $showStatus = false; $statusText = ''; $statusColor = ''; if (!empty($studentAnswer)) { // 学生有答题,显示判分结果 $showStatus = true; if ($isCorrect === 1) { $statusText = '正确'; $statusColor = '#10b981'; } elseif ($isCorrect === 0) { $statusText = '错误'; $statusColor = '#ef4444'; } } // 没答题的不显示状态 $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) { // 答错了,显示实际得分(可能为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 = '暂无解题思路,待补充'; } $stepsRaw = $insight['steps'] ?? $insight['solution_steps'] ?? $insight['analysis_steps'] ?? null; $steps = []; if (is_array($stepsRaw)) { $steps = $stepsRaw; } elseif (is_string($stepsRaw) && trim($stepsRaw) !== '') { $steps = preg_split('/[\r\n]+/', trim($stepsRaw)); } $typeMap = ['choice' => '选择题', '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; @endphp
题号 {{ $q['display_number'] ?? $q['question_number'] }} @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
{{-- 【新增】学生答案显示(如果有) --}} @if(!empty($studentAnswer))
学生答案
{!! nl2br(e($studentAnswer)) !!}
@endif
{!! $questionText !!}
题型:{{ $typeLabel }}
{{-- 【修复】正确答案显示 --}} @if(!empty($correctAnswer))
正确答案
{!! nl2br(e($correctAnswer)) !!}
@endif {{-- 【修改】解题思路显示(优先显示solution,其次显示analysis) --}} @if(!empty($solution))
解题思路
{!! is_array($solution) ? json_encode($solution, JSON_UNESCAPED_UNICODE) : nl2br(e($solution)) !!}
@elseif(!empty($analysis) && $analysis !== '暂无解题思路记录')
解题思路
{!! nl2br(e($analysis)) !!}
@endif {{-- 解题步骤(如果有) --}} @if(!empty($steps))
解题步骤
    @foreach($steps as $s)
  1. {!! nl2br(e(is_array($s) ? json_encode($s, JSON_UNESCAPED_UNICODE) : $s)) !!}
  2. @endforeach
@endif
@endforeach
{{-- 闭合page div --}}