From 24ffc028e22cd116af9069e5c72a091fdc3bfb41 Mon Sep 17 00:00:00 2001 From: Developer Date: Thu, 21 May 2026 12:42:52 +0800 Subject: [PATCH] fix: shuffle choice options per session + clean followup hints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Options shuffled with correctAnswer remapped at session creation - Followup hints strip conditional prefix (如果只说了XX,追问:) --- server/src/assessment/assessment.service.ts | 41 +++++++++++++------ .../src/assessment/graph/nodes/grader.node.ts | 3 +- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/server/src/assessment/assessment.service.ts b/server/src/assessment/assessment.service.ts index d23beed..eb4f9f2 100644 --- a/server/src/assessment/assessment.service.ts +++ b/server/src/assessment/assessment.service.ts @@ -505,18 +505,35 @@ private async getModel(tenantId: string): Promise { targetCount, ); - questionsFromBank = selectedItems.map(item => ({ - id: item.id, - questionText: item.questionText, - questionType: item.questionType, - options: item.options, - correctAnswer: item.correctAnswer, - judgment: item.judgment, - keyPoints: item.keyPoints, - difficulty: item.difficulty, - dimension: item.dimension, - basis: item.basis, - })); + questionsFromBank = selectedItems.map(item => { + let options = item.options; + let correctAnswer = item.correctAnswer; + if (item.questionType === 'MULTIPLE_CHOICE' && options && options.length > 0 && correctAnswer) { + const labels = ['A', 'B', 'C', 'D']; + const optTexts = options.map((o: string) => o.replace(/^[A-D][.)、]\s*/, '')); + const correctIdx = correctAnswer.charCodeAt(0) - 65; + const correctText = correctIdx >= 0 && correctIdx < optTexts.length ? optTexts[correctIdx] : null; + const indices = optTexts.map((_: any, i: number) => i); + for (let i = indices.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [indices[i], indices[j]] = [indices[j], indices[i]]; + } + options = indices.map((origIdx: number, newPos: number) => `${labels[newPos]}${optTexts[origIdx]}`); + correctAnswer = correctText ? labels[indices.indexOf(correctIdx)] : correctAnswer; + } + return { + id: item.id, + questionText: item.questionText, + questionType: item.questionType, + options, + correctAnswer, + judgment: item.judgment, + keyPoints: item.keyPoints, + difficulty: item.difficulty, + dimension: item.dimension, + basis: item.basis, + }; + }); const answerKey: Record = {}; selectedItems.forEach(item => { diff --git a/server/src/assessment/graph/nodes/grader.node.ts b/server/src/assessment/graph/nodes/grader.node.ts index dc7b032..bea5eac 100644 --- a/server/src/assessment/graph/nodes/grader.node.ts +++ b/server/src/assessment/graph/nodes/grader.node.ts @@ -254,7 +254,8 @@ Format your response as JSON: let followupHintMsg: AIMessage | null = null; if (shouldFollowUp && followupHints.length > 0) { - const hint = followupHints[Math.min(currentFollowUpCount, followupHints.length - 1)]; + let hint = followupHints[Math.min(currentFollowUpCount, followupHints.length - 1)]; + hint = hint.replace(/^如果[^,,]*[,,]\s*追问[::]\s*/i, '').replace(/^如果[^。]*[。]\s*/i, ''); const hintLabel = isZh ? `让我帮你完善一下:${hint}` : isJa