From 7ea1bc543cd9ad231122d3882ee917d93bb975dc Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期一, 25 三月 2024 09:49:52 +0800 Subject: [PATCH] 图书详情,答题器bug修改 --- packageBookService/pages/bookServices/examination/examination.js | 158 ++++++---------------------------------------------- 1 files changed, 18 insertions(+), 140 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index d99f15b..e444433 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -90,6 +90,11 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ onShow() { + if (this.data.answerType != 'mock') { + if (wx.timer) { + clearInterval(wx.timer) + } + } if (this.data.answerType == 'mock') { if (wx.timer) { clearInterval(wx.timer) @@ -109,12 +114,18 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 */ onHide() { + if (wx.timer) { + clearInterval(wx.timer) + } }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 */ onUnload(e) { + if (wx.timer) { + clearInterval(wx.timer) + } if (this.data.countdownInterval !== null) { clearInterval(this.data.countdownInterval) } @@ -458,18 +469,19 @@ let oldQuestionList = [] oldQuestionList = await this.getMockQuestionList() const userAnswerList = await this.getMockAnswer() - await this.getMockDataList(oldQuestionList, userAnswerList) this.setData({ 'mockData.sumTime': oldMockData.time, cardList: oldQuestionList }) + await this.getMockDataList(oldQuestionList, userAnswerList) } if (oldMockData.state == '0' || oldMockData.state == '1' || oldMockData.state == '2') { this.startCountdown() } if (oldMockData.state == '3') { this.setData({ - submitStatus: true + submitStatus: true, + subjectiveNum: oldMockData.report.userScore }) } } @@ -1389,141 +1401,8 @@ // 鑾峰彇缁勫嵎棰樼洰鍒楄〃 async getMockDataList(questionList, oldList) { const questionDataList = this.data.questionDataList - // for (let pathindex = 0; pathindex < questionList.length; pathindex++) { - // const pathitem = questionList[pathindex]; - // let itemIds = [] - // pathitem.infoList.forEach(item => { - // itemIds.push(item.id + '') - // }) - // let query = { - // path: '*', - // cmsPath: this.data.rootCmsItemId, - // cmsType: '*', - // productId: this.data.bookId, - // queryType: '*', - // itemIds, - // itemFields: { - // Embedded_QuestionBank_Stem: [], - // Embedded_QuestionBank_AnalysisCon: [], - // Embedded_QuestionBank_Answer: [], - // Embedded_QuestionBank_Option: [], - // Embedded_QuestionBank_QuestionType: [], - // Embedded_QuestionBank_StemStyle: [], - // Embedded_QuestionBank_OptionStyle: [], - // Embedded_QuestionBank_KnowledgePoint: [], - // Embedded_QuestionBank_Difficulty: [] - // } - // } - // await app.MG.store.getProductDetail(query).then((res) => { - // res.datas.cmsDatas[0].datas.forEach((item, index) => { - // // 寰幆questionList,缁欐瘡棰樿祴鍊煎垎鏁� - // let oldObj - // if (oldList) oldObj = oldList.find((oldItem) => oldItem.id == item.id) - // let questionObj = { - // // number: pathitem.infoList.find(infoItem => infoItem.itemId == item.id).number, - // id: item.id, - // score: pathitem.infoList.find(infoItem => infoItem.id == item.id).score, - // stem: - // item.Embedded_QuestionBank_QuestionType == 'completion' - // ? JSON.parse(item.Embedded_QuestionBank_Stem) - // .stemTxt.replaceAll('<vacancy>', ',input,') - // .split(',') - // : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 - // answer: item.Embedded_QuestionBank_Answer, // 绛旀 - // option: item.Embedded_QuestionBank_Option - // ? JSON.parse(item.Embedded_QuestionBank_Option) - // : '', // 閫夋嫨棰橀�夐」 - // analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽 - // questionType: item.Embedded_QuestionBank_QuestionType, // 棰樺瀷 - // optionStyle: item.Embedded_QuestionBank_OptionStyle, // 閫夐」鏄剧ず绫诲瀷 - // stemStyle: item.Embedded_QuestionBank_StemStyle, // 棰樺共鏄剧ず绫诲瀷 - // difficulty: item.Embedded_QuestionBank_Difficulty - // ? 4 - item.Embedded_QuestionBank_Difficulty - // : 0, // 闅惧害绛夌骇 - // userAnswer: oldObj - // ? oldObj.answer - // : item.Embedded_QuestionBank_QuestionType == 'completion' || - // item.Embedded_QuestionBank_QuestionType == 'multipleChoice' - // ? [] - // : '', - // isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false, - // isRight: oldObj ? oldObj.isRight : null, - // // isComplete: oldObj ? oldObj.isComplete : false, - // isComplete: this.data.mockData.state == '3' ? true : oldObj ? this.isHaveAnswer(oldObj.answer) : false, - // isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false, - // isUnfold: '' // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮� - // } - // // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡 - // if ( - // questionObj.questionType == 'completion' || - // questionObj.questionType == 'multipleChoice' - // ) { - // try { - // questionObj.answer = JSON.parse(questionObj.answer) - // } catch (error) { - // questionObj.answer = item.Embedded_QuestionBank_Answer - // } - // } - // // 濉┖棰樻敼閫� - // if (questionObj.questionType == 'completion') { - // let index = 0 - // for (let i = 0; i < questionObj.stem.length; i++) { - // const item = questionObj.stem[i] - // if (item == 'input') { - // questionObj.stem[i] = { - // num: index, - // data: 'input' - // } - // if (!oldObj) questionObj.userAnswer[index] = '' - // index++ - // } - // } - // } - // // 鑾峰彇鍥剧墖 - // if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { - // questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) - // } - // if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { - // questionObj.option.forEach(optionItem => { - // if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) - // }) - // } - // if (oldObj && oldObj.isRight) { - // this.setData({ - // correctNum: this.data.correctNum + 1 - // }) - // } - // if (item.questionType != 'shortAnswer' && item.isComplete) { - // this.setData({ - // subjectiveTotal: this.data.subjectiveTotal + 1 - // }) - // } - // // if (oldObj && isHaveAnswer(oldObj.answer)) countDownRef.value.changeAlready() - // // cardList璧嬪�� - // let cardIndex = this.data.cardList.findIndex((item) => item.catalogName == pathitem.catalogName) - // debugger - // let infoIndex = this.data.cardList[cardIndex].infoList.findIndex(infoItem => infoItem.id == item.id) - - // this.setData({ - // [`cardList[${cardIndex}].infoList[${infoIndex}]`]: questionObj - // }) - // let questionList = [] - // const cardUpdatedList = this.data.cardList - // cardUpdatedList.forEach(aitem => { - // aitem.infoList.forEach((bitem, bindex) => { - // questionList.push(bitem) - // bitem.number = bindex + 1 - // }) - // }) - // this.setData({ - // questionDataList: questionList, - // cardList: cardUpdatedList - // }) - // console.log('缁勫嵎棰樼洰鍒楄〃', this.data.questionDataList); - // }) - // }) - // } - questionList.forEach(async (pathitem, pathindex) => { + for (let pathindex = 0; pathindex < questionList.length; pathindex++) { + const pathitem = questionList[pathindex]; let itemIds = [] pathitem.infoList.forEach(item => { itemIds.push(item.id + '') @@ -1582,7 +1461,7 @@ isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false, isRight: oldObj ? oldObj.isRight : null, // isComplete: oldObj ? oldObj.isComplete : false, - isComplete: this.data.mockData.state == '3' ? true : oldObj ? this.isHaveAnswer(oldObj.answer) : false, + isComplete: this.data.mockData.state == '3' ? true : false, isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false, isUnfold: '' // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮� } @@ -1650,10 +1529,9 @@ questionDataList: questionList, cardList: cardUpdatedList }) - console.log('缁勫嵎棰樼洰鍒楄〃', this.data.questionDataList); }) }) - }) + } this.setData({ loading: false }) -- Gitblit v1.9.1