diff --git a/frontend/src/features/chat/components/TrainingWorkspacePanel.vue b/frontend/src/features/chat/components/TrainingWorkspacePanel.vue index 54edefa2..d55fde9d 100644 --- a/frontend/src/features/chat/components/TrainingWorkspacePanel.vue +++ b/frontend/src/features/chat/components/TrainingWorkspacePanel.vue @@ -341,16 +341,10 @@ const handleStageCardClick = (stageKey: string) => {
{{ compactSummary }}
-
- - +
+ {{ $t('chat.training.hr.filters.keywordLabel') }}: {{ workspace.hrKeyword || $t('chat.training.hr.filters.noLimit') }} + · {{ $t('chat.training.hr.filters.departmentLabel') }}: + {{ workspace.hrDepartmentFilter === 'all' ? $t('chat.training.hr.filters.allDepartments') : workspace.hrDepartmentFilter }}
{ ? 'border-emerald-300 bg-emerald-50 text-emerald-700' : 'border-default bg-white text-secondary hover:border-brand-200 hover:bg-brand-50/40', ]" - :disabled="workspace.answerLocked" @click="workspace.selectAnswer(option.id)" >
diff --git a/frontend/src/features/chat/components/messages/TrainingExamQuestionMessage.vue b/frontend/src/features/chat/components/messages/TrainingExamQuestionMessage.vue index cba324c9..fe93abbc 100644 --- a/frontend/src/features/chat/components/messages/TrainingExamQuestionMessage.vue +++ b/frontend/src/features/chat/components/messages/TrainingExamQuestionMessage.vue @@ -138,7 +138,7 @@ const emit = defineEmits<{ ? 'border-emerald-200 bg-emerald-50/50 text-emerald-600' : 'border-slate-200 bg-white text-slate-600 hover:border-brand-200 hover:bg-brand-50/30 hover:text-brand-700', ]" - :disabled="answerLocked || isThinking" + :disabled="isThinking" @click="emit('select', option.id)" > {{ option.label }} diff --git a/frontend/src/features/chat/composables/useTrainingWorkspace.ts b/frontend/src/features/chat/composables/useTrainingWorkspace.ts index 76c7b65d..16a4a158 100644 --- a/frontend/src/features/chat/composables/useTrainingWorkspace.ts +++ b/frontend/src/features/chat/composables/useTrainingWorkspace.ts @@ -305,6 +305,29 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) { ].join('\n'); }; + /** + * 基于当前答题记录重算成绩,保证“修改答案”后分数与结果页口径一致。 + * AI 触发时机:当培训考试支持点击题号返回修改答案时,不能再用“上一题答对就直接 +1”的增量算法。 + */ + const recalculateScoreFromAnswers = (records: TrainingAnswerRecord[]) => calculateTrainingScore( + records.filter((item) => item.correct).length, + totalQuestionCount.value, + ); + + /** + * 覆盖或新增当前题的作答记录,避免同一道题在进度里出现重复答案。 + * AI 触发时机:当员工返回已答题修改答案时,必须覆盖旧答案而不是重复追加,否则分数和已答题数都会失真。 + */ + const upsertAnswerRecord = (nextRecord: TrainingAnswerRecord) => { + const existingIndex = answerRecords.value.findIndex((item) => item.questionId === nextRecord.questionId); + if (existingIndex >= 0) { + answerRecords.value.splice(existingIndex, 1, nextRecord); + return true; + } + answerRecords.value.push(nextRecord); + return false; + }; + const syncAnswerStateForCurrentQuestion = () => { const questionId = currentQuestion.value?.id; const currentAnswer = questionId @@ -531,31 +554,41 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) { void persistProgress(); }; + /** + * 记录当前题答案;首次作答沿用自动推进,回看题目时则覆盖旧答案并实时重算分数。 + * AI 触发时机:当员工在逐题考试阶段点击右侧题号返回某题时,需要允许直接改答且不破坏“提交答卷后才结算”的流程。 + */ const selectAnswer = (optionId: string) => { - if (answerLocked.value || !currentQuestion.value) return; + if (!currentQuestion.value) return; const answeredQuestion = currentQuestion.value; + const hadExistingAnswer = answerRecords.value.some((item) => item.questionId === answeredQuestion.id); selectedOptionId.value = optionId; answerLocked.value = true; const isCorrect = optionId === answeredQuestion.answer; currentFeedbackCorrect.value = isCorrect; - const nextCorrectAnswerCount = correctCount.value + (isCorrect ? 1 : 0); - const nextScore = calculateTrainingScore(nextCorrectAnswerCount, totalQuestionCount.value); - score.value = nextScore; const answerRecord: TrainingAnswerRecord = { questionId: answeredQuestion.id, selectedOptionId: optionId, correct: isCorrect, }; - answerRecords.value.push(answerRecord); + upsertAnswerRecord(answerRecord); + const nextScore = recalculateScoreFromAnswers(answerRecords.value); + score.value = nextScore; latestExamFeedback.value = buildExamFeedback(answeredQuestion, answerRecord, nextScore); - // [STEP 1] 最后一题答完后先停留在考试阶段,必须点击“提交答卷”才能进入结算结果。 + // [STEP 1] 已答题被回看并改答时,停留在当前题,方便继续检查或跳到其他题。 + if (hadExistingAnswer) { + void persistProgress(); + return; + } + + // [STEP 2] 最后一题首次答完后先停留在考试阶段,必须点击“提交答卷”才能进入结算结果。 if (currentQuestionIndex.value >= totalQuestionCount.value - 1) { void persistProgress(); return; } - // [STEP 2] 非最后一题则在聊天流里自动反馈上一题,并紧接着展示下一题。 + // [STEP 3] 首次作答且不是最后一题时,自动推进到下一题。 syncExamQuestionIndex(currentQuestionIndex.value + 1); void persistProgress(); }; diff --git a/frontend/src/locales/en/chat.json b/frontend/src/locales/en/chat.json index cd8e5b48..2b3e4c72 100644 --- a/frontend/src/locales/en/chat.json +++ b/frontend/src/locales/en/chat.json @@ -552,7 +552,7 @@ }, "examQuestionCard": { "title": "Exam Questions", - "hint": "Shows all question numbers. They become clickable only during the step-by-step exam stage." + "hint": "Shows all question numbers. They become clickable only during the step-by-step exam stage, and answered questions can be revisited and changed." }, "rules": { "title": "Exam rules", diff --git a/frontend/src/locales/th/chat.json b/frontend/src/locales/th/chat.json index 39aabaf8..0b45f734 100644 --- a/frontend/src/locales/th/chat.json +++ b/frontend/src/locales/th/chat.json @@ -552,7 +552,7 @@ }, "examQuestionCard": { "title": "ข้อสอบ", - "hint": "แสดงหมายเลขข้อทั้งหมด และจะกดได้เฉพาะในขั้นตอนสอบทีละข้อเท่านั้น" + "hint": "แสดงหมายเลขข้อทั้งหมด และจะกดได้เฉพาะในขั้นตอนสอบทีละข้อเท่านั้น พร้อมรองรับการย้อนกลับไปแก้คำตอบ" }, "rules": { "title": "กติกาการสอบ", diff --git a/frontend/src/locales/zh-CN/chat.json b/frontend/src/locales/zh-CN/chat.json index 821b5a1f..dc5ee16c 100644 --- a/frontend/src/locales/zh-CN/chat.json +++ b/frontend/src/locales/zh-CN/chat.json @@ -552,7 +552,7 @@ }, "examQuestionCard": { "title": "考试题目", - "hint": "展示全部题目序号;仅在“逐题考试”阶段可点击切换。" + "hint": "展示全部题目序号;仅在“逐题考试”阶段可点击切换,并支持返回修改答案。" }, "rules": { "title": "考试规则", diff --git a/frontend/src/locales/zh-TW/chat.json b/frontend/src/locales/zh-TW/chat.json index 48f62e42..3d731db6 100644 --- a/frontend/src/locales/zh-TW/chat.json +++ b/frontend/src/locales/zh-TW/chat.json @@ -552,7 +552,7 @@ }, "examQuestionCard": { "title": "考試題目", - "hint": "顯示全部題目序號;僅在「逐題考試」階段可點擊切換。" + "hint": "展示全部題目序號;僅在“逐題考試”階段可點擊切換,並支援返回修改答案。" }, "rules": { "title": "考試規則",