From d76a5555a5f423dbcaa082619c00ab55a0912884 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 25 六月 2024 09:26:38 +0800
Subject: [PATCH] 拖拽题优化

---
 src/assets/methods/examination.js |   44 ++++++++++++++++++++++++++++----------------
 1 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/src/assets/methods/examination.js b/src/assets/methods/examination.js
index ea886c5..0da5175 100644
--- a/src/assets/methods/examination.js
+++ b/src/assets/methods/examination.js
@@ -1,38 +1,48 @@
-import { activeBook } from "@/assets/js/config";
 import MG from "@/assets/js/middleGround/WebMiddleGroundApi";
 import getPublicImage from "@/assets/js/middleGround/tool";
-const getQuestionList = async (oldList, questionList) => {
+const getQuestionList = async (page, questionList, activeBook) => {
+  console.log("page", page);
+  const oldAnswerData = localStorage.getItem(activeBook.name + "oldAnswerData");
+  let oldData = null;
+  let oldList = [];
+  if (oldAnswerData) {
+    oldData = JSON.parse(oldAnswerData);
+  }
+  if (oldData && oldData[page]) {
+    oldList = oldData[page];
+  }
   let cardList = [
     {
       catalogName: "鍗曢�夐",
-      infoList: []
+      infoList: [],
     },
     {
       catalogName: "鍒ゆ柇棰�",
-      infoList: []
+      infoList: [],
     },
     {
       catalogName: "澶氶�夐",
-      infoList: []
+      infoList: [],
     },
     {
       catalogName: "濉┖棰�",
-      infoList: []
+      infoList: [],
     },
     {
       catalogName: "绠�绛旈",
-      infoList: []
-    }
+      infoList: [],
+    },
   ];
   let singleChoiceArr = []; // 鍗曢��
   let judgeArr = []; // 鍒ゆ柇
   let shortArr = []; // 绠�绛�
   let multipleChoiceArr = []; // 澶氶��
   let completionArr = []; // 濉┖
-  console.log("active", activeBook);
+  // 11
   for (let qindex = 0; qindex < questionList.length; qindex++) {
     const qitem = questionList[qindex];
     let query = {
+      storeInfo: activeBook.storeRefcode,
       path: "*",
       cmsPath: activeBook.rootCmsItemId,
       cmsType: "*",
@@ -48,10 +58,11 @@
         Embedded_QuestionBank_StemStyle: [],
         Embedded_QuestionBank_OptionStyle: [],
         Embedded_QuestionBank_KnowledgePoint: [],
-        Embedded_QuestionBank_Difficulty: []
-      }
+        Embedded_QuestionBank_Difficulty: [],
+      },
     };
     const res = await MG.store.getProductDetail(query);
+    if (!res.datas) return false;
     res.datas.cmsDatas[0].datas.forEach((item, index) => {
       let oldObj = {};
       if (oldList) {
@@ -87,7 +98,7 @@
         isRight: null, // 鏄惁姝g‘
         isComplete: false,
         isCollect: true,
-        isUnfold: ""
+        isUnfold: "",
       };
       // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡
       if (
@@ -108,7 +119,7 @@
           if (item == "input") {
             questionObj.stem[i] = {
               num: index,
-              data: "input"
+              data: "input",
             };
             questionObj.userAnswer[index] = "";
             index++;
@@ -196,6 +207,7 @@
       }
     });
   }
+  // 22
   cardList[0].infoList = singleChoiceArr;
   cardList[1].infoList = judgeArr;
   cardList[2].infoList = multipleChoiceArr;
@@ -211,7 +223,7 @@
   return cardList.filter((item) => item.infoList.length > 0);
 };
 
-const getQuestionData = async (chapter, chapterData) => {
+const getQuestionData = async (chapter, chapterData, activeBook) => {
   const data = { ...chapterData };
   const oldAnswerData = localStorage.getItem("oldAnswerData");
   const oldData = oldAnswerData ? JSON.parse(oldAnswerData) : {};
@@ -224,9 +236,9 @@
     if (oldChapterData) {
       oldList = oldChapterData[key];
     }
-    data[key] = await getQuestionList(oldList, chapterData[key]);
+    data[key] = await getQuestionList(oldList, chapterData[key], activeBook);
   }
   return data;
 };
 
-export default getQuestionData;
+export default getQuestionList;

--
Gitblit v1.9.1