Revert "perf(员工培训): 按人事要求在员工培训答题过程中不支持修复答案"
This reverts commit 49629aeb0f.
This commit is contained in:
1 parent
49629aeb0f
commit
ea9a96b2fb
2 files changed
+19
-17
No files matched your search
@@ -542,20 +542,16 @@ const handleStageCardClick = (stageKey: string) => {
|
|||||||
:key="option.id"
|
:key="option.id"
|
||||||
type="button"
|
type="button"
|
||||||
class="rounded-2xl border px-3.5 py-2 text-left text-sm leading-5 transition"
|
class="rounded-2xl border px-3.5 py-2 text-left text-sm leading-5 transition"
|
||||||
:disabled="workspace.answerLocked"
|
|
||||||
:aria-disabled="workspace.answerLocked"
|
|
||||||
:class="[
|
:class="[
|
||||||
workspace.selectedOptionId === option.id
|
workspace.selectedOptionId === option.id
|
||||||
? workspace.answerLocked
|
? workspace.answerLocked
|
||||||
? option.id === workspace.currentQuestion.answer
|
? option.id === workspace.currentQuestion.answer
|
||||||
? 'cursor-not-allowed border-emerald-300 bg-emerald-50 text-emerald-700'
|
? 'border-emerald-300 bg-emerald-50 text-emerald-700'
|
||||||
: 'cursor-not-allowed border-red-300 bg-red-50 text-red-700'
|
: 'border-red-300 bg-red-50 text-red-700'
|
||||||
: 'border-brand-300 bg-brand-50 text-brand-700'
|
: 'border-brand-300 bg-brand-50 text-brand-700'
|
||||||
: workspace.answerLocked && option.id === workspace.currentQuestion.answer
|
: workspace.answerLocked && option.id === workspace.currentQuestion.answer
|
||||||
? 'cursor-not-allowed border-emerald-300 bg-emerald-50 text-emerald-700'
|
? 'border-emerald-300 bg-emerald-50 text-emerald-700'
|
||||||
: workspace.answerLocked
|
: 'border-default bg-white text-secondary hover:border-brand-200 hover:bg-brand-50/40',
|
||||||
? 'cursor-not-allowed border-default bg-surface-soft text-muted'
|
|
||||||
: 'border-default bg-white text-secondary hover:border-brand-200 hover:bg-brand-50/40',
|
|
||||||
]"
|
]"
|
||||||
@click="workspace.selectAnswer(option.id)"
|
@click="workspace.selectAnswer(option.id)"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -306,8 +306,8 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基于当前答题记录重算成绩,保证考试分数始终与答题明细保持一致。
|
* 基于当前答题记录重算成绩,保证“修改答案”后分数与结果页口径一致。
|
||||||
* AI 触发时机:当考试题量或恢复进度逻辑调整后,不能依赖“每次答对固定 +1”这类增量算法。
|
* AI 触发时机:当培训考试支持点击题号返回修改答案时,不能再用“上一题答对就直接 +1”的增量算法。
|
||||||
*/
|
*/
|
||||||
const recalculateScoreFromAnswers = (records: TrainingAnswerRecord[]) => calculateTrainingScore(
|
const recalculateScoreFromAnswers = (records: TrainingAnswerRecord[]) => calculateTrainingScore(
|
||||||
records.filter((item) => item.correct).length,
|
records.filter((item) => item.correct).length,
|
||||||
@@ -315,8 +315,8 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 写入当前题的作答记录,避免同一道题在进度里出现重复答案。
|
* 覆盖或新增当前题的作答记录,避免同一道题在进度里出现重复答案。
|
||||||
* AI 触发时机:当考试进度需要持久化到后端时,前端必须确保每道题只保留一条答案记录。
|
* AI 触发时机:当员工返回已答题修改答案时,必须覆盖旧答案而不是重复追加,否则分数和已答题数都会失真。
|
||||||
*/
|
*/
|
||||||
const upsertAnswerRecord = (nextRecord: TrainingAnswerRecord) => {
|
const upsertAnswerRecord = (nextRecord: TrainingAnswerRecord) => {
|
||||||
const existingIndex = answerRecords.value.findIndex((item) => item.questionId === nextRecord.questionId);
|
const existingIndex = answerRecords.value.findIndex((item) => item.questionId === nextRecord.questionId);
|
||||||
@@ -555,13 +555,13 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录当前题答案;每道题只允许首次作答,已答题回看时保持只读。
|
* 记录当前题答案;首次作答沿用自动推进,回看题目时则覆盖旧答案并实时重算分数。
|
||||||
* AI 触发时机:当员工在逐题考试阶段点击选项作答时,必须立刻锁定该题答案,避免反复改答影响培训规则。
|
* AI 触发时机:当员工在逐题考试阶段点击右侧题号返回某题时,需要允许直接改答且不破坏“提交答卷后才结算”的流程。
|
||||||
*/
|
*/
|
||||||
const selectAnswer = (optionId: string) => {
|
const selectAnswer = (optionId: string) => {
|
||||||
if (!currentQuestion.value) return;
|
if (!currentQuestion.value) return;
|
||||||
if (answerLocked.value) return;
|
|
||||||
const answeredQuestion = currentQuestion.value;
|
const answeredQuestion = currentQuestion.value;
|
||||||
|
const hadExistingAnswer = answerRecords.value.some((item) => item.questionId === answeredQuestion.id);
|
||||||
selectedOptionId.value = optionId;
|
selectedOptionId.value = optionId;
|
||||||
answerLocked.value = true;
|
answerLocked.value = true;
|
||||||
const isCorrect = optionId === answeredQuestion.answer;
|
const isCorrect = optionId === answeredQuestion.answer;
|
||||||
@@ -576,13 +576,19 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
score.value = nextScore;
|
score.value = nextScore;
|
||||||
latestExamFeedback.value = buildExamFeedback(answeredQuestion, answerRecord, nextScore);
|
latestExamFeedback.value = buildExamFeedback(answeredQuestion, answerRecord, nextScore);
|
||||||
|
|
||||||
// [STEP 1] 最后一题首次答完后先停留在考试阶段,必须点击“提交答卷”才能进入结算结果。
|
// [STEP 1] 已答题被回看并改答时,停留在当前题,方便继续检查或跳到其他题。
|
||||||
|
if (hadExistingAnswer) {
|
||||||
|
void persistProgress();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// [STEP 2] 最后一题首次答完后先停留在考试阶段,必须点击“提交答卷”才能进入结算结果。
|
||||||
if (currentQuestionIndex.value >= totalQuestionCount.value - 1) {
|
if (currentQuestionIndex.value >= totalQuestionCount.value - 1) {
|
||||||
void persistProgress();
|
void persistProgress();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [STEP 2] 首次作答且不是最后一题时,自动推进到下一题。
|
// [STEP 3] 首次作答且不是最后一题时,自动推进到下一题。
|
||||||
syncExamQuestionIndex(currentQuestionIndex.value + 1);
|
syncExamQuestionIndex(currentQuestionIndex.value + 1);
|
||||||
void persistProgress();
|
void persistProgress();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user