Browse Source

Revert "fix restore choice options in local PDF rendering"

This reverts commit 98c1e0b851658ed993d0dcb2096a796921ab2686.
yemeishu 2 weeks ago
parent
commit
9c5f11d82e
1 changed files with 1 additions and 31 deletions
  1. 1 31
      app/Services/ExamPdfExportService.php

+ 1 - 31
app/Services/ExamPdfExportService.php

@@ -2010,39 +2010,9 @@ class ExamPdfExportService
 
             // 构造视图需要的变量
             $questions = ['choice' => [], 'fill' => [], 'answer' => []];
-            $questionBankIds = $paper->questions
-                ->pluck('question_bank_id')
-                ->filter()
-                ->unique()
-                ->values();
-            $optionsByBankId = [];
-            if ($questionBankIds->isNotEmpty()) {
-                $optionsByBankId = Question::whereIn('id', $questionBankIds)
-                    ->pluck('options', 'id')
-                    ->toArray();
-            }
             foreach ($paper->questions as $pq) {
                 $qType = $this->normalizeQuestionType($pq->question_type ?? 'answer');
-                $normalizedQuestion = $this->normalizeAnswerFieldForPdf($pq);
-
-                // 本地渲染链路下,paper_questions 通常不带 options,需要从题库回填选择题选项。
-                if ($qType === 'choice') {
-                    $options = $normalizedQuestion->options ?? null;
-                    if (empty($options) && ! empty($normalizedQuestion->question_bank_id)) {
-                        $options = $optionsByBankId[$normalizedQuestion->question_bank_id] ?? null;
-                    }
-                    if (is_string($options)) {
-                        $decoded = json_decode($options, true);
-                        if (json_last_error() === JSON_ERROR_NONE) {
-                            $options = $decoded;
-                        }
-                    }
-                    if (is_array($options)) {
-                        $normalizedQuestion->options = $options;
-                    }
-                }
-
-                $questions[$qType][] = $normalizedQuestion;
+                $questions[$qType][] = $this->normalizeAnswerFieldForPdf($pq);
             }
 
             $studentModel = \App\Models\Student::find($paper->student_id);