From f165c79ce81b7f96cf5a0881671a8e0f36ce1f59 Mon Sep 17 00:00:00 2001 From: litian <2804272236@qq.com> Date: 星期五, 24 一月 2025 10:51:33 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/testbookLayout --- src/assets/methods/examination.js | 77 +++++++++++++++++++++++++++++++------- 1 files changed, 62 insertions(+), 15 deletions(-) diff --git a/src/assets/methods/examination.js b/src/assets/methods/examination.js index 5950571..742e446 100644 --- a/src/assets/methods/examination.js +++ b/src/assets/methods/examination.js @@ -1,33 +1,48 @@ import MG from "@/assets/js/middleGround/WebMiddleGroundApi"; +import { tokenKey } from "@/assets/js/config"; import getPublicImage from "@/assets/js/middleGround/tool"; -const getQuestionList = async (oldList, questionList,activeBook) => { +// 鑾峰彇棰樼洰鍒楄〃 +const getQuestionList = async (page, questionList, activeBook) => { + const token = localStorage.getItem(tokenKey); + let collectList = []; + if (token) collectList = await getCollectList(activeBook); + 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 = []; // 濉┖ + // 11 for (let qindex = 0; qindex < questionList.length; qindex++) { const qitem = questionList[qindex]; let query = { @@ -47,10 +62,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) { @@ -85,8 +101,8 @@ isSubmit: false, // 鏌ョ湅瑙f瀽 isRight: null, // 鏄惁姝g‘ isComplete: false, - isCollect: true, - isUnfold: "" + isCollect: collectList.indexOf(qitem) > -1 ? true : false, + isUnfold: "", }; // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡 if ( @@ -107,7 +123,7 @@ if (item == "input") { questionObj.stem[i] = { num: index, - data: "input" + data: "input", }; questionObj.userAnswer[index] = ""; index++; @@ -195,6 +211,7 @@ } }); } + // 22 cardList[0].infoList = singleChoiceArr; cardList[1].infoList = judgeArr; cardList[2].infoList = multipleChoiceArr; @@ -209,8 +226,38 @@ } return cardList.filter((item) => item.infoList.length > 0); }; - -const getQuestionData = async (chapter, chapterData,activeBook) => { +// 鑾峰彇鏀惰棌鍒楄〃 +const getCollectList = async (activeBook) => { + const allCollect = [ + { + type: "bits", + collectList: [], + }, + { + type: "json", + collectList: [], + }, + ]; + const res = await MG.identity.getUserKey({ + domain: "collectData", + keys: [activeBook.bookId], + }); + try { + const collect = JSON.parse(res[0].value); + if (collect.length) { + allCollect[0].collectList = collect.find( + (citem) => citem.type == "bits" + ).collectList; + allCollect[1].collectList = collect.find( + (citem) => citem.type == "json" + ).collectList; + } + } catch (error) { + console.log("鏆傛棤鏁版嵁"); + } + return allCollect.find((item) => item.type == "bits").collectList; +}; +const getQuestionData = async (chapter, chapterData, activeBook) => { const data = { ...chapterData }; const oldAnswerData = localStorage.getItem("oldAnswerData"); const oldData = oldAnswerData ? JSON.parse(oldAnswerData) : {}; @@ -223,7 +270,7 @@ if (oldChapterData) { oldList = oldChapterData[key]; } - data[key] = await getQuestionList(oldList, chapterData[key],activeBook); + data[key] = await getQuestionList(oldList, chapterData[key], activeBook); } return data; }; -- Gitblit v1.9.1