From b636ce580856ae22a09ea126ae0e53539d699246 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期五, 17 五月 2024 15:04:43 +0800
Subject: [PATCH] 页眉、ui替换

---
 src/assets/methods/examination.js |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/assets/methods/examination.js b/src/assets/methods/examination.js
index dd275f7..a1dffd6 100644
--- a/src/assets/methods/examination.js
+++ b/src/assets/methods/examination.js
@@ -1,7 +1,7 @@
 import { activeBook } from "@/assets/js/config";
 import MG from "@/assets/js/middleGround/WebMiddleGroundApi";
 import getPublicImage from "@/assets/js/middleGround/tool";
-const getQuestionList = async (questionList) => {
+const getQuestionList = async (oldList,questionList) => {
   let cardList = [
     {
       catalogName: "鍗曢�夐",
@@ -52,6 +52,10 @@
     };
     const res = await MG.store.getProductDetail(query);
     res.datas.cmsDatas[0].datas.forEach((item, index) => {
+      let oldObj = {}
+      if(oldList) {
+        oldObj = oldList.find(item => item.id == qitem)
+      }
       const questionObj = {
         number: index + 1, // 棰樺彿
         id: item.id,
@@ -72,7 +76,7 @@
         difficulty: item.Embedded_QuestionBank_Difficulty
           ? 4 - item.Embedded_QuestionBank_Difficulty
           : 0, // 闅惧害绛夌骇
-        userAnswer:
+        userAnswer:oldObj ? oldObj.userAnswer :
           item.Embedded_QuestionBank_QuestionType == "completion" ||
           item.Embedded_QuestionBank_QuestionType == "multipleChoice"
             ? []
@@ -204,14 +208,23 @@
       citem.number = cindex + 1;
     }
   }
-  console.log(cardList.filter(item=>item.infoList.length > 0),"cardList.filter(item=>item.infoList.length > 0)");
   return cardList.filter(item=>item.infoList.length > 0);
 };
 
-const getQuestionData = async (chapterData) => {
+const getQuestionData = async (chapter,chapterData) => {
   const data = { ...chapterData };
+  const oldAnswerData =  localStorage.getItem('oldAnswerData')
+  const oldData = oldAnswerData ? JSON.parse(oldAnswerData) :{}
+  let oldChapterData
+  if(oldData) {
+    oldChapterData = oldData[chapter]
+  }
   for (let key in chapterData) {
-    data[key] = await getQuestionList(chapterData[key]);
+    let oldList = []
+    if(oldChapterData) {
+      oldList = oldChapterData[key]
+    }
+    data[key] = await getQuestionList(oldList,chapterData[key]);
   }
   return data;
 };

--
Gitblit v1.9.1