|
@@ -125,7 +125,9 @@ class IntelligentExamController extends Controller
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$data = $validator->validated();
|
|
$data = $validator->validated();
|
|
|
- $data['total_questions'] = $data['total_questions'] ?? 20;
|
|
|
|
|
|
|
+ $assembleType = (int) ($data['assemble_type'] ?? 4);
|
|
|
|
|
+ $defaultQuestions = in_array($assembleType, [1, 8]) ? 10 : 20;
|
|
|
|
|
+ $data['total_questions'] = $data['total_questions'] ?? $defaultQuestions;
|
|
|
$this->ensureStudentTeacherRelation($data);
|
|
$this->ensureStudentTeacherRelation($data);
|
|
|
|
|
|
|
|
// 【修改】使用series_id、semester_code和grade获取textbook_id
|
|
// 【修改】使用series_id、semester_code和grade获取textbook_id
|
|
@@ -257,9 +259,16 @@ class IntelligentExamController extends Controller
|
|
|
$questions = array_slice($questions, 0, $totalQuestions);
|
|
$questions = array_slice($questions, 0, $totalQuestions);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 调整题目分值,确保符合目标总分
|
|
|
|
|
- $targetTotalScore = $data['total_score'] ?? 100.0;
|
|
|
|
|
- $questions = $this->adjustQuestionScores($questions, $targetTotalScore);
|
|
|
|
|
|
|
+ // 调整题目分值
|
|
|
|
|
+ if (($data['total_questions'] ?? 20) == 20) {
|
|
|
|
|
+ // 20题:沿用动态凑整算法,目标总分100
|
|
|
|
|
+ $targetTotalScore = $data['total_score'] ?? 100.0;
|
|
|
|
|
+ $questions = $this->adjustQuestionScores($questions, $targetTotalScore);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 非20题:固定题型分值(选择5、填空5、解答10)
|
|
|
|
|
+ $questions = $this->applyFixedScores($questions);
|
|
|
|
|
+ $targetTotalScore = array_sum(array_column($questions, 'score'));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 计算总分
|
|
// 计算总分
|
|
|
$totalScore = array_sum(array_column($questions, 'score'));
|
|
$totalScore = array_sum(array_column($questions, 'score'));
|
|
@@ -869,6 +878,26 @@ class IntelligentExamController extends Controller
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 非20题时使用固定题型分值
|
|
|
|
|
+ * 选择题:5分,填空题:5分,解答题:10分
|
|
|
|
|
+ */
|
|
|
|
|
+ private function applyFixedScores(array $questions): array
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach ($questions as &$question) {
|
|
|
|
|
+ $type = $this->normalizeQuestionType($question['question_type'] ?? 'answer');
|
|
|
|
|
+ $question['score'] = match ($type) {
|
|
|
|
|
+ 'choice' => 5,
|
|
|
|
|
+ 'fill' => 5,
|
|
|
|
|
+ 'answer' => 10,
|
|
|
|
|
+ default => 5,
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($question);
|
|
|
|
|
+
|
|
|
|
|
+ return $questions;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 计算试卷总分并调整各题目分值,确保总分接近目标分数
|
|
* 计算试卷总分并调整各题目分值,确保总分接近目标分数
|
|
|
* 符合中国中学卷子标准:
|
|
* 符合中国中学卷子标准:
|