@include('components.exam.paper-body', ['questions' => $questions])
{{-- 参考答案(仅在开启时显示) --}}
@if($includeAnswer)
参考答案
{{ $paper->paper_name ?? '未命名试卷' }}
{{-- 选择题答案 --}}
@if(count($questions['choice']) > 0)
一、选择题
@foreach($questions['choice'] as $index => $q)
{{ $index + 1 }}.
@if(!empty($q->answer))
@php
// 提取答案中的选项字母
$answerText = $q->answer;
$letter = '';
if (preg_match('/([A-D])/i', $answerText, $match)) {
$letter = strtoupper($match[1]);
} elseif (preg_match('/答案[::]\s*([A-D])/i', $answerText, $match)) {
$letter = strtoupper($match[1]);
}
echo $letter ?: '(待补充)';
@endphp
@else
(待补充)
@endif
@endforeach
@endif
{{-- 填空题答案 --}}
@if(count($questions['fill']) > 0)
二、填空题
@foreach($questions['fill'] as $index => $q)
{{ count($questions['choice']) + $index + 1 }}.
@if(!empty($q->answer))
@math($q->answer)
@else
(待补充)
@endif
@endforeach
@endif
{{-- 解答题答案 --}}
@if(count($questions['answer']) > 0)
三、解答题
@foreach($questions['answer'] as $index => $q)
@php
$questionNumber = count($questions['choice']) + count($questions['fill']) + $index + 1;
@endphp
{{ $questionNumber }}. ({{ $q->score ?? 10 }}分)
@if(!empty($q->answer))
@math($q->answer)
@else
(答案待补充或请参考标准答案)
@endif
@if(!empty($q->solution))
解析: @math($q->solution)
@endif
@endforeach
@endif
@endif