|
@@ -950,6 +950,10 @@ class ExamTypeStrategy
|
|
|
Log::info('ExamTypeStrategy: 构建知识点组卷参数', $params);
|
|
Log::info('ExamTypeStrategy: 构建知识点组卷参数', $params);
|
|
|
|
|
|
|
|
$kpCodeList = $params['kp_code_list'] ?? [];
|
|
$kpCodeList = $params['kp_code_list'] ?? [];
|
|
|
|
|
+ if (!is_array($kpCodeList)) {
|
|
|
|
|
+ $kpCodeList = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ $kpCodeList = array_values(array_unique(array_filter($kpCodeList)));
|
|
|
$studentId = $params['student_id'] ?? null;
|
|
$studentId = $params['student_id'] ?? null;
|
|
|
$totalQuestions = $params['total_questions'] ?? 20;
|
|
$totalQuestions = $params['total_questions'] ?? 20;
|
|
|
|
|
|
|
@@ -964,6 +968,41 @@ class ExamTypeStrategy
|
|
|
'total_questions' => $totalQuestions
|
|
'total_questions' => $totalQuestions
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
|
|
+ // assemble_type=2 走知识点扩展策略(复用 QuestionExpansionService)。
|
|
|
|
|
+ // 只在基础题池不足时,才会触发子知识点补充(由扩展策略内部控制)。
|
|
|
|
|
+ $assembleType = (int) ($params['assemble_type'] ?? 4);
|
|
|
|
|
+ $priorityQuestionIds = [];
|
|
|
|
|
+ $basePoolCount = 0;
|
|
|
|
|
+ $finalPoolCount = 0;
|
|
|
|
|
+ $childAddedCount = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if ($assembleType === 2) {
|
|
|
|
|
+ $expansionStrategy = $this->questionExpansionService->expandQuestionsByKnowledgePoints(
|
|
|
|
|
+ $params,
|
|
|
|
|
+ $studentId ? (string) $studentId : null,
|
|
|
|
|
+ $kpCodeList,
|
|
|
|
|
+ [],
|
|
|
|
|
+ (int) $totalQuestions
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ $priorityQuestionIds = array_values(array_unique(array_filter($expansionStrategy['mistake_question_ids'] ?? [])));
|
|
|
|
|
+ $basePoolCount = (int) (
|
|
|
|
|
+ ($expansionStrategy['expansion_details']['step1_direct_kp']['added_count'] ?? 0)
|
|
|
|
|
+ + ($expansionStrategy['expansion_details']['step2_same_kp']['added_count'] ?? 0)
|
|
|
|
|
+ );
|
|
|
|
|
+ $finalPoolCount = count($priorityQuestionIds);
|
|
|
|
|
+ $childAddedCount = max(0, $finalPoolCount - $basePoolCount);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 三项汇总日志放在外围,便于统一观察策略触发情况。
|
|
|
|
|
+ Log::info('ExamTypeStrategy: 知识点组卷题池评估', [
|
|
|
|
|
+ 'original_kp_count' => count($kpCodeList),
|
|
|
|
|
+ 'child_kp_added_count' => $childAddedCount,
|
|
|
|
|
+ 'pool_count_after_expand' => $finalPoolCount,
|
|
|
|
|
+ 'total_questions' => (int) $totalQuestions,
|
|
|
|
|
+ 'assemble_type' => $assembleType,
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
// 如果有学生ID,获取已做过的题目ID列表(用于排除)
|
|
// 如果有学生ID,获取已做过的题目ID列表(用于排除)
|
|
|
$answeredQuestionIds = [];
|
|
$answeredQuestionIds = [];
|
|
|
if ($studentId) {
|
|
if ($studentId) {
|
|
@@ -977,6 +1016,7 @@ class ExamTypeStrategy
|
|
|
// 组装增强参数
|
|
// 组装增强参数
|
|
|
$enhanced = array_merge($params, [
|
|
$enhanced = array_merge($params, [
|
|
|
'kp_codes' => $kpCodeList,
|
|
'kp_codes' => $kpCodeList,
|
|
|
|
|
+ 'mistake_question_ids' => $basePoolCount < (int) $totalQuestions ? $priorityQuestionIds : [],
|
|
|
'exclude_question_ids' => $answeredQuestionIds,
|
|
'exclude_question_ids' => $answeredQuestionIds,
|
|
|
'paper_name' => $params['paper_name'] ?? ('知识点组卷_' . now()->format('Ymd_His')),
|
|
'paper_name' => $params['paper_name'] ?? ('知识点组卷_' . now()->format('Ymd_His')),
|
|
|
// 知识点组卷:442配比(配合固定分值5/5/10,各题型贡献均等)
|
|
// 知识点组卷:442配比(配合固定分值5/5/10,各题型贡献均等)
|