feat(chat-training): 优化员工培训agent工作区交互

This commit is contained in:
runny committed 2026-07-09 10:14:12 +08:00
1 parent 37e08c83d8
commit 5bef77f86c
10 files changed
+126 -165

No files matched your search

@@ -119,9 +119,11 @@ const openBlankMaintenanceRecordCreate = (): void => {
maintenancePanel.value = 'record'; maintenancePanel.value = 'record';
}; };
// 切换 Agent 时,重置工作区展开状态,确保每次进入都是收起状态(聊天优先) // 切换非培训 Agent 时,重置工作区展开状态;培训 Agent 的默认展开策略交给 TrainingWorkspacePanel 按角色决定。
watch(() => page.currentAgentId, () => { watch(() => page.currentAgentId, () => {
isTrainingWorkspaceExpanded.value = false; if (!isTrainingAgentPage.value) {
isTrainingWorkspaceExpanded.value = false;
}
maintenancePanel.value = null; maintenancePanel.value = null;
isMaintenancePanelFullscreen.value = false; isMaintenancePanelFullscreen.value = false;
}); });
@@ -198,12 +200,9 @@ watch(() => page.currentAgentId, () => {
:current-agent="page.currentAgent" :current-agent="page.currentAgent"
:current-user="page.currentUser" :current-user="page.currentUser"
:agent-guides="page.agentGuides" :agent-guides="page.agentGuides"
:has-messages="page.messages.length > 0"
:new-session-tick="page.viewId" :new-session-tick="page.viewId"
:training="page.training" :training="page.training"
@open-guide="page.openGuideModal" @open-guide="page.openGuideModal"
@send-chat-prompt="page.handleSend($event)"
@push-local-assistant-message="page.pushLocalAssistantMessage($event)"
@update:expanded="isTrainingWorkspaceExpanded = $event" @update:expanded="isTrainingWorkspaceExpanded = $event"
/> />
@@ -1,9 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
/** /**
* features/chat/components/TrainingWorkspacePanel.vue * features/chat/components/TrainingWorkspacePanel.vue
* 用途:在培训 Agent 的聊天页顶部提供“学员考试流 + HR 管理流”一体化工作区。 * 用途:在培训 Agent 的聊天页顶部提供“员工培训 + 培训管理”一体化工作区。
* 依赖:useTrainingWorkspace、lucide 图标、聊天页 currentAgent/currentUser。 * 依赖:useTrainingWorkspace、lucide 图标、聊天页 currentAgent/currentUser。
* 逻辑:只在培训 Agent 下渲染;学员端负责前端交互闭环,HR 端负责本地筛选统计与 Excel 导出,并可把上下文同步回聊天区。 * 逻辑:只在培训 Agent 下渲染;员工角色默认直达展开工作区,管理角色保留问答视图,培训答题不再走聊天链路。
*/ */
import { computed, reactive, ref, watch, type ShallowUnwrapRef } from 'vue'; import { computed, reactive, ref, watch, type ShallowUnwrapRef } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
@@ -18,7 +18,6 @@ import {
RefreshCcw, RefreshCcw,
ShieldCheck, ShieldCheck,
Target, Target,
Users,
XCircle, XCircle,
} from 'lucide-vue-next'; } from 'lucide-vue-next';
import { useTrainingWorkspace } from '@/features/chat/composables/useTrainingWorkspace'; import { useTrainingWorkspace } from '@/features/chat/composables/useTrainingWorkspace';
@@ -28,13 +27,11 @@ const props = defineProps<{
currentAgent: Record<string, unknown> | null; currentAgent: Record<string, unknown> | null;
currentUser: Record<string, unknown> | null; currentUser: Record<string, unknown> | null;
agentGuides: TrainingGuideLike[]; agentGuides: TrainingGuideLike[];
hasMessages: boolean;
newSessionTick: number; newSessionTick: number;
training: ShallowUnwrapRef<ReturnType<typeof useTrainingWorkspace>>; training: ShallowUnwrapRef<ReturnType<typeof useTrainingWorkspace>>;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
'push-local-assistant-message': [content: string];
'open-guide': [guideId?: number]; 'open-guide': [guideId?: number];
'update:expanded': [expanded: boolean]; 'update:expanded': [expanded: boolean];
}>(); }>();
@@ -64,7 +61,8 @@ const stageItems = computed(() => ([
{ key: 'result', label: 'chat.training.steps.result', icon: ShieldCheck }, { key: 'result', label: 'chat.training.steps.result', icon: ShieldCheck },
])); ]));
const userExpandedOverride = ref(false); const userExpandedOverride = ref<boolean | null>(null);
const shouldDefaultExpanded = computed(() => workspace.isTrainingAgent && !workspace.isAdminViewer);
const handleVideoTimeUpdate = (e: Event) => { const handleVideoTimeUpdate = (e: Event) => {
const video = e.target as HTMLVideoElement; const video = e.target as HTMLVideoElement;
@@ -91,7 +89,7 @@ const setWorkspaceExpanded = (expanded: boolean, manual = false) => {
if (manual) { if (manual) {
userExpandedOverride.value = expanded; userExpandedOverride.value = expanded;
} else if (!expanded) { } else if (!expanded) {
userExpandedOverride.value = false; userExpandedOverride.value = null;
} }
}; };
@@ -103,53 +101,30 @@ const currentAnswerLabel = computed(() => {
const trainingExamPdfGuide = computed(() => resolveTrainingExamPdfGuide(props.agentGuides)); const trainingExamPdfGuide = computed(() => resolveTrainingExamPdfGuide(props.agentGuides));
// 默认进入 Chat 聊天页面(即收起工作区状态)
const workspaceExpanded = ref(false); const workspaceExpanded = ref(false);
const autoSyncInitialPrompt = () => { const applyDefaultExpandedState = () => {
if ( const nextExpanded = userExpandedOverride.value ?? shouldDefaultExpanded.value;
workspace.isTrainingAgent workspaceExpanded.value = nextExpanded;
&& workspace.isHydrated emit('update:expanded', nextExpanded);
&& !props.hasMessages
&& workspace.shouldShowNewSessionReminder
) {
emit('push-local-assistant-message', workspace.newSessionReminderMessage);
}
}; };
// 监听 Agent 切换,重置所有本地交互状态,确保每次进入都是初始、收起且触发引导的状态 // 监听 Agent/角色切换,重置本地展开态:员工默认展开工作区,培训管理角色默认保留问答视图。
watch( watch(
() => props.currentAgent?.id, () => [props.currentAgent?.id, workspace.isAdminViewer],
() => { () => {
userExpandedOverride.value = false; userExpandedOverride.value = null;
workspaceExpanded.value = false; applyDefaultExpandedState();
emit('update:expanded', false);
}, },
{ immediate: true } { immediate: true }
); );
watch(() => props.hasMessages, () => {
// 如果用户没有手动展开,且消息状态变化,我们保持在聊天模式(收起工作区)
if (!userExpandedOverride.value) {
workspaceExpanded.value = false;
emit('update:expanded', false);
}
});
watch(
() => workspace.isHydrated,
(ready) => {
if (ready && workspace.isTrainingAgent && !props.hasMessages) {
autoSyncInitialPrompt();
}
},
);
watch( watch(
() => props.newSessionTick, () => props.newSessionTick,
(tick, prevTick) => { (tick, prevTick) => {
if (!tick || tick === prevTick) return; if (!tick || tick === prevTick) return;
autoSyncInitialPrompt(); userExpandedOverride.value = null;
applyDefaultExpandedState();
}, },
); );
@@ -177,6 +152,21 @@ const ruleItems = computed(() => ([
t('chat.training.rules.rule3', { passScore: workspace.passScore }), t('chat.training.rules.rule3', { passScore: workspace.passScore }),
t('chat.training.rules.rule4'), t('chat.training.rules.rule4'),
])); ]));
const learnerIdentityItems = computed(() => ([
{ key: 'name', label: t('chat.training.learnerCard.name'), value: workspace.currentUserName },
{ key: 'employee-id', label: t('chat.training.learnerCard.employeeId'), value: workspace.currentUserEmployeeId },
{ key: 'department', label: t('chat.training.learnerCard.department'), value: workspace.currentUserDepartment },
]));
const examQuestionItems = computed(() => Array.from({ length: workspace.totalQuestionCount }, (_, index) => ({
index,
label: String(index + 1).padStart(2, '0'),
isActive: workspace.currentQuestionIndex === index,
})));
const canNavigateExamQuestions = computed(() => workspace.stage === 'exam');
const jumpToExamQuestion = (index: number) => {
if (!canNavigateExamQuestions.value) return;
workspace.currentQuestionIndex = index;
};
</script> </script>
<template> <template>
@@ -262,10 +252,14 @@ const ruleItems = computed(() => ([
· {{ $t('chat.training.hr.filters.departmentLabel') }}: · {{ $t('chat.training.hr.filters.departmentLabel') }}:
{{ workspace.hrDepartmentFilter === 'all' ? $t('chat.training.hr.filters.allDepartments') : workspace.hrDepartmentFilter }} {{ workspace.hrDepartmentFilter === 'all' ? $t('chat.training.hr.filters.allDepartments') : workspace.hrDepartmentFilter }}
</template> </template>
<template v-else> </div>
{{ $t('chat.training.progressPercent') }}: {{ workspace.learnerProgressPercent }}% <div
· {{ $t('chat.training.learnerCard.name') }}: {{ workspace.currentUserName }} v-if="workspace.activeView === 'learner'"
</template> class="mt-1 flex flex-wrap gap-x-4 gap-y-1 text-xs leading-5 text-secondary"
>
<span v-for="item in learnerIdentityItems" :key="item.key">
{{ item.label }}: {{ item.value }}
</span>
</div> </div>
</div> </div>
<div class="flex flex-wrap items-center gap-2 text-xs"> <div class="flex flex-wrap items-center gap-2 text-xs">
@@ -350,6 +344,14 @@ const ruleItems = computed(() => ([
· {{ $t('chat.training.learnerCard.name') }}: {{ workspace.currentUserName }} · {{ $t('chat.training.learnerCard.name') }}: {{ workspace.currentUserName }}
</template> </template>
</div> </div>
<div
v-if="workspace.activeView === 'learner'"
class="mt-1 flex flex-wrap gap-x-4 gap-y-1 text-xs leading-5 text-secondary"
>
<span v-for="item in learnerIdentityItems" :key="item.key">
{{ item.label }}: {{ item.value }}
</span>
</div>
</div> </div>
<div class="flex flex-wrap items-center gap-2 text-xs"> <div class="flex flex-wrap items-center gap-2 text-xs">
<div class="rounded-full bg-white px-3 py-1.5 font-medium text-primary shadow-sm"> <div class="rounded-full bg-white px-3 py-1.5 font-medium text-primary shadow-sm">
@@ -636,22 +638,30 @@ const ruleItems = computed(() => ([
<div class="min-w-0 md:sticky md:top-4 md:self-start"> <div class="min-w-0 md:sticky md:top-4 md:self-start">
<div class="rounded-2xl border border-default bg-white p-3 shadow-sm"> <div class="rounded-2xl border border-default bg-white p-3 shadow-sm">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<Users class="h-4 w-4 text-brand-600" /> <ClipboardCheck class="h-4 w-4 text-brand-600" />
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.learnerCard.title') }}</div> <div class="text-sm font-semibold text-primary">{{ $t('chat.training.examQuestionCard.title') }}</div>
</div> </div>
<div class="mt-2.5 grid gap-1.5 text-sm text-secondary"> <div class="mt-2 text-xs leading-5 text-secondary">
<div class="flex items-center justify-between rounded-xl bg-surface-soft px-3 py-2"> {{ $t('chat.training.examQuestionCard.hint') }}
<span>{{ $t('chat.training.learnerCard.name') }}</span> </div>
<span class="font-medium text-primary">{{ workspace.currentUserName }}</span> <div class="mt-3 grid grid-cols-4 gap-2">
</div> <button
<div class="flex items-center justify-between rounded-xl bg-surface-soft px-3 py-2"> v-for="item in examQuestionItems"
<span>{{ $t('chat.training.learnerCard.employeeId') }}</span> :key="item.index"
<span class="font-medium text-primary">{{ workspace.currentUserEmployeeId }}</span> type="button"
</div> class="flex h-10 items-center justify-center rounded-xl border text-sm font-semibold transition"
<div class="flex items-center justify-between rounded-xl bg-surface-soft px-3 py-2"> :class="[
<span>{{ $t('chat.training.learnerCard.department') }}</span> item.isActive
<span class="font-medium text-primary">{{ workspace.currentUserDepartment }}</span> ? 'border-brand-500 bg-brand-600 text-white shadow-sm'
</div> : canNavigateExamQuestions
? 'border-brand-200 bg-brand-50/60 text-brand-700 hover:bg-brand-100'
: 'cursor-not-allowed border-default bg-surface-soft text-muted',
]"
:disabled="!canNavigateExamQuestions"
@click="jumpToExamQuestion(item.index)"
>
{{ item.label }}
</button>
</div> </div>
<div class="my-3 h-px bg-slate-100" /> <div class="my-3 h-px bg-slate-100" />
@@ -93,49 +93,11 @@ const isLeaveMessage = computed(() =>
|| message.type === 'leave-result', || message.type === 'leave-result',
); );
const isTrainingExamMessage = computed(() => { // 员工培训的答题、结果与视频步骤统一收口到工作区,聊天区仅保留普通问答,不再承接培训操作卡片。
if (message.role !== 'assistant') return false; const isTrainingExamMessage = computed(() => false);
// 必须是最后一条助手消息,且包含题目特征文字(确保只在当前正在进行的题目上显示交互组件) const isTrainingVideoMessage = computed(() => false);
if (!isLastMessage.value) return false; const isTrainingSummaryMessage = computed(() => false);
const content = message.content || ''; const isTrainingResultMessage = computed(() => false);
return content.includes('正在进行新人培训考试')
|| (content.includes('第') && content.includes('题') && (content.includes('共') || content.includes('/')));
});
const isTrainingVideoMessage = computed(() => {
if (message.role !== 'assistant') return false;
// 只要包含特定引导文案,就显示视频占位符,不限于最后一条消息
const content = message.content || '';
return content.includes('专属入职培训助手')
|| content.includes('onboarding training assistant')
|| content.includes('ผู้ช่วยอบรมพนักงานใหม่')
|| content.includes('入职培训视频')
|| content.includes('training video');
});
const isTrainingSummaryMessage = computed(() => {
if (message.role !== 'assistant') return false;
const content = message.content || '';
return content.includes('完成视频学习')
|| content.includes('复盘重点知识')
|| content.includes('复盘知识点')
|| content.includes('总结重点知识')
|| content.includes('核心知识点')
|| content.includes('key knowledge points')
|| content.includes('ประเด็นสำคัญ');
});
const isTrainingResultMessage = computed(() => {
if (message.role !== 'assistant') return false;
// 只要是结果文案,就显示结算卡片,不限于最后一条消息
const content = message.content || '';
return content.includes('考试结束')
|| content.includes('顺利通过新人考核')
|| content.includes('Exam finished')
|| content.includes('passed the onboarding assessment')
|| content.includes('สอบเสร็จแล้ว')
|| content.includes('ผ่านการประเมินพนักงานใหม่');
});
const retrieverResources = computed(() => handlers.getDisplayRetrieverResources(message)); const retrieverResources = computed(() => handlers.getDisplayRetrieverResources(message));
const sourceLinks = computed(() => handlers.getSourceLinks(retrieverResources.value)); const sourceLinks = computed(() => handlers.getSourceLinks(retrieverResources.value));
@@ -27,10 +27,10 @@ const TRAINING_AGENT_DESCRIPTION =
'我是你的新人培训助手,会在同一个聊天页面内带你完成视频学习、知识点复盘、逐题考试和结果复盘。'; '我是你的新人培训助手,会在同一个聊天页面内带你完成视频学习、知识点复盘、逐题考试和结果复盘。';
const TRAINING_AGENT_QUESTIONS: AgentSuggestedQuestionItem[] = [ const TRAINING_AGENT_QUESTIONS: AgentSuggestedQuestionItem[] = [
{ question: '开始新人培训', group: '培训流程' }, { question: '这次员工培训主要学习什么内容?', group: '培训问答' },
{ question: '我已看完视频,请总结知识点', group: '培训流程' }, { question: '员工培训的通过规则是什么?', group: '培训问答' },
{ question: '开始考试', group: '培训流程' }, { question: '这次培训的试题范围有哪些?', group: '培训问答' },
{ question: '导出本月培训成绩', group: 'HR 管理' }, { question: '培训记录会如何统计?', group: '培训问答' },
]; ];
const normalizeAgentSuggestedQuestions = (value: unknown): AgentSuggestedQuestionItem[] => { const normalizeAgentSuggestedQuestions = (value: unknown): AgentSuggestedQuestionItem[] => {
@@ -348,26 +348,10 @@ export function useChatPage() {
t, t,
}); });
const pushLocalUserMessage = async (content: string) => {
const msgText = String(content || '').trim();
if (!msgText) return;
const userMsg: ChatMessage = {
role: 'user',
type: 'text',
content: msgText,
local_id: newLocalMessageId('local-user'),
local_only: true,
};
messages.value.push(userMsg);
await saveLocalMessageToBackend(userMsg);
};
const training = useTrainingWorkspace({ const training = useTrainingWorkspace({
currentAgent: computed(() => agent.currentAgent.value), currentAgent: computed(() => agent.currentAgent.value),
currentUser: computed(() => currentUser.value), currentUser: computed(() => currentUser.value),
currentGuides: computed(() => chatGuides.guides.value), currentGuides: computed(() => chatGuides.guides.value),
pushLocalAssistantMessage,
pushLocalUserMessage,
}); });
const markdown = createChatPageMarkdownApi({ const markdown = createChatPageMarkdownApi({
@@ -2,7 +2,7 @@
* features/chat/composables/useTrainingWorkspace.ts * features/chat/composables/useTrainingWorkspace.ts
* 用途:封装员工培训 Agent 的工作区状态,包括学员考试流、进度持久化与 HR 真实统计导出。 * 用途:封装员工培训 Agent 的工作区状态,包括学员考试流、进度持久化与 HR 真实统计导出。
* 依赖:Vue reactivity、vue-i18n、training.api,以及 training.types。 * 依赖:Vue reactivity、vue-i18n、training.api,以及 training.types。
* 逻辑:仅在培训 Agent 下启用;学员端按“视频 -> 知识点 -> 一题一答 -> 结算”推进,并把进度同步到后端。 * 逻辑:仅在培训 Agent 下启用;学员端按“视频 -> 知识点 -> 一题一答 -> 结算”推进,并把进度同步到后端,聊天区只保留问答能力。
*/ */
import { computed, ref, watch, type ComputedRef } from 'vue'; import { computed, ref, watch, type ComputedRef } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
@@ -56,8 +56,6 @@ export interface UseTrainingWorkspaceOptions {
currentAgent: ComputedRef<TrainingAgentLike>; currentAgent: ComputedRef<TrainingAgentLike>;
currentUser: ComputedRef<TrainingUserLike>; currentUser: ComputedRef<TrainingUserLike>;
currentGuides: ComputedRef<TrainingGuideLike[]>; currentGuides: ComputedRef<TrainingGuideLike[]>;
pushLocalAssistantMessage?: (content: string) => Promise<void>;
pushLocalUserMessage?: (content: string) => Promise<void>;
} }
const DEFAULT_TRAINING_VIDEO_URL = 'https://www.w3schools.com/html/mov_bbb.mp4'; const DEFAULT_TRAINING_VIDEO_URL = 'https://www.w3schools.com/html/mov_bbb.mp4';
@@ -75,13 +73,14 @@ const calculateTrainingScore = (correctAnswerCount: number, totalQuestionCount:
}; };
export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) { export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
const { currentAgent, currentUser, currentGuides, pushLocalAssistantMessage, pushLocalUserMessage } = options; const { currentAgent, currentUser, currentGuides } = options;
const { t, tm } = useI18n(); const { t, tm } = useI18n();
const msg = useMessage(); const msg = useMessage();
const isTrainingAgent = computed(() => matchesTrainingAgent(currentAgent.value)); const isTrainingAgent = computed(() => matchesTrainingAgent(currentAgent.value));
const hasAuthenticatedUser = computed(() => Boolean(String(currentUser.value?.username || '').trim())); const hasAuthenticatedUser = computed(() => Boolean(String(currentUser.value?.username || '').trim()));
const isAdminViewer = computed(() => Boolean(currentUser.value?.feature_permissions?.training_hr_manage)); const isAdminViewer = computed(() => Boolean(currentUser.value?.feature_permissions?.training_hr_manage));
const defaultActiveView = computed<TrainingWorkspaceView>(() => (isAdminViewer.value ? 'admin' : 'learner'));
const activeView = ref<TrainingWorkspaceView>('learner'); const activeView = ref<TrainingWorkspaceView>('learner');
const stage = ref<TrainingStage>('video'); const stage = ref<TrainingStage>('video');
@@ -127,6 +126,15 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
} }
}); });
watch(
[isTrainingAgent, isAdminViewer],
([enabled]) => {
if (!enabled) return;
activeView.value = defaultActiveView.value;
},
{ immediate: true },
);
const defaultSummaryPoints = computed(() => { const defaultSummaryPoints = computed(() => {
const raw = tm('chat.training.summaryPoints'); const raw = tm('chat.training.summaryPoints');
return Array.isArray(raw) ? raw.map((item) => String(item)) : []; return Array.isArray(raw) ? raw.map((item) => String(item)) : [];
@@ -484,8 +492,6 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
const markVideoCompleted = () => { const markVideoCompleted = () => {
stage.value = 'summary'; stage.value = 'summary';
// 立即推入本地助手消息(复盘卡片)
void pushLocalAssistantMessage?.(learnerAssistantMessage.value);
void persistProgress(); void persistProgress();
}; };
@@ -497,9 +503,6 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
stage.value = 'exam'; stage.value = 'exam';
attemptCount.value += 1; attemptCount.value += 1;
resetExamState(); resetExamState();
void pushLocalUserMessage?.(t('chat.training.chatPrompts.startExamCommand'));
// 立即推入第一题的消息引导
void pushLocalAssistantMessage?.(learnerAssistantMessage.value);
void persistProgress(); void persistProgress();
}; };
@@ -520,10 +523,6 @@ 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);
// 推入用户选择的答案到聊天流
const label = getQuestionOptionLabel(answeredQuestion, optionId);
void pushLocalUserMessage?.(label);
// [STEP 1] 最后一题直接进入结算,对齐文档里的“答完即公布最终成绩”。 // [STEP 1] 最后一题直接进入结算,对齐文档里的“答完即公布最终成绩”。
if (currentQuestionIndex.value >= totalQuestionCount.value - 1) { if (currentQuestionIndex.value >= totalQuestionCount.value - 1) {
stage.value = 'result'; stage.value = 'result';
@@ -534,7 +533,6 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
wrongCount: answerRecords.value.filter((item) => !item.correct).length, wrongCount: answerRecords.value.filter((item) => !item.correct).length,
isPassed: nextScore >= passScore.value, isPassed: nextScore >= passScore.value,
}; };
void pushLocalAssistantMessage?.(learnerAssistantMessage.value);
void persistProgress(); void persistProgress();
return; return;
} }
@@ -544,7 +542,6 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
selectedOptionId.value = ''; selectedOptionId.value = '';
answerLocked.value = false; answerLocked.value = false;
currentFeedbackCorrect.value = false; currentFeedbackCorrect.value = false;
void pushLocalAssistantMessage?.(learnerAssistantMessage.value);
void persistProgress(); void persistProgress();
}; };
@@ -557,8 +554,6 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
if (currentQuestionIndex.value >= totalQuestionCount.value - 1) { if (currentQuestionIndex.value >= totalQuestionCount.value - 1) {
stage.value = 'result'; stage.value = 'result';
completionDate.value = formatDate(new Date()); completionDate.value = formatDate(new Date());
// 推入结果消息
void pushLocalAssistantMessage?.(learnerAssistantMessage.value);
void persistProgress(); void persistProgress();
return; return;
} }
@@ -567,17 +562,12 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
answerLocked.value = false; answerLocked.value = false;
currentFeedbackCorrect.value = false; currentFeedbackCorrect.value = false;
latestExamFeedback.value = null; latestExamFeedback.value = null;
// 推入下一题消息
void pushLocalAssistantMessage?.(learnerAssistantMessage.value);
void persistProgress(); void persistProgress();
}; };
const restartExam = () => { const restartExam = () => {
stage.value = 'video'; stage.value = 'video';
resetExamState(); resetExamState();
void pushLocalUserMessage?.(t('chat.training.chatPrompts.restartExamCommand'));
// 重新推回视频导学,强制补考再次完整经过“视频 -> 复盘 -> 开考”链路。
void pushLocalAssistantMessage?.(learnerAssistantMessage.value);
// 不立即覆盖后端已结算成绩,避免刷新页面或重新进入历史对话时丢失上一轮考试结果与 HR 统计事实。 // 不立即覆盖后端已结算成绩,避免刷新页面或重新进入历史对话时丢失上一轮考试结果与 HR 统计事实。
}; };
+8 -4
View File
@@ -480,8 +480,8 @@
"title": "", "title": "",
"subtitle": "Complete video learning, knowledge review, one-question-at-a-time testing, and HR reporting in the same chat page.", "subtitle": "Complete video learning, knowledge review, one-question-at-a-time testing, and HR reporting in the same chat page.",
"tabs": { "tabs": {
"learner": "Learner", "learner": "Employee Training",
"admin": "HR Admin" "admin": "Training Management"
}, },
"actions": { "actions": {
"syncLearnerToChat": "Sync learner context to chat", "syncLearnerToChat": "Sync learner context to chat",
@@ -549,6 +549,10 @@
"employeeId": "Employee ID", "employeeId": "Employee ID",
"department": "Department" "department": "Department"
}, },
"examQuestionCard": {
"title": "Exam Questions",
"hint": "Shows all question numbers. They become clickable only during the step-by-step exam stage."
},
"rules": { "rules": {
"title": "Exam rules", "title": "Exam rules",
"rule1": "There are {total} questions, and the system calculates the result on a 100-point scale.", "rule1": "There are {total} questions, and the system calculates the result on a 100-point scale.",
@@ -603,12 +607,12 @@
"examInProgress": "I am taking the onboarding training exam and am currently on question {index}/{total}. Please stay in proctor mode and continue.", "examInProgress": "I am taking the onboarding training exam and am currently on question {index}/{total}. Please stay in proctor mode and continue.",
"assistantVideoIntro": "👋 Welcome aboard! I am your onboarding training assistant. Today's training has three steps: watch the video ➡️ review the key knowledge points ➡️ take the quiz ({passScore} points to pass).\n\n▶️ Please start with the onboarding training video. After watching it, move on to the knowledge review.", "assistantVideoIntro": "👋 Welcome aboard! I am your onboarding training assistant. Today's training has three steps: watch the video ➡️ review the key knowledge points ➡️ take the quiz ({passScore} points to pass).\n\n▶️ Please start with the onboarding training video. After watching it, move on to the knowledge review.",
"assistantSummaryIntro": "Great. Based on the video, I pulled together the key knowledge points you are most likely to be tested on:", "assistantSummaryIntro": "Great. Based on the video, I pulled together the key knowledge points you are most likely to be tested on:",
"assistantSummaryReady": "Ready for the challenge? Click Start Exam directly or reply \"Start Exam\" in the chat.", "assistantSummaryReady": "Ready for the challenge? Click Start Exam directly in the workspace.",
"assistantQuestionSingleType": "Single choice", "assistantQuestionSingleType": "Single choice",
"assistantQuestionBooleanType": "True or false", "assistantQuestionBooleanType": "True or false",
"assistantQuestionReplyHint": "Reply with the option or the answer text directly.", "assistantQuestionReplyHint": "Reply with the option or the answer text directly.",
"assistantResultPass": "🎉 **Congratulations!** Your final score is **{score}**. You passed the onboarding assessment, and your score has been synced to HR automatically.", "assistantResultPass": "🎉 **Congratulations!** Your final score is **{score}**. You passed the onboarding assessment, and your score has been synced to HR automatically.",
"assistantResultFail": "📊 **Exam finished!** Your final score is **{score}**. The passing line is {passScore}. Reply \"Retake Exam\" to try again.", "assistantResultFail": "📊 **Exam finished!** Your final score is **{score}**. The passing line is {passScore}. Click Retake Exam in the workspace to try again.",
"startExamCommand": "Start Exam", "startExamCommand": "Start Exam",
"restartExamCommand": "Retake Exam" "restartExamCommand": "Retake Exam"
}, },
+8 -4
View File
@@ -480,8 +480,8 @@
"title": "", "title": "",
"subtitle": "ทำวิดีโอเรียนรู้ ทบทวนความรู้ สอบทีละข้อ และดูสถิติ HR ได้ในหน้าแชตเดียวกัน", "subtitle": "ทำวิดีโอเรียนรู้ ทบทวนความรู้ สอบทีละข้อ และดูสถิติ HR ได้ในหน้าแชตเดียวกัน",
"tabs": { "tabs": {
"learner": "ผู้เรียน", "learner": "อบรมพนักงาน",
"admin": "HR Admin" "admin": "จัดการอบรม"
}, },
"actions": { "actions": {
"syncLearnerToChat": "ส่งบริบทผู้เรียนเข้าแชต", "syncLearnerToChat": "ส่งบริบทผู้เรียนเข้าแชต",
@@ -549,6 +549,10 @@
"employeeId": "รหัสพนักงาน", "employeeId": "รหัสพนักงาน",
"department": "แผนก" "department": "แผนก"
}, },
"examQuestionCard": {
"title": "ข้อสอบ",
"hint": "แสดงหมายเลขข้อทั้งหมด และจะกดได้เฉพาะในขั้นตอนสอบทีละข้อเท่านั้น"
},
"rules": { "rules": {
"title": "กติกาการสอบ", "title": "กติกาการสอบ",
"rule1": "มีทั้งหมด {total} ข้อ และระบบจะคำนวณผลสอบบนสเกล 100 คะแนน", "rule1": "มีทั้งหมด {total} ข้อ และระบบจะคำนวณผลสอบบนสเกล 100 คะแนน",
@@ -603,12 +607,12 @@
"examInProgress": "ฉันกำลังสอบอบรมพนักงานใหม่ ตอนนี้อยู่ที่ข้อ {index}/{total} โปรดทำหน้าที่เป็นผู้คุมสอบและถามต่อ", "examInProgress": "ฉันกำลังสอบอบรมพนักงานใหม่ ตอนนี้อยู่ที่ข้อ {index}/{total} โปรดทำหน้าที่เป็นผู้คุมสอบและถามต่อ",
"assistantVideoIntro": "👋 ยินดีต้อนรับสู่บริษัท! ฉันคือผู้ช่วยอบรมพนักงานใหม่ของคุณ วันนี้มี 3 ขั้นตอนคือ ดูวิดีโอ ➡️ ทบทวนความรู้ ➡️ ทำแบบทดสอบ (ผ่านที่ {passScore} คะแนน)\n\n▶️ โปรดเริ่มจากการดูวิดีโออบรมพนักงานใหม่ แล้วจึงเข้าสู่ช่วงทบทวนความรู้", "assistantVideoIntro": "👋 ยินดีต้อนรับสู่บริษัท! ฉันคือผู้ช่วยอบรมพนักงานใหม่ของคุณ วันนี้มี 3 ขั้นตอนคือ ดูวิดีโอ ➡️ ทบทวนความรู้ ➡️ ทำแบบทดสอบ (ผ่านที่ {passScore} คะแนน)\n\n▶️ โปรดเริ่มจากการดูวิดีโออบรมพนักงานใหม่ แล้วจึงเข้าสู่ช่วงทบทวนความรู้",
"assistantSummaryIntro": "ยอดเยี่ยม จากวิดีโอเมื่อครู่นี้ ฉันสรุปประเด็นสำคัญที่มีโอกาสออกสอบไว้ให้แล้ว:", "assistantSummaryIntro": "ยอดเยี่ยม จากวิดีโอเมื่อครู่นี้ ฉันสรุปประเด็นสำคัญที่มีโอกาสออกสอบไว้ให้แล้ว:",
"assistantSummaryReady": "พร้อมรับความท้าทายหรือยัง? กดเริ่มสอบได้เลย หรือพิมพ์ \"เริ่มสอบ\" ในแชตก็ได้", "assistantSummaryReady": "พร้อมรับความท้าทายหรือยัง? โปรดกดเริ่มสอบจากพื้นที่ทำงานได้เลย",
"assistantQuestionSingleType": "ปรนัย", "assistantQuestionSingleType": "ปรนัย",
"assistantQuestionBooleanType": "ถูกหรือผิด", "assistantQuestionBooleanType": "ถูกหรือผิด",
"assistantQuestionReplyHint": "ตอบด้วยตัวเลือกหรือข้อความคำตอบได้โดยตรง", "assistantQuestionReplyHint": "ตอบด้วยตัวเลือกหรือข้อความคำตอบได้โดยตรง",
"assistantResultPass": "🎉 **ยินดีด้วย!** คุณได้คะแนนสุดท้าย **{score}** และผ่านการประเมินพนักงานใหม่แล้ว ระบบได้ซิงก์คะแนนไปยัง HR โดยอัตโนมัติ", "assistantResultPass": "🎉 **ยินดีด้วย!** คุณได้คะแนนสุดท้าย **{score}** และผ่านการประเมินพนักงานใหม่แล้ว ระบบได้ซิงก์คะแนนไปยัง HR โดยอัตโนมัติ",
"assistantResultFail": "📊 **สอบเสร็จแล้ว!** คะแนนสุดท้ายของคุณคือ **{score}** เกณฑ์ผ่านคือ {passScore} คะแนน พิมพ์ \"สอบใหม่\" เพื่อเริ่มอีกครั้ง", "assistantResultFail": "📊 **สอบเสร็จแล้ว!** คะแนนสุดท้ายของคุณคือ **{score}** เกณฑ์ผ่านคือ {passScore} คะแนน โปรดกดสอบใหม่จากพื้นที่ทำงานเพื่อเริ่มอีกครั้ง",
"startExamCommand": "เริ่มสอบ", "startExamCommand": "เริ่มสอบ",
"restartExamCommand": "สอบใหม่" "restartExamCommand": "สอบใหม่"
}, },
+8 -4
View File
@@ -480,8 +480,8 @@
"title": "", "title": "",
"subtitle": "在同一个 Chat 页面内完成视频学习、知识点复盘、逐题考试以及 HR 管理统计。", "subtitle": "在同一个 Chat 页面内完成视频学习、知识点复盘、逐题考试以及 HR 管理统计。",
"tabs": { "tabs": {
"learner": "学员端", "learner": "员工培训",
"admin": "HR 管理" "admin": "培训管理"
}, },
"actions": { "actions": {
"syncLearnerToChat": "同步学员上下文到聊天", "syncLearnerToChat": "同步学员上下文到聊天",
@@ -549,6 +549,10 @@
"employeeId": "工号", "employeeId": "工号",
"department": "部门" "department": "部门"
}, },
"examQuestionCard": {
"title": "考试题目",
"hint": "展示全部题目序号;仅在“逐题考试”阶段可点击切换。"
},
"rules": { "rules": {
"title": "考试规则", "title": "考试规则",
"rule1": "共 {total} 题,系统按百分制自动计算成绩。", "rule1": "共 {total} 题,系统按百分制自动计算成绩。",
@@ -603,12 +607,12 @@
"examInProgress": "我正在进行新人培训考试,目前做到第 {index}/{total} 题。题目是:{question}。请保持考官模式,评价我的表现并引导我继续。", "examInProgress": "我正在进行新人培训考试,目前做到第 {index}/{total} 题。题目是:{question}。请保持考官模式,评价我的表现并引导我继续。",
"assistantVideoIntro": "👋 欢迎加入公司!我是你的专属入职培训助手。今天的培训分为三个步骤:看视频 ➡️ 知识点复盘 ➡️ 随堂测试({passScore} 分及格)。\n\n▶️ 请先点击观看【入职培训视频】。观看完毕后,点击进入【知识点复盘】。", "assistantVideoIntro": "👋 欢迎加入公司!我是你的专属入职培训助手。今天的培训分为三个步骤:看视频 ➡️ 知识点复盘 ➡️ 随堂测试({passScore} 分及格)。\n\n▶️ 请先点击观看【入职培训视频】。观看完毕后,点击进入【知识点复盘】。",
"assistantSummaryIntro": "太棒了!结合刚才的视频,我为你提炼了以下核心知识点(必考哦):", "assistantSummaryIntro": "太棒了!结合刚才的视频,我为你提炼了以下核心知识点(必考哦):",
"assistantSummaryReady": "准备好接受挑战了吗?直接点击【开始考试】或在 Chat 中回复【开始考试】。", "assistantSummaryReady": "准备好接受挑战了吗?请直接在工作区点击【开始考试】。",
"assistantQuestionSingleType": "单选题", "assistantQuestionSingleType": "单选题",
"assistantQuestionBooleanType": "判断题", "assistantQuestionBooleanType": "判断题",
"assistantQuestionReplyHint": "请直接回复选项或内容。", "assistantQuestionReplyHint": "请直接回复选项或内容。",
"assistantResultPass": "🎉 **恭喜!** 您的最终得分是 **{score} 分**,已顺利通过新人考核!您的成绩已自动同步至人事部门。", "assistantResultPass": "🎉 **恭喜!** 您的最终得分是 **{score} 分**,已顺利通过新人考核!您的成绩已自动同步至人事部门。",
"assistantResultFail": "📊 **考试结束!** 您的最终得分是 **{score} 分**。及格线为 {passScore} 分。请回复【重新考试】再次挑战!", "assistantResultFail": "📊 **考试结束!** 您的最终得分是 **{score} 分**。及格线为 {passScore} 分。请在工作区点击【重新考试】再次挑战!",
"startExamCommand": "开始考试", "startExamCommand": "开始考试",
"restartExamCommand": "重新考试" "restartExamCommand": "重新考试"
}, },
+8 -4
View File
@@ -480,8 +480,8 @@
"title": "", "title": "",
"subtitle": "在同一個 Chat 頁面內完成影片學習、知識點複盤、逐題考試與 HR 管理統計。", "subtitle": "在同一個 Chat 頁面內完成影片學習、知識點複盤、逐題考試與 HR 管理統計。",
"tabs": { "tabs": {
"learner": "學員端", "learner": "員工培訓",
"admin": "HR 管理" "admin": "培訓管理"
}, },
"actions": { "actions": {
"syncLearnerToChat": "同步學員上下文到聊天", "syncLearnerToChat": "同步學員上下文到聊天",
@@ -549,6 +549,10 @@
"employeeId": "工號", "employeeId": "工號",
"department": "部門" "department": "部門"
}, },
"examQuestionCard": {
"title": "考試題目",
"hint": "顯示全部題目序號;僅在「逐題考試」階段可點擊切換。"
},
"rules": { "rules": {
"title": "考試規則", "title": "考試規則",
"rule1": "共 {total} 題,系統按百分制自動計算成績。", "rule1": "共 {total} 題,系統按百分制自動計算成績。",
@@ -603,12 +607,12 @@
"examInProgress": "我正在進行新人培訓考試,目前做到第 {index}/{total} 題,請保持考官模式繼續出題。", "examInProgress": "我正在進行新人培訓考試,目前做到第 {index}/{total} 題,請保持考官模式繼續出題。",
"assistantVideoIntro": "👋 歡迎加入公司!我是你的專屬入職培訓助手。今天的培訓分為三個步驟:看影片 ➡️ 知識點複盤 ➡️ 隨堂測試({passScore} 分及格)。\n\n▶️ 請先點擊觀看【入職培訓影片】。觀看完畢後,點擊進入【知識點複盤】。", "assistantVideoIntro": "👋 歡迎加入公司!我是你的專屬入職培訓助手。今天的培訓分為三個步驟:看影片 ➡️ 知識點複盤 ➡️ 隨堂測試({passScore} 分及格)。\n\n▶️ 請先點擊觀看【入職培訓影片】。觀看完畢後,點擊進入【知識點複盤】。",
"assistantSummaryIntro": "太棒了!結合剛才的影片,我為你提煉了以下核心知識點(必考哦):", "assistantSummaryIntro": "太棒了!結合剛才的影片,我為你提煉了以下核心知識點(必考哦):",
"assistantSummaryReady": "準備好接受挑戰了嗎?直接點擊【開始考試】或在 Chat 中回覆【開始考試】。", "assistantSummaryReady": "準備好接受挑戰了嗎?請直接在工作區點擊【開始考試】。",
"assistantQuestionSingleType": "單選題", "assistantQuestionSingleType": "單選題",
"assistantQuestionBooleanType": "判斷題", "assistantQuestionBooleanType": "判斷題",
"assistantQuestionReplyHint": "請直接回覆選項或內容。", "assistantQuestionReplyHint": "請直接回覆選項或內容。",
"assistantResultPass": "🎉 **恭喜!** 你的最終得分是 **{score} 分**,已順利通過新人考核!成績已自動同步至人事部門。", "assistantResultPass": "🎉 **恭喜!** 你的最終得分是 **{score} 分**,已順利通過新人考核!成績已自動同步至人事部門。",
"assistantResultFail": "📊 **考試結束!** 你的最終得分是 **{score} 分**。及格線為 {passScore} 分。請回覆【重新考試】再次挑戰!", "assistantResultFail": "📊 **考試結束!** 你的最終得分是 **{score} 分**。及格線為 {passScore} 分。請在工作區點擊【重新考試】再次挑戰!",
"startExamCommand": "開始考試", "startExamCommand": "開始考試",
"restartExamCommand": "重新考試" "restartExamCommand": "重新考試"
}, },