From f0229b7c6801f6429dec75e208192b61053b8c7d Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期三, 03 四月 2024 09:46:02 +0800 Subject: [PATCH] 书目 --- packageBookService/pages/bookServices/examination/examination.js | 90 ++++++++++++++++++++++++++++++++------------- 1 files changed, 64 insertions(+), 26 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index 83953d8..1baf9aa 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -45,6 +45,8 @@ saveTime: 20, isNight: false, sliderValue: 0, // 瀛椾綋婊戝潡 + startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿 + pauseTime: 0 //鏆傚仠鏃堕棿 }, /** @@ -110,6 +112,9 @@ } }, 1000) } + this.setData({ + startTime: Date.now() + }) }, /** @@ -118,6 +123,13 @@ onHide() { if (wx.timer) { clearInterval(wx.timer) + } + this.setData({ + pauseTime: Date.now() + }) + if (wx.getStorageSync(app.config.tokenKey)) { + let duration = this.data.pauseTime - this.data.startTime + this.count(duration) } }, @@ -131,6 +143,32 @@ if (this.data.countdownInterval !== null) { clearInterval(this.data.countdownInterval) } + this.setData({ + pauseTime: Date.now() + }) + if (wx.getStorageSync(app.config.tokenKey)) { + let duration = this.data.pauseTime - this.data.startTime + this.count(duration) + } + }, + + count(timeStr) { + const data = { + appRefCode: app.config.appRefCode, + type: 'LearningTime', //缁熻绫诲瀷--闃呰鏃堕暱 + data: timeStr + '', //缁熻鍐呭--鏃堕暱姣 + event: 'LearningTime', + sysType: 'App' + } + //闃呰鍟嗗搧鐨刬d + if (this.data.bookId) { + data.productId = this.data.bookId + } + //闃呰璧勬簮鐨刬d + // if (product.cmsItemId) { + // data.cmsItemId = product.cmsItemId + // } + app.MG.job.newJobWithApiNewEvent(data).then((res) => {}) }, /** @@ -257,7 +295,9 @@ 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) + if (!item.isComplete) { + this.handleQuestion(this.data.currentIndex) + } } }, // 鐐瑰嚮绛旈鍗¤烦杞鐩� @@ -730,13 +770,11 @@ questionObj.questionType == 'multipleChoice' ) { try { - questionObj.answer = JSON.parse(questionObj.answer) + questionObj.answer = JSON.parse(questionObj.answer).toString() } catch (error) { questionObj.answer = item.Embedded_QuestionBank_Answer } } - // questionObj.userAnswer = this.arrayToString(questionObj.userAnswer) - // questionObj.isHaveAnswer = this.isHaveAnswer(questionObj.userAnswer) // 濉┖棰樻敼閫� if (questionObj.questionType == 'completion') { let index = 0 @@ -756,13 +794,16 @@ 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"') }) + } + // 瑙f瀽瀵屾枃鏈鐞� + if (questionObj.analysisCon && typeof questionObj.analysisCon == 'string') { + questionObj.analysisCon = questionObj.analysisCon.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ') } // 鑾峰彇鍥剧墖 if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { @@ -773,13 +814,17 @@ if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) }) } + // 瀹㈣棰樻�诲垎璧嬪�� + if (questionObj.questionType !== 'shortAnswer') { + this.setData({ + subjectiveGrade: this.data.subjectiveGrade + 2 + }) + } // if (questionObj.optionStyle == 'RichText') { // questionObj.option.forEach(optionItem => { // optionItem.txt.replace(/<img>/g, "<img class='imgClass'>") // }) // } - // 鏃ф暟鎹噷 棰樼洰宸茬粡浣滅瓟锛屼慨鏀瑰凡绛旈鐩暟閲� - // if (oldObj && oldObj.userAnswer.length > 0) countDownRef.value.changeAlready() // 鏃ф暟鎹噷 棰樼洰姝g‘ 璁板綍姝g‘鏁伴噺 if (questionObj.isRight) { this.setData({ @@ -792,7 +837,6 @@ subjectiveTotal: this.data.subjectiveTotal + 1 }) } - } // cardList璧嬪�� let cardIndex = this.data.cardList.findIndex((item) => item.path == pathitem.productLinkPath) @@ -801,11 +845,9 @@ this.setData({ [`cardList[${cardIndex}].infoList`]: infoList }) - // this.data.cardList[this.data.cardList.findIndex((item) => item.path == pathitem.productLinkPath)] - // .infoList - // infoList.push(questionObj) flag++; let questionList = [] + let grade = 0 const cardUpdatedList = this.data.cardList // if (flag == this.data.idPathList.length) { cardUpdatedList.forEach(aitem => { @@ -840,7 +882,6 @@ // 鎵规敼棰樼洰 if (item.questionType == 'multipleChoice') { // 澶氶�夐 - // subjectiveGrade.value += item.score if (item.answer.length == item.userAnswer.length) { const sortedArr1 = item.answer.slice().sort() const sortedArr2 = item.userAnswer.slice().sort() @@ -852,7 +893,6 @@ } } else if (item.questionType == 'singleChoice' || item.questionType == 'judge') { // 鍗曢�� 鍒ゆ柇 - // subjectiveGrade.value += item.score questionList[index].isRight = item.answer == item.userAnswer } else if (item.questionType == 'shortAnswer') { // 绠�绛� 缈昏瘧 @@ -869,7 +909,6 @@ ) } } - // subjectiveGrade.value += item.score if (typeof item.answer == 'string') { questionList[index].isRight = item.answer == item.userAnswer[0] } else { @@ -885,7 +924,6 @@ if (item.questionType != 'shortAnswer') { this.setData({ subjectiveTotal: this.data.subjectiveTotal + 1, - subjectiveGrade: this.data.subjectiveGrade + item.score }) } if (questionList[index].isRight && item.questionType != 'shortAnswer') { @@ -1162,9 +1200,9 @@ questionObj.questionType == 'multipleChoice' ) { try { - questionObj.answer = JSON.parse(questionObj.answer) + questionObj.answer = JSON.parse(questionObj.answer).toString() } catch (error) { - // + questionObj.answer = item.Embedded_QuestionBank_Answer } } // 濉┖棰樻敼閫� @@ -1282,12 +1320,6 @@ }, // 鑾峰彇閿欓闆� async getErrorDataList() { - // this.setData({ - // cardList: [{ - // catalogName: '閿欓闆�', - // infoList: [] - // }] - // }) this.setData({ cardList: [{ catalogName: '鍗曢�夐', @@ -1362,9 +1394,9 @@ questionObj.questionType == 'multipleChoice' ) { try { - questionObj.answer = JSON.parse(questionObj.answer) + questionObj.answer = JSON.parse(questionObj.answer).toString() } catch (error) { - // + questionObj.answer = item.Embedded_QuestionBank_Answer } } // 濉┖棰樻敼閫� @@ -1606,7 +1638,7 @@ questionObj.questionType == 'multipleChoice' ) { try { - questionObj.answer = JSON.parse(questionObj.answer) + questionObj.answer = JSON.parse(questionObj.answer).toString() } catch (error) { questionObj.answer = item.Embedded_QuestionBank_Answer } @@ -1646,6 +1678,12 @@ if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) }) } + // 瀹㈣棰樻�诲垎璧嬪�� + if (questionObj.questionType !== 'shortAnswer') { + this.setData({ + subjectiveGrade: this.data.subjectiveGrade + questionObj.score + }) + } if (oldObj && oldObj.isRight) { this.setData({ correctNum: this.data.correctNum + 1 -- Gitblit v1.9.1