From f1e20feafa89c8d50af5e69c0333a9efc239ee49 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期一, 01 四月 2024 14:09:11 +0800 Subject: [PATCH] 图书详情页bug修改,我的错题、收藏模式下答题卡添加题目类型,非单选题添加查看解析按钮 --- packageBookService/pages/bookServices/examination/examination.js | 199 +++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 166 insertions(+), 33 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index fc94dce..c90f3bc 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -253,6 +253,13 @@ if (flag) this.handleQuestion(index) } }, + // 鎴戠殑閿欓锛屾敹钘忔煡鐪嬭В鏋愭寜閽� + viewParsing() { + if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') { + const item = this.data.questionDataList[this.data.currentIndex] + if (!item.isComplete) this.handleQuestion(this.data.currentIndex) + } + }, // 鐐瑰嚮绛旈鍗¤烦杞鐩� goQuestion(e) { const id = e.detail.id @@ -387,7 +394,6 @@ }, // 鎻愪氦閫昏緫 submitPaper() { - // 鍏抽棴閫�鍑洪〉闈㈢洃鍚� wx.disableAlertBeforeUnload() this.setData({ @@ -852,7 +858,17 @@ // 绠�绛� 缈昏瘧 questionList[index].isRight = null } else if (item.questionType == 'completion') { - // 濉┖ + if (item.answer == 'string') { + item.isRight = item.answer == item.userAnswer[0] + } else { + if (item.answer.length != item.userAnswer.length) { + item.isRight = false + } else { + item.isRight = item.answer.every( + (value, index) => value === item.userAnswer[index] + ) + } + } // subjectiveGrade.value += item.score if (typeof item.answer == 'string') { questionList[index].isRight = item.answer == item.userAnswer[0] @@ -1071,12 +1087,35 @@ // 鑾峰彇鏀惰棌澶� async getCollectDataList() { let questionArr = [] + // this.setData({ + // cardList: [{ + // catalogName: '鏀惰棌澶�', + // infoList: [] + // }] + // }) this.setData({ cardList: [{ - catalogName: '鏀惰棌澶�', + catalogName: '鍗曢�夐', + infoList: [] + }, { + catalogName: '鍒ゆ柇棰�', + infoList: [] + }, { + catalogName: '澶氶�夐', + infoList: [] + }, { + catalogName: '濉┖棰�', + infoList: [] + }, { + catalogName: '绠�绛旈', infoList: [] }] }) + let singleChoiceArr = [] // 鍗曢�� + let judgeArr = [] // 鍒ゆ柇 + let shortArr = [] // 绠�绛� + let multipleChoiceArr = [] // 澶氶�� + let completionArr = [] // 濉┖ let query = { path: '*', cmsPath: this.data.rootCmsItemId, @@ -1157,25 +1196,61 @@ if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) }) } - // if (item.Embedded_QuestionBank_QuestionType == 'judge') { - // topicList.value.judge.data.push(questionObj) - // } else if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') { - // topicList.value.radio.data.push(questionObj) - // } else if (item.Embedded_QuestionBank_QuestionType == 'multipleChoice') { - // topicList.value.check.data.push(questionObj) - // } else if (item.Embedded_QuestionBank_QuestionType == 'completion') { - // topicList.value.gap.data.push(questionObj) - // } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') { - // topicList.value.short.data.push(questionObj) - // } - questionArr.push(questionObj) - // cardList.value[0].infoList.push(questionObj) + // 棰樺共瀵屾枃鏈鐞� + if (questionObj.stemStyle == 'RichText') { + // questionObj.option.txt = '' + questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ').replace(/\<p/gi, '<p class="stem-rich-p"') + + } + // 閫夐」瀵屾枃鏈鐞� + if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) { + questionObj.option.forEach(item => { + if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"') + }) + } + if (item.Embedded_QuestionBank_QuestionType == 'judge') { + questionObj.type = '鍒ゆ柇棰�' + judgeArr.push(questionObj) + } else if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') { + questionObj.type = '鍗曢�夐' + singleChoiceArr.push(questionObj) + } else if (item.Embedded_QuestionBank_QuestionType == 'multipleChoice') { + questionObj.type = '澶氶�夐' + multipleChoiceArr.push(questionObj) + } else if (item.Embedded_QuestionBank_QuestionType == 'completion') { + questionObj.type = '濉┖棰�' + completionArr.push(questionObj) + } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') { + questionObj.type = '绠�绛旈' + shortArr.push(questionObj) + } + // questionArr.push(questionObj) }) - // loadings.value = false + // this.setData({ + // questionDataList: questionArr, + // ['cardList[0].infoList']: questionArr, + // loading: false, + // }) + this.setData({ + ['cardList[0].infoList']: singleChoiceArr, + ['cardList[1].infoList']: judgeArr, + ['cardList[2].infoList']: multipleChoiceArr, + ['cardList[3].infoList']: completionArr, + ['cardList[3].infoList']: shortArr, + }) + const cardList = this.data.cardList + for (let index = 0; index < cardList.length; index++) { + const item = cardList[index]; + for (let cindex = 0; cindex < item.infoList.length; cindex++) { + const citem = item.infoList[cindex] + citem.number = cindex + 1 + questionArr.push(citem) + } + } this.setData({ questionDataList: questionArr, - ['cardList[0].infoList']: questionArr, - loading: false, + cardList: cardList, + loading: false }) }) }, @@ -1217,12 +1292,35 @@ }, // 鑾峰彇閿欓闆� async getErrorDataList() { + // this.setData({ + // cardList: [{ + // catalogName: '閿欓闆�', + // infoList: [] + // }] + // }) this.setData({ cardList: [{ - catalogName: '閿欓闆�', + catalogName: '鍗曢�夐', + infoList: [] + }, { + catalogName: '鍒ゆ柇棰�', + infoList: [] + }, { + catalogName: '澶氶�夐', + infoList: [] + }, { + catalogName: '濉┖棰�', + infoList: [] + }, { + catalogName: '绠�绛旈', infoList: [] }] }) + let singleChoiceArr = [] // 鍗曢�� + let judgeArr = [] // 鍒ゆ柇 + let shortArr = [] // 绠�绛� + let multipleChoiceArr = [] // 澶氶�� + let completionArr = [] // 濉┖ let query = { path: '*', cmsPath: this.data.rootCmsItemId, @@ -1303,22 +1401,57 @@ if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) }) } - // if (item.Embedded_QuestionBank_QuestionType == 'judge') { - // topicList.value.judge.data.push(questionObj) - // } else if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') { - // topicList.value.radio.data.push(questionObj) - // } else if (item.Embedded_QuestionBank_QuestionType == 'multipleChoice') { - // topicList.value.check.data.push(questionObj) - // } else if (item.Embedded_QuestionBank_QuestionType == 'completion') { - // topicList.value.gap.data.push(questionObj) - // } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') { - // topicList.value.short.data.push(questionObj) - // } - questionArr.push(questionObj) + // 棰樺共瀵屾枃鏈鐞� + if (questionObj.stemStyle == 'RichText') { + // questionObj.option.txt = '' + questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ').replace(/\<p/gi, '<p class="stem-rich-p"') + + } + // 閫夐」瀵屾枃鏈鐞� + if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) { + questionObj.option.forEach(item => { + if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"') + }) + } + if (item.Embedded_QuestionBank_QuestionType == 'judge') { + questionObj.type = '鍒ゆ柇棰�' + judgeArr.push(questionObj) + } else if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') { + questionObj.type = '鍗曢�夐' + singleChoiceArr.push(questionObj) + } else if (item.Embedded_QuestionBank_QuestionType == 'multipleChoice') { + questionObj.type = '澶氶�夐' + multipleChoiceArr.push(questionObj) + } else if (item.Embedded_QuestionBank_QuestionType == 'completion') { + questionObj.type = '濉┖棰�' + completionArr.push(questionObj) + } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') { + questionObj.type = '绠�绛旈' + shortArr.push(questionObj) + } + // questionArr.push(questionObj) }) this.setData({ + // questionDataList: questionArr, + ['cardList[0].infoList']: singleChoiceArr, + ['cardList[1].infoList']: judgeArr, + ['cardList[2].infoList']: multipleChoiceArr, + ['cardList[3].infoList']: completionArr, + ['cardList[3].infoList']: shortArr, + // loading: false + }) + const cardList = this.data.cardList + for (let index = 0; index < cardList.length; index++) { + const item = cardList[index]; + for (let cindex = 0; cindex < item.infoList.length; cindex++) { + const citem = item.infoList[cindex] + citem.number = cindex + 1 + questionArr.push(citem) + } + } + this.setData({ questionDataList: questionArr, - ['cardList[0].infoList']: questionArr, + cardList: cardList, loading: false }) }) -- Gitblit v1.9.1