Procházet zdrojové kódy

fix: 智能组卷(type 1/8)强制10题,忽略前端传入的total_questions

前端请求显式传入total_questions=20导致默认值逻辑不生效,
改为对type 1/8强制覆盖为10题,其他类型保持原有默认逻辑。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gwd před 1 dnem
rodič
revize
b8585658f2

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

@@ -126,8 +126,11 @@ class IntelligentExamController extends Controller
 
 
         $data = $validator->validated();
         $data = $validator->validated();
         $assembleType = (int) ($data['assemble_type'] ?? 4);
         $assembleType = (int) ($data['assemble_type'] ?? 4);
-        $defaultQuestions = in_array($assembleType, [1, 8]) ? 10 : 20;
-        $data['total_questions'] = $data['total_questions'] ?? $defaultQuestions;
+        if (in_array($assembleType, [1, 8])) {
+            $data['total_questions'] = 10;
+        } else {
+            $data['total_questions'] = $data['total_questions'] ?? 20;
+        }
         $this->ensureStudentTeacherRelation($data);
         $this->ensureStudentTeacherRelation($data);
 
 
         // 【修改】使用series_id、semester_code和grade获取textbook_id
         // 【修改】使用series_id、semester_code和grade获取textbook_id