diff --git a/src/api/aiTrainingEvaluation.js b/src/api/aiTrainingEvaluation.js index 413cae0..4a3ef50 100644 --- a/src/api/aiTrainingEvaluation.js +++ b/src/api/aiTrainingEvaluation.js @@ -7,10 +7,11 @@ export function getAiTrainingEvaluation(taskKey) { }); } -export function requestAiTrainingHelp(taskKey) { +export function requestAiTrainingHelp(taskKey, question) { return request({ url: `/api/student/training-tasks/${taskKey}/ai-evaluation/help`, method: "post", + data: { question }, headers: { repeatSubmit: false }, }); } diff --git a/src/views/components/TrainingAiSidebar.vue b/src/views/components/TrainingAiSidebar.vue index 73e1c02..dfce35e 100644 --- a/src/views/components/TrainingAiSidebar.vue +++ b/src/views/components/TrainingAiSidebar.vue @@ -122,15 +122,20 @@ function useReferencePrompt() { async function requestAssist() { emit("request-assist", assistQuestion.value); + const question = assistQuestion.value.trim(); + if (!question) { + assistMessage.value = "请输入问题,或点击上方参考提示词后发送。"; + return; + } if (currentTaskKey.value) { try { - await requestAiTrainingHelp(currentTaskKey.value); + await requestAiTrainingHelp(currentTaskKey.value, question); await loadEvaluation(); assistMessage.value = reports.value.helpReport || props.assistText; return; } catch (error) {} } - assistMessage.value = assistQuestion.value ? `围绕“${assistQuestion.value}”,建议先对照任务目标检查信息是否完整,再补充数据依据和分析结论。` : props.assistText; + assistMessage.value = `围绕“${question}”,建议先对照任务目标检查信息是否完整,再补充数据依据和分析结论。`; } async function requestEvaluation() { diff --git a/tests/ai-training-evaluation.static.test.cjs b/tests/ai-training-evaluation.static.test.cjs index 131d196..e18ae14 100644 --- a/tests/ai-training-evaluation.static.test.cjs +++ b/tests/ai-training-evaluation.static.test.cjs @@ -5,14 +5,19 @@ const path = require("path"); const root = path.resolve(__dirname, ".."); const api = fs.readFileSync(path.join(root, "src/api/aiTrainingEvaluation.js"), "utf8"); const component = fs.readFileSync(path.join(root, "src/views/components/TrainingAiEvaluation.vue"), "utf8"); +const sidebar = fs.readFileSync(path.join(root, "src/views/components/TrainingAiSidebar.vue"), "utf8"); const page = fs.readFileSync(path.join(root, "src/views/training/GenericTrainingPage.vue"), "utf8"); const { normalizeEvaluationReports } = require(path.join(root, "src/views/components/trainingAiEvaluationReport.cjs")); assert(/`\/api\/student\/training-tasks\/\$\{taskKey\}\/ai-evaluation`/.test(api), "evaluation API should use the student task endpoint"); assert(/\/help/.test(api) && /\/assessment/.test(api), "evaluation API should expose help and assessment operations"); -assert(/TrainingAiEvaluation/.test(page) && /:has-any-answer="hasAnyAnswer"/.test(page), "generic training page should pass meaningful answer state to AI evaluation"); +assert(/TrainingAiSidebar/.test(page), "generic training page should render the unified AI sidebar"); assert(/form\.value/.test(page) && /workRows\.value/.test(page) && /processRows\.value/.test(page), "hasAnyAnswer should inspect all supported answer shapes"); -assert(/\s*props\.taskKey/.test(component), "AI evaluation should load on mount and task changes"); assert(/AI助学/.test(component) && /AI助评/.test(component), "AI evaluation should offer separate help and assessment controls");