Ver código fonte

自主学习还原

11wqe1 2 semanas atrás
pai
commit
26d16e942e
1 arquivos alterados com 16 adições e 24 exclusões
  1. 16 24
      cocostudy.js

+ 16 - 24
cocostudy.js

@@ -84,7 +84,8 @@ const aiBatchCorrectionBtn = (item, aiBatchCorrection) => {
   };
   const _test = [];
 
-    testjson.forEach((w) => { if (w.tool === "choice") {
+  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());
@@ -181,7 +182,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"].includes(val.test[i].tool) ? (_userAnswer ? _userAnswer :'暂无数据') : "",
       model: "gpt-5.4",
     };
 
@@ -360,19 +361,7 @@ const loadAgents = async () => {
   agent2a = outlineRes.data;
 };
 
-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) => {
+const callAgentChat = async (agent, message, userId, stepName = "Agent") => {
   let lastErr;
   for (let attempt = 1; attempt <= GRADE_RETRY_TIMES; attempt++) {
     try {
@@ -409,9 +398,6 @@ const callAgentChat = async (agent, message, userId, stepName = "Agent", spaceId
       }
     }
   }
-  if (spaceId) {
-    await updateSpaceAnalyzeStatus(spaceId, 2);
-  }
   throw lastErr;
 };
 
@@ -477,8 +463,7 @@ async function generateErrorAnalysis(quizSummary, userId, spaceId) {
     agent1a,
     `题目数据:\n${JSON.stringify(quizSummary)}`,
     userId,
-    "错因分析",
-    spaceId
+    "错因分析"
   );
   const errorAnalysis = parseAgentJsonMessage(raw);
   await generateLectureOutline(quizSummary, errorAnalysis, userId, spaceId);
@@ -489,8 +474,7 @@ 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);
 }
@@ -505,9 +489,17 @@ async function generatedetailedExplanation(quizSummary, errorAnalysis, lectureOu
     "\n生成的Agenda顺序:" +
     JSON.stringify(lectureOutline);
 
-  const answer = await callAgentChat(agent_data2, displayContent, userId, "详细讲解", spaceId);
+  const answer = await callAgentChat(agent_data2, displayContent, userId, "详细讲解");
   await insertChat(answer, spaceId, userId);
-  await updateSpaceAnalyzeStatus(spaceId, 1);
+
+  try {
+    await callMysqlProc("updatespaceisanalyze", {
+      sid: spaceId,
+      isl: 1,
+    });
+  } catch (err) {
+    console.error("[cocostudy] updatespaceisanalyze err", err.message || err);
+  }
 
   console.log("[cocostudy] 错题分析完成", { userId, spaceId });
 }