feat(training-workspace): 培训考试增加提交答卷后再进入结算结果
feat(training-workspace): 完善员工培训工作区考试流转与配置交互
This commit is contained in:
1 parent
5bef77f86c
commit
8bd66baa21
8 files changed
+246
-197
No files matched your search
@@ -38,6 +38,7 @@ def build_dify_inputs_for_context(ctx: ChatStreamContext) -> dict[str, Any]:
|
|||||||
session_id=str(getattr(ctx.session, 'session_id', '') or ''),
|
session_id=str(getattr(ctx.session, 'session_id', '') or ''),
|
||||||
request_id=ctx.request_id,
|
request_id=ctx.request_id,
|
||||||
trigger_source='frontend_chat',
|
trigger_source='frontend_chat',
|
||||||
|
user_role=str(getattr(ctx.user, 'role', '') or '').strip() or None,
|
||||||
adapter_hints=ctx.adapter_hints,
|
adapter_hints=ctx.adapter_hints,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -531,200 +531,202 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
|||||||
{{ form.training_workspace_enabled ? t('admin.agent.training.enableHint') : t('admin.agent.training.disabledHint') }}
|
{{ form.training_workspace_enabled ? t('admin.agent.training.enableHint') : t('admin.agent.training.disabledHint') }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="mt-4 grid grid-cols-1 gap-4 md:grid-cols-3">
|
<template v-if="form.training_workspace_enabled">
|
||||||
<div class="space-y-2">
|
<div class="mt-4 grid grid-cols-1 gap-4 md:grid-cols-3">
|
||||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.passScore') }}</label>
|
<div class="space-y-2">
|
||||||
<input
|
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.passScore') }}</label>
|
||||||
v-model.number="form.training_pass_score"
|
<input
|
||||||
type="number"
|
v-model.number="form.training_pass_score"
|
||||||
min="0"
|
type="number"
|
||||||
max="100"
|
min="0"
|
||||||
step="1"
|
max="100"
|
||||||
class="w-full input-field text-sm"
|
step="1"
|
||||||
/>
|
class="w-full input-field text-sm"
|
||||||
<p class="text-xs leading-5 text-muted">{{ t('admin.agent.training.passScoreHint') }}</p>
|
/>
|
||||||
</div>
|
<p class="text-xs leading-5 text-muted">{{ t('admin.agent.training.passScoreHint') }}</p>
|
||||||
<div class="space-y-2 md:col-span-2">
|
|
||||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.summaryPoints') }}</label>
|
|
||||||
<textarea
|
|
||||||
v-model="form.training_summary_points_text"
|
|
||||||
rows="5"
|
|
||||||
class="w-full input-field text-sm"
|
|
||||||
:placeholder="t('admin.agent.training.summaryPointsPlaceholder')"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="space-y-2 md:col-span-3">
|
|
||||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.summaryChecklist') }}</label>
|
|
||||||
<textarea
|
|
||||||
v-model="form.training_summary_checklist_text"
|
|
||||||
rows="4"
|
|
||||||
class="w-full input-field text-sm"
|
|
||||||
:placeholder="t('admin.agent.training.summaryChecklistPlaceholder')"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-5 space-y-3">
|
|
||||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
||||||
<div>
|
|
||||||
<div class="text-sm font-semibold text-primary">{{ t('admin.agent.training.questionBank') }}</div>
|
|
||||||
<p class="mt-1 text-xs leading-5 text-muted">{{ t('admin.agent.training.questionHint') }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
<div class="space-y-2 md:col-span-2">
|
||||||
<button
|
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.summaryPoints') }}</label>
|
||||||
type="button"
|
<textarea
|
||||||
class="inline-flex items-center gap-1 rounded-lg border border-default bg-white px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60"
|
v-model="form.training_summary_points_text"
|
||||||
:disabled="!isEditing || trainingExamPdfGuides.length === 0 || isImportingTrainingPdf"
|
rows="5"
|
||||||
@click="emit('importTrainingPdf', trainingExamPdfGuides[0]?.id || null)"
|
class="w-full input-field text-sm"
|
||||||
>
|
:placeholder="t('admin.agent.training.summaryPointsPlaceholder')"
|
||||||
<FileDown class="h-4 w-4" />
|
/>
|
||||||
{{ isImportingTrainingPdf ? t('admin.agent.training.importingPdf') : t('admin.agent.training.importFromPdf') }}
|
</div>
|
||||||
</button>
|
<div class="space-y-2 md:col-span-3">
|
||||||
<button
|
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.summaryChecklist') }}</label>
|
||||||
type="button"
|
<textarea
|
||||||
class="inline-flex items-center gap-1 rounded-lg border border-default bg-white px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
v-model="form.training_summary_checklist_text"
|
||||||
@click="emit('addTrainingQuestion')"
|
rows="4"
|
||||||
>
|
class="w-full input-field text-sm"
|
||||||
<Plus class="h-4 w-4" />
|
:placeholder="t('admin.agent.training.summaryChecklistPlaceholder')"
|
||||||
{{ t('admin.agent.training.addQuestion') }}
|
/>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="text-xs leading-5 text-muted">
|
<div class="mt-5 space-y-3">
|
||||||
{{
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
!isEditing
|
<div>
|
||||||
? t('admin.agent.training.importPdfCreateFirst')
|
<div class="text-sm font-semibold text-primary">{{ t('admin.agent.training.questionBank') }}</div>
|
||||||
: trainingExamPdfGuides.length > 0
|
<p class="mt-1 text-xs leading-5 text-muted">{{ t('admin.agent.training.questionHint') }}</p>
|
||||||
? t('admin.agent.training.importPdfHint', { fileName: trainingExamPdfGuides[0]?.file_name || '--' })
|
</div>
|
||||||
: t('admin.agent.training.importPdfMissing')
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
}}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div v-if="form.training_question_bank.length === 0" class="rounded-xl border border-dashed border-default bg-white px-4 py-5 text-sm text-muted">
|
|
||||||
{{ t('admin.agent.training.emptyQuestionBank') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-else class="space-y-4">
|
|
||||||
<div
|
|
||||||
v-for="(question, questionIndex) in form.training_question_bank"
|
|
||||||
:key="questionIndex"
|
|
||||||
class="rounded-2xl border border-default bg-white p-4"
|
|
||||||
>
|
|
||||||
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
|
||||||
<div class="text-sm font-semibold text-primary">
|
|
||||||
{{ t('admin.agent.training.questionCardTitle', { index: questionIndex + 1 }) }}
|
|
||||||
</div>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="inline-flex items-center gap-1 rounded-lg border border-red-200 bg-red-50 px-3 py-1.5 text-xs font-medium text-red-600 transition-colors hover:bg-red-100"
|
class="inline-flex items-center gap-1 rounded-lg border border-default bg-white px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60"
|
||||||
@click="emit('removeTrainingQuestion', questionIndex)"
|
:disabled="!isEditing || trainingExamPdfGuides.length === 0 || isImportingTrainingPdf"
|
||||||
|
@click="emit('importTrainingPdf', trainingExamPdfGuides[0]?.id || null)"
|
||||||
>
|
>
|
||||||
<Trash2 class="h-4 w-4" />
|
<FileDown class="h-4 w-4" />
|
||||||
{{ t('admin.agent.training.removeQuestion') }}
|
{{ isImportingTrainingPdf ? t('admin.agent.training.importingPdf') : t('admin.agent.training.importFromPdf') }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="inline-flex items-center gap-1 rounded-lg border border-default bg-white px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||||
|
@click="emit('addTrainingQuestion')"
|
||||||
|
>
|
||||||
|
<Plus class="h-4 w-4" />
|
||||||
|
{{ t('admin.agent.training.addQuestion') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-3">
|
<p class="text-xs leading-5 text-muted">
|
||||||
<div class="space-y-2">
|
{{
|
||||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.questionId') }}</label>
|
!isEditing
|
||||||
<input
|
? t('admin.agent.training.importPdfCreateFirst')
|
||||||
v-model="question.id"
|
: trainingExamPdfGuides.length > 0
|
||||||
type="text"
|
? t('admin.agent.training.importPdfHint', { fileName: trainingExamPdfGuides[0]?.file_name || '--' })
|
||||||
class="w-full input-field text-sm"
|
: t('admin.agent.training.importPdfMissing')
|
||||||
:placeholder="t('admin.agent.training.questionIdPlaceholder')"
|
}}
|
||||||
/>
|
</p>
|
||||||
</div>
|
|
||||||
<div class="space-y-2">
|
<div v-if="form.training_question_bank.length === 0" class="rounded-xl border border-dashed border-default bg-white px-4 py-5 text-sm text-muted">
|
||||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.questionType') }}</label>
|
{{ t('admin.agent.training.emptyQuestionBank') }}
|
||||||
<select
|
</div>
|
||||||
v-model="question.type"
|
|
||||||
class="w-full input-field text-sm"
|
<div v-else class="space-y-4">
|
||||||
@change="handleTrainingQuestionTypeChange(form, questionIndex)"
|
<div
|
||||||
|
v-for="(question, questionIndex) in form.training_question_bank"
|
||||||
|
:key="questionIndex"
|
||||||
|
class="rounded-2xl border border-default bg-white p-4"
|
||||||
|
>
|
||||||
|
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||||
|
<div class="text-sm font-semibold text-primary">
|
||||||
|
{{ t('admin.agent.training.questionCardTitle', { index: questionIndex + 1 }) }}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="inline-flex items-center gap-1 rounded-lg border border-red-200 bg-red-50 px-3 py-1.5 text-xs font-medium text-red-600 transition-colors hover:bg-red-100"
|
||||||
|
@click="emit('removeTrainingQuestion', questionIndex)"
|
||||||
>
|
>
|
||||||
<option value="single">{{ t('admin.agent.training.single') }}</option>
|
<Trash2 class="h-4 w-4" />
|
||||||
<option value="boolean">{{ t('admin.agent.training.boolean') }}</option>
|
{{ t('admin.agent.training.removeQuestion') }}
|
||||||
</select>
|
</button>
|
||||||
</div>
|
|
||||||
<div class="space-y-2">
|
|
||||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.correctAnswer') }}</label>
|
|
||||||
<select v-model="question.answer" class="w-full input-field text-sm">
|
|
||||||
<template v-if="question.type === 'boolean'">
|
|
||||||
<option value="true">{{ t('admin.agent.training.booleanTrue') }}</option>
|
|
||||||
<option value="false">{{ t('admin.agent.training.booleanFalse') }}</option>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<option
|
|
||||||
v-for="(_, optionIndex) in question.options.filter((item) => String(item || '').trim())"
|
|
||||||
:key="`${questionIndex}-${optionIndex}`"
|
|
||||||
:value="String.fromCharCode(97 + optionIndex)"
|
|
||||||
>
|
|
||||||
{{ t('admin.agent.training.optionLabel', { label: optionLabels[optionIndex] || optionIndex + 1 }) }}
|
|
||||||
</option>
|
|
||||||
</template>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="space-y-2 md:col-span-3">
|
<div class="grid grid-cols-1 gap-4 md:grid-cols-3">
|
||||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.questionPrompt') }}</label>
|
<div class="space-y-2">
|
||||||
<textarea
|
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.questionId') }}</label>
|
||||||
v-model="question.prompt"
|
<input
|
||||||
rows="3"
|
v-model="question.id"
|
||||||
class="w-full input-field text-sm"
|
type="text"
|
||||||
:placeholder="t('admin.agent.training.questionPromptPlaceholder')"
|
class="w-full input-field text-sm"
|
||||||
/>
|
:placeholder="t('admin.agent.training.questionIdPlaceholder')"
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
<div class="space-y-2 md:col-span-3">
|
<div class="space-y-2">
|
||||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.questionExplanation') }}</label>
|
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.questionType') }}</label>
|
||||||
<textarea
|
<select
|
||||||
v-model="question.explanation"
|
v-model="question.type"
|
||||||
rows="3"
|
class="w-full input-field text-sm"
|
||||||
class="w-full input-field text-sm"
|
@change="handleTrainingQuestionTypeChange(form, questionIndex)"
|
||||||
:placeholder="t('admin.agent.training.questionExplanationPlaceholder')"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="question.type === 'single'" class="space-y-3 md:col-span-3">
|
|
||||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
||||||
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.questionOptions') }}</label>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="inline-flex items-center gap-1 rounded-lg border border-default bg-surface-soft px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-slate-100"
|
|
||||||
@click="emit('addTrainingOption', questionIndex)"
|
|
||||||
>
|
>
|
||||||
<Plus class="h-4 w-4" />
|
<option value="single">{{ t('admin.agent.training.single') }}</option>
|
||||||
{{ t('admin.agent.training.addOption') }}
|
<option value="boolean">{{ t('admin.agent.training.boolean') }}</option>
|
||||||
</button>
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-2">
|
||||||
|
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.correctAnswer') }}</label>
|
||||||
|
<select v-model="question.answer" class="w-full input-field text-sm">
|
||||||
|
<template v-if="question.type === 'boolean'">
|
||||||
|
<option value="true">{{ t('admin.agent.training.booleanTrue') }}</option>
|
||||||
|
<option value="false">{{ t('admin.agent.training.booleanFalse') }}</option>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<option
|
||||||
|
v-for="(_, optionIndex) in question.options.filter((item) => String(item || '').trim())"
|
||||||
|
:key="`${questionIndex}-${optionIndex}`"
|
||||||
|
:value="String.fromCharCode(97 + optionIndex)"
|
||||||
|
>
|
||||||
|
{{ t('admin.agent.training.optionLabel', { label: optionLabels[optionIndex] || optionIndex + 1 }) }}
|
||||||
|
</option>
|
||||||
|
</template>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid gap-3 md:grid-cols-2">
|
<div class="space-y-2 md:col-span-3">
|
||||||
<div
|
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.questionPrompt') }}</label>
|
||||||
v-for="(_, optionIndex) in question.options"
|
<textarea
|
||||||
:key="`${questionIndex}-option-${optionIndex}`"
|
v-model="question.prompt"
|
||||||
class="flex items-center gap-2 rounded-xl border border-default bg-surface-soft/40 p-3"
|
rows="3"
|
||||||
>
|
class="w-full input-field text-sm"
|
||||||
<span class="min-w-6 text-xs font-semibold text-muted">{{ optionLabels[optionIndex] || optionIndex + 1 }}.</span>
|
:placeholder="t('admin.agent.training.questionPromptPlaceholder')"
|
||||||
<input
|
/>
|
||||||
v-model="question.options[optionIndex]"
|
</div>
|
||||||
type="text"
|
|
||||||
class="w-full input-field text-sm"
|
<div class="space-y-2 md:col-span-3">
|
||||||
:placeholder="t('admin.agent.training.optionPlaceholder')"
|
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.questionExplanation') }}</label>
|
||||||
/>
|
<textarea
|
||||||
|
v-model="question.explanation"
|
||||||
|
rows="3"
|
||||||
|
class="w-full input-field text-sm"
|
||||||
|
:placeholder="t('admin.agent.training.questionExplanationPlaceholder')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="question.type === 'single'" class="space-y-3 md:col-span-3">
|
||||||
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
|
<label class="text-xs font-semibold text-secondary">{{ t('admin.agent.training.questionOptions') }}</label>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="inline-flex h-10 w-10 items-center justify-center rounded-lg border border-red-200 bg-red-50 text-red-600 transition-colors hover:bg-red-100"
|
class="inline-flex items-center gap-1 rounded-lg border border-default bg-surface-soft px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-slate-100"
|
||||||
@click="emit('removeTrainingOption', questionIndex, optionIndex)"
|
@click="emit('addTrainingOption', questionIndex)"
|
||||||
>
|
>
|
||||||
<Trash2 class="h-4 w-4" />
|
<Plus class="h-4 w-4" />
|
||||||
|
{{ t('admin.agent.training.addOption') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="grid gap-3 md:grid-cols-2">
|
||||||
|
<div
|
||||||
|
v-for="(_, optionIndex) in question.options"
|
||||||
|
:key="`${questionIndex}-option-${optionIndex}`"
|
||||||
|
class="flex items-center gap-2 rounded-xl border border-default bg-surface-soft/40 p-3"
|
||||||
|
>
|
||||||
|
<span class="min-w-6 text-xs font-semibold text-muted">{{ optionLabels[optionIndex] || optionIndex + 1 }}.</span>
|
||||||
|
<input
|
||||||
|
v-model="question.options[optionIndex]"
|
||||||
|
type="text"
|
||||||
|
class="w-full input-field text-sm"
|
||||||
|
:placeholder="t('admin.agent.training.optionPlaceholder')"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="inline-flex h-10 w-10 items-center justify-center rounded-lg border border-red-200 bg-red-50 text-red-600 transition-colors hover:bg-red-100"
|
||||||
|
@click="emit('removeTrainingOption', questionIndex, optionIndex)"
|
||||||
|
>
|
||||||
|
<Trash2 class="h-4 w-4" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<AgentToolRunProgressConfig
|
<AgentToolRunProgressConfig
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ const compactSummary = computed(() => {
|
|||||||
if (workspace.stage === 'summary') return t('chat.training.summary.title');
|
if (workspace.stage === 'summary') return t('chat.training.summary.title');
|
||||||
if (workspace.stage === 'exam') {
|
if (workspace.stage === 'exam') {
|
||||||
return t('chat.training.exam.questionCounter', {
|
return t('chat.training.exam.questionCounter', {
|
||||||
current: workspace.answeredCount + 1,
|
current: workspace.currentQuestionNumber,
|
||||||
total: workspace.totalQuestionCount,
|
total: workspace.totalQuestionCount,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,15 @@ const examQuestionItems = computed(() => Array.from({ length: workspace.totalQue
|
|||||||
const canNavigateExamQuestions = computed(() => workspace.stage === 'exam');
|
const canNavigateExamQuestions = computed(() => workspace.stage === 'exam');
|
||||||
const jumpToExamQuestion = (index: number) => {
|
const jumpToExamQuestion = (index: number) => {
|
||||||
if (!canNavigateExamQuestions.value) return;
|
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;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -387,8 +395,11 @@ const jumpToExamQuestion = (index: number) => {
|
|||||||
v-for="(item, index) in stageItems"
|
v-for="(item, index) in stageItems"
|
||||||
:key="item.key"
|
:key="item.key"
|
||||||
class="rounded-xl border px-3 py-2.5 transition cursor-pointer hover:border-brand-300"
|
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'"
|
:class="[
|
||||||
@click="workspace.stage = item.key as any"
|
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))"
|
||||||
>
|
>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<div
|
<div
|
||||||
@@ -492,7 +503,7 @@ const jumpToExamQuestion = (index: number) => {
|
|||||||
{{ $t('chat.training.exam.title') }}
|
{{ $t('chat.training.exam.title') }}
|
||||||
</div>
|
</div>
|
||||||
<h3 class="mt-1 text-lg font-semibold text-primary">
|
<h3 class="mt-1 text-lg font-semibold text-primary">
|
||||||
{{ $t('chat.training.exam.questionCounter', { current: workspace.answeredCount + 1, total: workspace.totalQuestionCount }) }}
|
{{ $t('chat.training.exam.questionCounter', { current: workspace.currentQuestionNumber, total: workspace.totalQuestionCount }) }}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-wrap gap-2 text-sm text-secondary">
|
<div class="flex flex-wrap gap-2 text-sm text-secondary">
|
||||||
@@ -564,12 +575,12 @@ const jumpToExamQuestion = (index: number) => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="inline-flex items-center gap-2 rounded-xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-brand-700"
|
class="inline-flex items-center gap-2 rounded-xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-brand-700"
|
||||||
@click="workspace.moveToNextQuestion"
|
@click="workspace.examReadyToSubmit ? workspace.submitExam() : workspace.moveToNextQuestion()"
|
||||||
>
|
>
|
||||||
<ClipboardCheck class="h-4 w-4" />
|
<ClipboardCheck class="h-4 w-4" />
|
||||||
{{
|
{{
|
||||||
workspace.answeredCount >= workspace.totalQuestionCount
|
workspace.examReadyToSubmit
|
||||||
? $t('chat.training.exam.finishExam')
|
? $t('chat.training.exam.submitPaper')
|
||||||
: $t('chat.training.exam.nextQuestion')
|
: $t('chat.training.exam.nextQuestion')
|
||||||
}}
|
}}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -199,10 +199,20 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
|
|
||||||
const currentQuestion = computed(() => questionBank.value[currentQuestionIndex.value] || null);
|
const currentQuestion = computed(() => questionBank.value[currentQuestionIndex.value] || null);
|
||||||
const totalQuestionCount = computed(() => questionBank.value.length);
|
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 answeredCount = computed(() => answerRecords.value.length);
|
||||||
const correctCount = computed(() => answerRecords.value.filter((item) => item.correct).length);
|
const correctCount = computed(() => answerRecords.value.filter((item) => item.correct).length);
|
||||||
const wrongCount = 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 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(() => {
|
const learnerProgressPercent = computed(() => {
|
||||||
if (stage.value === 'video') return 25;
|
if (stage.value === 'video') return 25;
|
||||||
@@ -305,6 +315,21 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
currentFeedbackCorrect.value = Boolean(currentAnswer?.correct);
|
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) => {
|
const applyProgressRecord = (record: TrainingProgressRecord | null) => {
|
||||||
if (!record) {
|
if (!record) {
|
||||||
stage.value = 'video';
|
stage.value = 'video';
|
||||||
@@ -314,7 +339,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stage.value = record.stage;
|
stage.value = record.stage;
|
||||||
currentQuestionIndex.value = record.currentQuestionIndex;
|
syncExamQuestionIndex(record.currentQuestionIndex);
|
||||||
score.value = Number(record.score || 0);
|
score.value = Number(record.score || 0);
|
||||||
attemptCount.value = Number(record.attempts || 0);
|
attemptCount.value = Number(record.attempts || 0);
|
||||||
answerRecords.value = Array.isArray(record.answerDetails) ? record.answerDetails : [];
|
answerRecords.value = Array.isArray(record.answerDetails) ? record.answerDetails : [];
|
||||||
@@ -510,6 +535,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
if (answerLocked.value || !currentQuestion.value) return;
|
if (answerLocked.value || !currentQuestion.value) return;
|
||||||
const answeredQuestion = currentQuestion.value;
|
const answeredQuestion = currentQuestion.value;
|
||||||
selectedOptionId.value = optionId;
|
selectedOptionId.value = optionId;
|
||||||
|
answerLocked.value = true;
|
||||||
const isCorrect = optionId === answeredQuestion.answer;
|
const isCorrect = optionId === answeredQuestion.answer;
|
||||||
currentFeedbackCorrect.value = isCorrect;
|
currentFeedbackCorrect.value = isCorrect;
|
||||||
const nextCorrectAnswerCount = correctCount.value + (isCorrect ? 1 : 0);
|
const nextCorrectAnswerCount = correctCount.value + (isCorrect ? 1 : 0);
|
||||||
@@ -523,25 +549,14 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
answerRecords.value.push(answerRecord);
|
answerRecords.value.push(answerRecord);
|
||||||
latestExamFeedback.value = buildExamFeedback(answeredQuestion, answerRecord, nextScore);
|
latestExamFeedback.value = buildExamFeedback(answeredQuestion, answerRecord, nextScore);
|
||||||
|
|
||||||
// [STEP 1] 最后一题直接进入结算,对齐文档里的“答完即公布最终成绩”。
|
// [STEP 1] 最后一题答完后先停留在考试阶段,必须点击“提交答卷”才能进入结算结果。
|
||||||
if (currentQuestionIndex.value >= totalQuestionCount.value - 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();
|
void persistProgress();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [STEP 2] 非最后一题则在聊天流里自动反馈上一题,并紧接着展示下一题。
|
// [STEP 2] 非最后一题则在聊天流里自动反馈上一题,并紧接着展示下一题。
|
||||||
currentQuestionIndex.value += 1;
|
syncExamQuestionIndex(currentQuestionIndex.value + 1);
|
||||||
selectedOptionId.value = '';
|
|
||||||
answerLocked.value = false;
|
|
||||||
currentFeedbackCorrect.value = false;
|
|
||||||
void persistProgress();
|
void persistProgress();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -552,19 +567,30 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
const moveToNextQuestion = () => {
|
const moveToNextQuestion = () => {
|
||||||
if (!answerLocked.value) return;
|
if (!answerLocked.value) return;
|
||||||
if (currentQuestionIndex.value >= totalQuestionCount.value - 1) {
|
if (currentQuestionIndex.value >= totalQuestionCount.value - 1) {
|
||||||
stage.value = 'result';
|
|
||||||
completionDate.value = formatDate(new Date());
|
|
||||||
void persistProgress();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentQuestionIndex.value += 1;
|
syncExamQuestionIndex(currentQuestionIndex.value + 1);
|
||||||
selectedOptionId.value = '';
|
|
||||||
answerLocked.value = false;
|
|
||||||
currentFeedbackCorrect.value = false;
|
|
||||||
latestExamFeedback.value = null;
|
latestExamFeedback.value = null;
|
||||||
void persistProgress();
|
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 = () => {
|
const restartExam = () => {
|
||||||
stage.value = 'video';
|
stage.value = 'video';
|
||||||
resetExamState();
|
resetExamState();
|
||||||
@@ -645,6 +671,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
activeView,
|
activeView,
|
||||||
stage,
|
stage,
|
||||||
currentQuestionIndex,
|
currentQuestionIndex,
|
||||||
|
currentQuestionNumber,
|
||||||
currentQuestion,
|
currentQuestion,
|
||||||
totalQuestionCount,
|
totalQuestionCount,
|
||||||
passScore,
|
passScore,
|
||||||
@@ -654,6 +681,8 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
selectedOptionId,
|
selectedOptionId,
|
||||||
answerLocked,
|
answerLocked,
|
||||||
currentFeedbackCorrect,
|
currentFeedbackCorrect,
|
||||||
|
examReadyToSubmit,
|
||||||
|
canEnterResultStage,
|
||||||
latestExamFeedback,
|
latestExamFeedback,
|
||||||
latestSettledResult,
|
latestSettledResult,
|
||||||
answerRecords,
|
answerRecords,
|
||||||
@@ -681,7 +710,9 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
markVideoCompleted,
|
markVideoCompleted,
|
||||||
startExam,
|
startExam,
|
||||||
selectAnswer,
|
selectAnswer,
|
||||||
|
syncExamQuestionIndex,
|
||||||
moveToNextQuestion,
|
moveToNextQuestion,
|
||||||
|
submitExam,
|
||||||
restartExam,
|
restartExam,
|
||||||
exportRecords,
|
exportRecords,
|
||||||
showVideoModal,
|
showVideoModal,
|
||||||
|
|||||||
@@ -526,6 +526,7 @@
|
|||||||
"selectedAnswer": "Your answer: {answer}",
|
"selectedAnswer": "Your answer: {answer}",
|
||||||
"correctAnswer": "Correct answer: {answer}",
|
"correctAnswer": "Correct answer: {answer}",
|
||||||
"nextQuestion": "Next Question",
|
"nextQuestion": "Next Question",
|
||||||
|
"submitPaper": "Submit Paper",
|
||||||
"finishExam": "Finish Exam"
|
"finishExam": "Finish Exam"
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|||||||
@@ -526,6 +526,7 @@
|
|||||||
"selectedAnswer": "คำตอบของคุณ: {answer}",
|
"selectedAnswer": "คำตอบของคุณ: {answer}",
|
||||||
"correctAnswer": "คำตอบที่ถูกต้อง: {answer}",
|
"correctAnswer": "คำตอบที่ถูกต้อง: {answer}",
|
||||||
"nextQuestion": "ข้อถัดไป",
|
"nextQuestion": "ข้อถัดไป",
|
||||||
|
"submitPaper": "ส่งข้อสอบ",
|
||||||
"finishExam": "จบการสอบ"
|
"finishExam": "จบการสอบ"
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|||||||
@@ -526,6 +526,7 @@
|
|||||||
"selectedAnswer": "你的答案:{answer}",
|
"selectedAnswer": "你的答案:{answer}",
|
||||||
"correctAnswer": "正确答案:{answer}",
|
"correctAnswer": "正确答案:{answer}",
|
||||||
"nextQuestion": "下一题",
|
"nextQuestion": "下一题",
|
||||||
|
"submitPaper": "提交答卷",
|
||||||
"finishExam": "完成考试"
|
"finishExam": "完成考试"
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|||||||
@@ -526,6 +526,7 @@
|
|||||||
"selectedAnswer": "你的答案:{answer}",
|
"selectedAnswer": "你的答案:{answer}",
|
||||||
"correctAnswer": "正確答案:{answer}",
|
"correctAnswer": "正確答案:{answer}",
|
||||||
"nextQuestion": "下一題",
|
"nextQuestion": "下一題",
|
||||||
|
"submitPaper": "提交答卷",
|
||||||
"finishExam": "完成考試"
|
"finishExam": "完成考試"
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|||||||
Reference in new issue
Block a user