+ {{ t('admin.agent.training.emptyQuestionBank') }}
+
+
+ {
if (workspace.stage === 'summary') return t('chat.training.summary.title');
if (workspace.stage === 'exam') {
return t('chat.training.exam.questionCounter', {
- current: workspace.answeredCount + 1,
+ current: workspace.currentQuestionNumber,
total: workspace.totalQuestionCount,
});
}
@@ -165,7 +165,15 @@ const examQuestionItems = computed(() => Array.from({ length: workspace.totalQue
const canNavigateExamQuestions = computed(() => workspace.stage === 'exam');
const jumpToExamQuestion = (index: number) => {
if (!canNavigateExamQuestions.value) return;
- workspace.currentQuestionIndex = index;
+ workspace.syncExamQuestionIndex(index);
+};
+const canSwitchToStage = (stageKey: string) => {
+ if (stageKey !== 'result') return true;
+ return workspace.canEnterResultStage;
+};
+const handleStageCardClick = (stageKey: string) => {
+ if (!canSwitchToStage(stageKey)) return;
+ workspace.stage = stageKey as typeof workspace.stage;
};
@@ -387,8 +395,11 @@ const jumpToExamQuestion = (index: number) => {
v-for="(item, index) in stageItems"
:key="item.key"
class="rounded-xl border px-3 py-2.5 transition cursor-pointer hover:border-brand-300"
- :class="stageStep >= index + 1 ? 'border-brand-200 bg-brand-50/70' : 'border-default bg-surface-soft/70'"
- @click="workspace.stage = item.key as any"
+ :class="[
+ stageStep >= index + 1 ? 'border-brand-200 bg-brand-50/70' : 'border-default bg-surface-soft/70',
+ canSwitchToStage(String(item.key)) ? 'cursor-pointer hover:border-brand-300' : 'cursor-not-allowed opacity-60',
+ ]"
+ @click="handleStageCardClick(String(item.key))"
>
{
{{ $t('chat.training.exam.title') }}
- {{ $t('chat.training.exam.questionCounter', { current: workspace.answeredCount + 1, total: workspace.totalQuestionCount }) }}
+ {{ $t('chat.training.exam.questionCounter', { current: workspace.currentQuestionNumber, total: workspace.totalQuestionCount }) }}
@@ -564,12 +575,12 @@ const jumpToExamQuestion = (index: number) => {
diff --git a/frontend/src/features/chat/composables/useTrainingWorkspace.ts b/frontend/src/features/chat/composables/useTrainingWorkspace.ts
index a1900eed..76c7b65d 100644
--- a/frontend/src/features/chat/composables/useTrainingWorkspace.ts
+++ b/frontend/src/features/chat/composables/useTrainingWorkspace.ts
@@ -199,10 +199,20 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
const currentQuestion = computed(() => questionBank.value[currentQuestionIndex.value] || null);
const totalQuestionCount = computed(() => questionBank.value.length);
+ const currentQuestionNumber = computed(() => {
+ if (totalQuestionCount.value <= 0) return 0;
+ return Math.min(currentQuestionIndex.value + 1, totalQuestionCount.value);
+ });
const answeredCount = computed(() => answerRecords.value.length);
const correctCount = computed(() => answerRecords.value.filter((item) => item.correct).length);
const wrongCount = computed(() => answerRecords.value.filter((item) => !item.correct).length);
const isPassed = computed(() => score.value >= passScore.value);
+ const examReadyToSubmit = computed(() => (
+ stage.value === 'exam'
+ && totalQuestionCount.value > 0
+ && answeredCount.value >= totalQuestionCount.value
+ ));
+ const canEnterResultStage = computed(() => stage.value === 'result');
const learnerProgressPercent = computed(() => {
if (stage.value === 'video') return 25;
@@ -305,6 +315,21 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
currentFeedbackCorrect.value = Boolean(currentAnswer?.correct);
};
+ /**
+ * 切换考试题目时,同步左侧题干、已答状态和反馈展示。
+ * AI 触发时机:当员工点击右侧题号导航或后端恢复考试进度时,必须保证“当前题序号、选中项、答题对错反馈”完全一致。
+ */
+ const syncExamQuestionIndex = (nextIndex: number) => {
+ if (totalQuestionCount.value <= 0) {
+ currentQuestionIndex.value = 0;
+ syncAnswerStateForCurrentQuestion();
+ return;
+ }
+ const normalizedIndex = Math.min(Math.max(nextIndex, 0), totalQuestionCount.value - 1);
+ currentQuestionIndex.value = normalizedIndex;
+ syncAnswerStateForCurrentQuestion();
+ };
+
const applyProgressRecord = (record: TrainingProgressRecord | null) => {
if (!record) {
stage.value = 'video';
@@ -314,7 +339,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
return;
}
stage.value = record.stage;
- currentQuestionIndex.value = record.currentQuestionIndex;
+ syncExamQuestionIndex(record.currentQuestionIndex);
score.value = Number(record.score || 0);
attemptCount.value = Number(record.attempts || 0);
answerRecords.value = Array.isArray(record.answerDetails) ? record.answerDetails : [];
@@ -510,6 +535,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
if (answerLocked.value || !currentQuestion.value) return;
const answeredQuestion = currentQuestion.value;
selectedOptionId.value = optionId;
+ answerLocked.value = true;
const isCorrect = optionId === answeredQuestion.answer;
currentFeedbackCorrect.value = isCorrect;
const nextCorrectAnswerCount = correctCount.value + (isCorrect ? 1 : 0);
@@ -523,25 +549,14 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
answerRecords.value.push(answerRecord);
latestExamFeedback.value = buildExamFeedback(answeredQuestion, answerRecord, nextScore);
- // [STEP 1] 最后一题直接进入结算,对齐文档里的“答完即公布最终成绩”。
+ // [STEP 1] 最后一题答完后先停留在考试阶段,必须点击“提交答卷”才能进入结算结果。
if (currentQuestionIndex.value >= totalQuestionCount.value - 1) {
- stage.value = 'result';
- completionDate.value = formatDate(new Date());
- latestSettledResult.value = {
- score: nextScore,
- correctCount: answerRecords.value.filter((item) => item.correct).length,
- wrongCount: answerRecords.value.filter((item) => !item.correct).length,
- isPassed: nextScore >= passScore.value,
- };
void persistProgress();
return;
}
// [STEP 2] 非最后一题则在聊天流里自动反馈上一题,并紧接着展示下一题。
- currentQuestionIndex.value += 1;
- selectedOptionId.value = '';
- answerLocked.value = false;
- currentFeedbackCorrect.value = false;
+ syncExamQuestionIndex(currentQuestionIndex.value + 1);
void persistProgress();
};
@@ -552,19 +567,30 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
const moveToNextQuestion = () => {
if (!answerLocked.value) return;
if (currentQuestionIndex.value >= totalQuestionCount.value - 1) {
- stage.value = 'result';
- completionDate.value = formatDate(new Date());
- void persistProgress();
return;
}
- currentQuestionIndex.value += 1;
- selectedOptionId.value = '';
- answerLocked.value = false;
- currentFeedbackCorrect.value = false;
+ syncExamQuestionIndex(currentQuestionIndex.value + 1);
latestExamFeedback.value = null;
void persistProgress();
};
+ /**
+ * 统一提交整份答卷并进入结算结果。
+ * AI 触发时机:当员工已完成全部题目但尚未结算时,必须显式点击“提交答卷”后才允许进入第 4 阶段。
+ */
+ const submitExam = () => {
+ if (!examReadyToSubmit.value) return;
+ stage.value = 'result';
+ completionDate.value = formatDate(new Date());
+ latestSettledResult.value = {
+ score: score.value,
+ correctCount: answerRecords.value.filter((item) => item.correct).length,
+ wrongCount: answerRecords.value.filter((item) => !item.correct).length,
+ isPassed: score.value >= passScore.value,
+ };
+ void persistProgress();
+ };
+
const restartExam = () => {
stage.value = 'video';
resetExamState();
@@ -645,6 +671,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
activeView,
stage,
currentQuestionIndex,
+ currentQuestionNumber,
currentQuestion,
totalQuestionCount,
passScore,
@@ -654,6 +681,8 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
selectedOptionId,
answerLocked,
currentFeedbackCorrect,
+ examReadyToSubmit,
+ canEnterResultStage,
latestExamFeedback,
latestSettledResult,
answerRecords,
@@ -681,7 +710,9 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
markVideoCompleted,
startExam,
selectAnswer,
+ syncExamQuestionIndex,
moveToNextQuestion,
+ submitExam,
restartExam,
exportRecords,
showVideoModal,
diff --git a/frontend/src/locales/en/chat.json b/frontend/src/locales/en/chat.json
index 16a40fe8..cd8e5b48 100644
--- a/frontend/src/locales/en/chat.json
+++ b/frontend/src/locales/en/chat.json
@@ -526,6 +526,7 @@
"selectedAnswer": "Your answer: {answer}",
"correctAnswer": "Correct answer: {answer}",
"nextQuestion": "Next Question",
+ "submitPaper": "Submit Paper",
"finishExam": "Finish Exam"
},
"result": {
diff --git a/frontend/src/locales/th/chat.json b/frontend/src/locales/th/chat.json
index 826bdf0b..39aabaf8 100644
--- a/frontend/src/locales/th/chat.json
+++ b/frontend/src/locales/th/chat.json
@@ -526,6 +526,7 @@
"selectedAnswer": "คำตอบของคุณ: {answer}",
"correctAnswer": "คำตอบที่ถูกต้อง: {answer}",
"nextQuestion": "ข้อถัดไป",
+ "submitPaper": "ส่งข้อสอบ",
"finishExam": "จบการสอบ"
},
"result": {
diff --git a/frontend/src/locales/zh-CN/chat.json b/frontend/src/locales/zh-CN/chat.json
index aa56cfa8..821b5a1f 100644
--- a/frontend/src/locales/zh-CN/chat.json
+++ b/frontend/src/locales/zh-CN/chat.json
@@ -526,6 +526,7 @@
"selectedAnswer": "你的答案:{answer}",
"correctAnswer": "正确答案:{answer}",
"nextQuestion": "下一题",
+ "submitPaper": "提交答卷",
"finishExam": "完成考试"
},
"result": {
diff --git a/frontend/src/locales/zh-TW/chat.json b/frontend/src/locales/zh-TW/chat.json
index ce7eab0c..48f62e42 100644
--- a/frontend/src/locales/zh-TW/chat.json
+++ b/frontend/src/locales/zh-TW/chat.json
@@ -526,6 +526,7 @@
"selectedAnswer": "你的答案:{answer}",
"correctAnswer": "正確答案:{answer}",
"nextQuestion": "下一題",
+ "submitPaper": "提交答卷",
"finishExam": "完成考試"
},
"result": {