From e8f418421e7e6305db2ffc0516a555f04510d2e7 Mon Sep 17 00:00:00 2001 From: YM <479443481@qq.com> Date: 星期三, 22 五月 2024 21:41:46 +0800 Subject: [PATCH] 1 --- src/assets/methods/examination.js | 83 +++++++++++++++++++++-------------------- 1 files changed, 42 insertions(+), 41 deletions(-) diff --git a/src/assets/methods/examination.js b/src/assets/methods/examination.js index a1dffd6..3e059f9 100644 --- a/src/assets/methods/examination.js +++ b/src/assets/methods/examination.js @@ -1,37 +1,39 @@ -import { activeBook } from "@/assets/js/config"; +import { activeBook, goodsStore } 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 (oldList, questionList) => { 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); for (let qindex = 0; qindex < questionList.length; qindex++) { const qitem = questionList[qindex]; let query = { + storeInfo: goodsStore, path: "*", cmsPath: activeBook.rootCmsItemId, cmsType: "*", @@ -47,14 +49,14 @@ Embedded_QuestionBank_StemStyle: [], Embedded_QuestionBank_OptionStyle: [], Embedded_QuestionBank_KnowledgePoint: [], - Embedded_QuestionBank_Difficulty: [], - }, + Embedded_QuestionBank_Difficulty: [] + } }; 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) + let oldObj = {}; + if (oldList) { + oldObj = oldList.find((item) => item.id == qitem); } const questionObj = { number: index + 1, // 棰樺彿 @@ -76,16 +78,17 @@ difficulty: item.Embedded_QuestionBank_Difficulty ? 4 - item.Embedded_QuestionBank_Difficulty : 0, // 闅惧害绛夌骇 - userAnswer:oldObj ? oldObj.userAnswer : - item.Embedded_QuestionBank_QuestionType == "completion" || - item.Embedded_QuestionBank_QuestionType == "multipleChoice" - ? [] - : "", + userAnswer: oldObj + ? oldObj.userAnswer + : item.Embedded_QuestionBank_QuestionType == "completion" || + item.Embedded_QuestionBank_QuestionType == "multipleChoice" + ? [] + : "", isSubmit: false, // 鏌ョ湅瑙f瀽 isRight: null, // 鏄惁姝g‘ isComplete: false, isCollect: true, - isUnfold: "", + isUnfold: "" }; // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡 if ( @@ -106,7 +109,7 @@ if (item == "input") { questionObj.stem[i] = { num: index, - data: "input", + data: "input" }; questionObj.userAnswer[index] = ""; index++; @@ -141,7 +144,7 @@ '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ' ) .replace(/\<p/gi, '<p class="stem-rich-p"') - .replace("../file", app.config.requestCtx + "/file"); + .replace("../file", process.env.VUE_APP_API_URL + "/file"); } // 閫夐」瀵屾枃鏈鐞� if ( @@ -155,7 +158,7 @@ item.txt = item.txt .replace(/\<img/gi, '<img class="option-rich-img"') .replace(/\<p/gi, '<p class="stem-rich-p"') - .replace("../file", app.config.requestCtx + "/file"); + .replace("../file", process.env.VUE_APP_API_URL + "/file"); }); } // 瑙f瀽瀵屾枃鏈鐞� @@ -182,9 +185,7 @@ } else if (item.Embedded_QuestionBank_QuestionType == "singleChoice") { questionObj.type = "鍗曢�夐"; singleChoiceArr.push(questionObj); - } else if ( - item.Embedded_QuestionBank_QuestionType == "multipleChoice" - ) { + } else if (item.Embedded_QuestionBank_QuestionType == "multipleChoice") { questionObj.type = "澶氶�夐"; multipleChoiceArr.push(questionObj); } else if (item.Embedded_QuestionBank_QuestionType == "completion") { @@ -196,11 +197,11 @@ } }); } - cardList[0].infoList = singleChoiceArr - cardList[1].infoList = judgeArr - cardList[2].infoList = multipleChoiceArr - cardList[3].infoList = completionArr - cardList[4].infoList = shortArr + cardList[0].infoList = singleChoiceArr; + cardList[1].infoList = judgeArr; + cardList[2].infoList = multipleChoiceArr; + cardList[3].infoList = completionArr; + cardList[4].infoList = shortArr; for (let index = 0; index < cardList.length; index++) { const item = cardList[index]; for (let cindex = 0; cindex < item.infoList.length; cindex++) { @@ -208,23 +209,23 @@ citem.number = cindex + 1; } } - return cardList.filter(item=>item.infoList.length > 0); + return cardList.filter((item) => item.infoList.length > 0); }; -const getQuestionData = async (chapter,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] + const oldAnswerData = localStorage.getItem("oldAnswerData"); + const oldData = oldAnswerData ? JSON.parse(oldAnswerData) : {}; + let oldChapterData; + if (oldData) { + oldChapterData = oldData[chapter]; } for (let key in chapterData) { - let oldList = [] - if(oldChapterData) { - oldList = oldChapterData[key] + let oldList = []; + if (oldChapterData) { + oldList = oldChapterData[key]; } - data[key] = await getQuestionList(oldList,chapterData[key]); + data[key] = await getQuestionList(oldList, chapterData[key]); } return data; }; -- Gitblit v1.9.1