|
|
@@ -85,17 +85,8 @@ const aiBatchCorrectionBtn = (item, aiBatchCorrection) => {
|
|
|
const _test = [];
|
|
|
|
|
|
testjson.forEach((w) => {
|
|
|
- if (w.tool === "choice") {
|
|
|
- work.score[w.id] = 0;
|
|
|
- if (w.answer && _work[w.id]) {
|
|
|
- const correctAnswer = JSON.stringify([...w.answer].sort());
|
|
|
- const userAnswer = JSON.stringify([...(_work[w.id] || [])].sort());
|
|
|
- work.score[w.id] = correctAnswer === userAnswer ? w.score : 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
_test.push(w);
|
|
|
work.score[w.id] = 0;
|
|
|
- }
|
|
|
});
|
|
|
|
|
|
aiBatchCorrection.push({
|
|
|
@@ -182,7 +173,7 @@ const aiGradingBatchCorrection = async (aiBatchCorrection, val) => {
|
|
|
figure_image_urls: _imgSrc,
|
|
|
},
|
|
|
student_file_urls: Array.isArray(_userAnswer) ? _userAnswer.map((u) => u.url) : [],
|
|
|
- student_answer_text: ["fill", "qa"].includes(val.test[i].tool) ? (_userAnswer ? _userAnswer :'暂无数据') : "",
|
|
|
+ student_answer_text: ["fill", "qa", "choice"].includes(val.test[i].tool) ? _userAnswer : "",
|
|
|
model: "gpt-5.4",
|
|
|
};
|
|
|
|
|
|
@@ -361,7 +352,19 @@ const loadAgents = async () => {
|
|
|
agent2a = outlineRes.data;
|
|
|
};
|
|
|
|
|
|
-const callAgentChat = async (agent, message, userId, stepName = "Agent") => {
|
|
|
+const updateSpaceAnalyzeStatus = async (spaceId, isl) => {
|
|
|
+ try {
|
|
|
+ await callMysqlProc("updatespaceisanalyze", {
|
|
|
+ sid: spaceId,
|
|
|
+ isl,
|
|
|
+ });
|
|
|
+ console.log("[cocostudy] updatespaceisanalyze", { spaceId, isl });
|
|
|
+ } catch (err) {
|
|
|
+ console.error("[cocostudy] updatespaceisanalyze err", err.message || err);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const callAgentChat = async (agent, message, userId, stepName = "Agent", spaceId) => {
|
|
|
let lastErr;
|
|
|
for (let attempt = 1; attempt <= GRADE_RETRY_TIMES; attempt++) {
|
|
|
try {
|
|
|
@@ -398,6 +401,9 @@ const callAgentChat = async (agent, message, userId, stepName = "Agent") => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (spaceId) {
|
|
|
+ await updateSpaceAnalyzeStatus(spaceId, 2);
|
|
|
+ }
|
|
|
throw lastErr;
|
|
|
};
|
|
|
|
|
|
@@ -463,7 +469,8 @@ async function generateErrorAnalysis(quizSummary, userId, spaceId) {
|
|
|
agent1a,
|
|
|
`题目数据:\n${JSON.stringify(quizSummary)}`,
|
|
|
userId,
|
|
|
- "错因分析"
|
|
|
+ "错因分析",
|
|
|
+ spaceId
|
|
|
);
|
|
|
const errorAnalysis = parseAgentJsonMessage(raw);
|
|
|
await generateLectureOutline(quizSummary, errorAnalysis, userId, spaceId);
|
|
|
@@ -474,7 +481,8 @@ async function generateLectureOutline(quizSummary, errorAnalysis, userId, spaceI
|
|
|
agent2a,
|
|
|
`==\n## 统计性信息如下:\n${JSON.stringify(quizSummary)}\n\n==\n\n## 错题深度分析如下:\n${JSON.stringify(errorAnalysis)}`,
|
|
|
userId,
|
|
|
- "讲义大纲"
|
|
|
+ "讲义大纲",
|
|
|
+ spaceId
|
|
|
);
|
|
|
await generatedetailedExplanation(quizSummary, errorAnalysis, lectureOutline, userId, spaceId);
|
|
|
}
|
|
|
@@ -489,17 +497,9 @@ async function generatedetailedExplanation(quizSummary, errorAnalysis, lectureOu
|
|
|
"\n生成的Agenda顺序:" +
|
|
|
JSON.stringify(lectureOutline);
|
|
|
|
|
|
- const answer = await callAgentChat(agent_data2, displayContent, userId, "详细讲解");
|
|
|
+ const answer = await callAgentChat(agent_data2, displayContent, userId, "详细讲解", spaceId);
|
|
|
await insertChat(answer, spaceId, userId);
|
|
|
-
|
|
|
- try {
|
|
|
- await callMysqlProc("updatespaceisanalyze", {
|
|
|
- sid: spaceId,
|
|
|
- isl: 1,
|
|
|
- });
|
|
|
- } catch (err) {
|
|
|
- console.error("[cocostudy] updatespaceisanalyze err", err.message || err);
|
|
|
- }
|
|
|
+ await updateSpaceAnalyzeStatus(spaceId, 1);
|
|
|
|
|
|
console.log("[cocostudy] 错题分析完成", { userId, spaceId });
|
|
|
}
|
|
|
@@ -526,13 +526,13 @@ async function insertChat(answer, spaceId, userId) {
|
|
|
|
|
|
|
|
|
// 定时任务:每10分钟触发一次
|
|
|
-schedule.scheduleJob("*/10 * * * *", async () => {
|
|
|
- try {
|
|
|
- await runAutoScoSafe();
|
|
|
- } catch (error) {
|
|
|
- console.error("[cocostudy] 定时任务异常", error.message || error);
|
|
|
- }
|
|
|
-});
|
|
|
+// schedule.scheduleJob("*/10 * * * *", async () => {
|
|
|
+// try {
|
|
|
+// await runAutoScoSafe();
|
|
|
+// } catch (error) {
|
|
|
+// console.error("[cocostudy] 定时任务异常", error.message || error);
|
|
|
+// }
|
|
|
+// });
|
|
|
|
|
|
// 手动触发:GET/POST /api/cocostudy/autosco
|
|
|
router.all("/autosco", async (req, res) => {
|