Browse Source

fix(exam): assemble_type=15 展示为错题追练,5 保持智能追练并统一文案

Made-with: Cursor
yemeishu 1 month ago
parent
commit
906143bc5c

+ 2 - 2
app/Http/Controllers/Api/IntelligentExamController.php

@@ -171,11 +171,11 @@ class IntelligentExamController extends Controller
             return response()->json([
                 'success' => false,
                 'message' => '参数错误',
-                'errors' => ['paper_ids' => ['assemble_type 为 15(错题本组卷)时,paper_ids 须为非空数组,元素为题库题目 question_id,且该学生错题本中须存在对应错题记录']], 
+                'errors' => ['paper_ids' => ['assemble_type 为 15(错题追练)时,paper_ids 须为非空数组,元素为题库题目 question_id,且该学生错题本中须存在对应错题记录']], 
             ], 422);
         }
 
-        // API 固定题量:含追练(5)、错题本组卷(15) 等,一律 default_total_questions,不使用请求题量参数
+        // API 固定题量:含按卷追练(5)、错题追练(15) 等,一律 default_total_questions,不使用请求题量参数
         $data['total_questions'] = (int) config('question_bank.default_total_questions');
         // 预分配 paper_id,保证接口语义稳定(后续异步化时也可继续同步返回)
         $reservedPaperId = $this->questionBankService->generatePaperId();

+ 4 - 4
app/Jobs/AssembleExamTaskJob.php

@@ -63,10 +63,10 @@ class AssembleExamTaskJob implements ShouldQueue
             $explanationKpCodes = null;
 
             if ($assembleType === 15) {
-                // 错题本组卷:paper_ids 传题库题目 question_id(须在该学生错题本 mistake_records 中存在),与 assemble_type=5 按卷追练(真实试卷 paper_id)分离
+                // assemble_type=15(展示类型「错题追练」):paper_ids 为题库 question_id,须在该学生 mistake_records 中存在;与 assemble_type=5(卷 id 追练)分离
                 $questionIdList = $this->normalizeBankQuestionIdsList($paperIds);
                 if ($questionIdList === []) {
-                    $taskManager->markTaskFailed($this->taskId, '错题组卷需提供 paper_ids(题库题目 id)');
+                    $taskManager->markTaskFailed($this->taskId, '错题追练组卷需提供 paper_ids(题库题目 id)');
                     return;
                 }
 
@@ -89,7 +89,7 @@ class AssembleExamTaskJob implements ShouldQueue
 
                 $questions = $this->hydrateQuestions($bankQuestions, $data['kp_codes'] ?? []);
                 $questions = $this->sortQuestionsByRequestedIds($questions, $questionIds);
-                $paperName = $data['paper_name'] ?? ('错题本组卷_'.$data['student_id'].'_'.now()->format('Ymd_His'));
+                $paperName = $data['paper_name'] ?? ('错题追练_'.$data['student_id'].'_'.now()->format('Ymd_His'));
             } elseif (! empty($mistakeIds) || ! empty($mistakeQuestionIds)) {
                 // assemble_type=5 时 mistake_ids / mistake_question_ids 须严格归属该学生;其它类型走宽松解析。
                 if ($assembleType === 5) {
@@ -274,7 +274,7 @@ class AssembleExamTaskJob implements ShouldQueue
     /**
      * 追练(assemble_type=5)+ 指定错题:mistake_ids 须逐条命中该学生的 mistake_records;
      * mistake_question_ids 须在该学生错题本中至少有一条记录。顺序:先按 mistake_ids 请求顺序,再追加题号列表(去重)。
-     * 错题本组卷(assemble_type=15)将 paper_ids 解析为题库题目 id 后,仅使用本方法的 mistake_question_ids 分支做校验。
+     * assemble_type=15(错题追练)将 paper_ids 解析为题库题目 id 后,仅使用本方法的 mistake_question_ids 分支做校验。
      *
      * @return array{ok: bool, message?: string, question_ids?: array<int, string>}
      */

+ 2 - 2
app/Services/ExamTypeStrategy.php

@@ -35,7 +35,7 @@ class ExamTypeStrategy
 
     /**
      * 根据组卷类型构建参数
-     * assembleType: 0-章节摸底, 1-智能组卷, 2-知识点组卷, 3-教材组卷, 4-通用, 5-按卷追练(paper_ids=试卷), 8-智能组卷(新), 9-原摸底, 15-错题本组卷(paper_ids=题库题目id,由队列单独处理)
+     * assembleType: 0-章节摸底, 1-智能组卷, 2-知识点组卷, 3-教材组卷, 4-通用, 5-按卷追练(paper_ids=试卷), 8-智能组卷(新), 9-原摸底, 15-错题追练(paper_ids=题库题目id,由 AssembleExamTaskJob 单独处理)
      *
      * 映射规则(前端不改,后端动态处理):
      * - 0, 9(摸底)→ 章节摸底(新逻辑)
@@ -447,7 +447,7 @@ class ExamTypeStrategy
             'total_score' => $maxTotalScore
         ]);
 
-        Log::debug('ExamTypeStrategy: 错题本组卷关键参数', [
+        Log::debug('ExamTypeStrategy: 按卷追练(5)关键参数', [
             'paper_ids' => $paperIds,
             'kp_code_list' => array_values($paperKnowledgePoints),
             'difficulty_category' => $difficultyCategory,

+ 0 - 1
app/Services/LearningAnalyticsService.php

@@ -1377,7 +1377,6 @@ class LearningAnalyticsService
             // 【修改】错题本类型严格按错题组卷,不补充题目
             if ($isMistakeBook) {
                 $mistakeKpSource = (bool) ($params['mistake_kp_source'] ?? false);
-                // 记录错题本组卷信息
                 Log::info('LearningAnalyticsService: 错题本严格按错题组卷,不补充题目', [
                     'mistake_count' => count($priorityQuestions),
                     'assemble_type' => $assembleType,

+ 1 - 1
app/Support/PaperNaming.php

@@ -15,7 +15,7 @@ class PaperNaming
             2 => '知识点组题',
             3 => '教材组题',
             5 => '智能追练',
-            15 => '错题本组卷',
+            15 => '错题追练',
             default => throw new InvalidArgumentException("不支持的 assemble_type: {$assembleType}"),
         };
     }