feat: send student questions to AI help

dev-QQq
chenyuan 3 weeks ago
parent 0d2cc2aac0
commit a3ee21e568

@ -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 },
});
}

@ -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() {

@ -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(/<TrainingAiEvaluation[\s\S]*<TrainingAiSidebar/.test(page), "AI evaluation should render before the existing AI sidebar");
assert(/requestAiTrainingHelp\(taskKey, question\)/.test(api), "AI help API should accept the student's question");
assert(/data:\s*\{\s*question\s*\}/.test(api), "AI help API should submit the student's question as JSON");
assert(/const question = assistQuestion\.value\.trim\(\)/.test(sidebar), "AI sidebar should trim the student's question before sending it");
assert(/if \(!question\)/.test(sidebar), "AI sidebar should block an empty AI help question");
assert(/requestAiTrainingHelp\(currentTaskKey\.value, question\)/.test(sidebar), "AI sidebar should send the trimmed question to AI help");
assert(/onMounted\(/.test(component) && /watch\(\s*\(\)\s*=>\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");

Loading…
Cancel
Save