From 986d4798a9dad75b6ae617e52ea2918dfacd3708 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期五, 22 三月 2024 11:19:34 +0800 Subject: [PATCH] 图书详情、答题器bug修改 --- packageBookService/pages/bookServices/examination/examination.js | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 167 insertions(+), 13 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index 3bec06c..d99f15b 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -258,8 +258,18 @@ item.isUserAnswer = this.isHaveAnswer(radioChecked) } }) + const cardListUpdata = this.data.cardList + cardListUpdata.forEach(item => { + item.infoList.forEach(citem => { + if (citem.id == id) { + citem.userAnswer = radioChecked + citem.isUserAnswer = this.isHaveAnswer(radioChecked) + } + }) + }) this.setData({ - questionDataList: questionList + questionDataList: questionList, + cardList: cardListUpdata }) if (this.data.answerType == 'mock') { this.setData({ @@ -271,16 +281,27 @@ onChangeInput(e) { const inputData = e.detail.value.detail.value const id = e.detail.value.currentTarget.dataset.id - const index = e.detail.value.currentTarget.dataset.index + const index = Number(e.detail.value.currentTarget.dataset.index) + console.log(index); const questionList = this.data.questionDataList questionList.forEach(item => { if (item.id == id) { - item.userAnswer[index] = inputData, - item.isUserAnswer = this.isHaveAnswer(item.userAnswer) + item.userAnswer[index] = inputData + return item.isUserAnswer = this.isHaveAnswer(inputData) } }) + const cardListUpdata = this.data.cardList + cardListUpdata.forEach(item => { + item.infoList.forEach(citem => { + if (citem.id == id) { + citem.userAnswer[index] = inputData + return citem.isUserAnswer = this.isHaveAnswer(inputData) + } + }) + }) this.setData({ - questionDataList: questionList + questionDataList: questionList, + cardList: cardListUpdata, }) if (this.data.answerType == 'mock') { this.setData({ @@ -563,19 +584,19 @@ errorList: JSON.parse(res[0].value) }) } catch (error) { - } }) }, // 鑾峰彇棰樺簱棰樼洰 - getQuestionList(oldData) { + async getQuestionList(oldData) { // 娓呯┖姝g‘棰樻暟璁板綍 this.setData({ cardList: [], correctNum: 0, }) let flag = 0 - this.data.idPathList.forEach((pathitem) => { + for (let index = 0; index < this.data.idPathList.length; index++) { + const pathitem = this.data.idPathList[index]; const pathList = this.data.cardList pathList.push({ path: pathitem.productLinkPath, @@ -608,7 +629,7 @@ size: 999 } } - app.MG.store.getProductDetail(query).then((res) => { + await app.MG.store.getProductDetail(query).then((res) => { this.setData({ total: res.datas.cmsDatas[0].datas.length }) @@ -738,13 +759,13 @@ }) this.setData({ questionDataList: questionList, - cardList: cardUpdatedList + cardList: cardUpdatedList, }) }) }) - }) + } this.setData({ - loading: false, + loading: false }) }, // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘�,锛岀粍鍗凤級 @@ -1368,6 +1389,140 @@ // 鑾峰彇缁勫嵎棰樼洰鍒楄〃 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) => { let itemIds = [] pathitem.infoList.forEach(item => { @@ -1500,7 +1655,6 @@ }) }) this.setData({ - // questionDataList: questionDataList, loading: false }) }, -- Gitblit v1.9.1