feat: 参考答案推送开关与学生首页成绩展示
- 任务页(实训任务管理)增加参考答案推送开关,推送后学生端可见 - 学生首页成绩区同步展示AI评分与老师评分 - 静态测试同步更新dev-QQq
parent
efd1679952
commit
d28e896b86
@ -0,0 +1,39 @@
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const apiSource = fs.readFileSync(path.join(root, "src/api/AI.js"), "utf8");
|
||||
const dialogueSource = fs.readFileSync(path.join(root, "src/views/analysis-of-students/dialogue.vue"), "utf8");
|
||||
const indexApiSource = fs.readFileSync(path.join(root, "src/api/index.js"), "utf8");
|
||||
const projectStudyTimeSource = fs.readFileSync(path.join(root, "src/api/projectStudyTime.js"), "utf8");
|
||||
|
||||
test("learning analysis api treats AI service error text as failure", () => {
|
||||
const requestBlock = apiSource.match(/export function getLearningAnalysis[\s\S]*?\n}/)?.[0] || "";
|
||||
assert.match(requestBlock, /\^error\\b\/i/);
|
||||
assert.match(requestBlock, /throw new Error\(text\)/);
|
||||
});
|
||||
|
||||
test("dialogue page falls back to the AI chat channel with the same learning data", () => {
|
||||
assert.match(dialogueSource, /openAssistantStream/);
|
||||
const fallbackBlock = dialogueSource.match(/专用学情分析接口不可用时[\s\S]*?openAssistantStream\([\s\S]*?\);/)?.[0] || "";
|
||||
assert.match(fallbackBlock, /stuNeed/);
|
||||
assert.match(fallbackBlock, /JSON\.stringify\(stuData\)/);
|
||||
});
|
||||
|
||||
test("kimi4 stream requests fail loudly on non-2xx responses", () => {
|
||||
assert.match(dialogueSource, /if \(!resp\.ok \|\| !resp\.body\)/);
|
||||
});
|
||||
|
||||
test("sendMessage never leaves the pending state stuck", () => {
|
||||
const sendBlock = dialogueSource.match(/const sendMessage = async \(\) => \{[\s\S]*?\n};/)?.[0] || "";
|
||||
assert.match(sendBlock, /finally\s*\{\s*isRequestPending\.value = false/);
|
||||
});
|
||||
|
||||
test("score apis suppress duplicate interceptor toasts", () => {
|
||||
const reportBlock = indexApiSource.match(/export const getCurrentExperimentReport[\s\S]*?\n}/)?.[0] || "";
|
||||
const studyTimeBlock = projectStudyTimeSource.match(/export function getCurrentProjectStudyTime[\s\S]*?\n}/)?.[0] || "";
|
||||
assert.match(reportBlock, /skipErrorMessage:\s*true/);
|
||||
assert.match(studyTimeBlock, /skipErrorMessage:\s*true/);
|
||||
});
|
||||
@ -0,0 +1,22 @@
|
||||
const assert = require("assert");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const editor = fs.readFileSync(
|
||||
path.join(root, "src/views/teacherEnd/trainingTask/index.vue"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
assert(/key: "referenceAnswer",\s*label: "参考答案"/.test(editor));
|
||||
assert(/accept: "\.doc,\.docx/.test(editor), "reference answers should expose Word file types");
|
||||
assert(/referenceAnswerName: ""/.test(editor));
|
||||
assert(/referenceAnswerUrl: ""/.test(editor));
|
||||
assert(/referenceAnswerName: referenceAnswer\.name/.test(editor));
|
||||
assert(/referenceAnswerUrl: referenceAnswer\.url/.test(editor));
|
||||
assert(/referenceAnswerName: taskForm\.referenceAnswerName/.test(editor));
|
||||
assert(/referenceAnswerUrl: taskForm\.referenceAnswerUrl/.test(editor));
|
||||
assert(/slotKey === "referenceAnswer" && !isWordFile\(rawFile\)/.test(editor));
|
||||
assert(/name\.endsWith\("\.doc"\) \|\| name\.endsWith\("\.docx"\)/.test(editor));
|
||||
|
||||
console.log("teacher reference-answer upload contract passed");
|
||||
Loading…
Reference in New Issue