答案速查
@foreach($quickAnswers as $item)
{{ $item['no'] }}. {!! $item['answer'] !!}
@endforeach
@foreach($allQuestions as $item)
@php
$q = $item['q'];
$no = (int) ($q->question_number ?? 0);
$detailType = strtolower((string) ($item['detail_type'] ?? ''));
$isAnswerType = $detailType === 'answer';
$rawAnswer = trim((string) ($q->answer ?? ''));
$rawSolution = $normalizeDetailHtml($q->solution ?? '');
$isSeeSolutionAnswer = (bool) preg_match('/^见\s*解析[。\.]?$|^详见解析/u', $rawAnswer);
$hasImageLikeSolution = (bool) preg_match('/<\s*img\b|<\s*image\b|(^|[\s>])img\s+src\s*=/iu', $rawSolution);
$showAnswer = !$isSeeSolutionAnswer;
$renderAnswer = $rawAnswer !== ''
? \App\Services\MathFormulaProcessor::processFormulas($rawAnswer)
: '—';
if ($rawSolution === '') {
$renderSolution = '(无详解)';
} elseif ($hasImageLikeSolution) {
// 与判卷页保持一致:图片型解析优先保留原始HTML结构,避免标签被公式处理链打散为纯文本
$renderSolution = $formatDetailForReadability($rawSolution);
} else {
$renderSolution = \App\Services\MathFormulaProcessor::processFormulas($formatDetailForReadability($rawSolution));
}
if ($isAnswerType) {
$renderSolution = $renderSolutionLikeGrading($renderSolution, true);
} else {
$renderSolution = $renderSolutionLikeGrading($renderSolution, false);
}
// 版式规则:
// 1) 选择/填空同行
// 2) 简答默认解析另起一行
// 3) 若答案为“见解析”被隐藏,则题号与【解析】同行
$useSplitAnalysisLine = $isAnswerType && $showAnswer;
@endphp
@if($useSplitAnalysisLine)
{{ $no }}.
{!! $renderAnswer !!}
【解析】
{!! $renderSolution !!}
@else
{{ $no }}.
@if($showAnswer)
{!! $renderAnswer !!}
@endif
【解析】
{!! $renderSolution !!}
@endif
@endforeach