| | |
| | | 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: "单选题", |
| | |
| | | let shortArr = []; // 简答 |
| | | let multipleChoiceArr = []; // 多选 |
| | | let completionArr = []; // 填空 |
| | | console.log('active',activeBook); |
| | | for (let qindex = 0; qindex < questionList.length; qindex++) { |
| | | const qitem = questionList[qindex]; |
| | | let query = { |
| | |
| | | }; |
| | | 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, |
| | |
| | | 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" |
| | | ? [] |
| | |
| | | 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; |
| | | }; |