packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -82,11 +82,10 @@ }, // 跳转音视频播放器 goPlayer(e) { console.log(e); debugger const item = e.currentTarget.dataset.item const parent = e.currentTarget.dataset.parent let url if (item.selectType == 'video') { url = '/packageDomain/pages/resourceDetails/myVideo/index' @@ -249,5 +248,8 @@ }, oncheckbox() { console.log(111); }, logdata(e) { console.log(e); } }) packageBookService/pages/bookServices/detail/components/tree/index.wxml
packageBookService/pages/bookServices/detail/index.js
@@ -417,20 +417,22 @@ //教学资源 云学习 if (type.refCode == 'jsek_teachingResources' || type.refCode == 'jsek_cloudLearning') { if (res.datas.cmsDatas[0].datas.length > 0) { if (type.refCode == 'jsek_teachingResources') { res.datas.cmsDatas[0].datas.forEach(item => { item.checked = false }) const list = await this.getAllResource(res.datas.cmsDatas[0].datas) console.log(list, 'list'); if (type.refCode == 'jsek_teachingResources') { this.setData({ teach: list, loading: false }) this.findChildIds(this.data.teach, this.data.openTeachids = []) } else if (type.refCode == 'jsek_cloudLearning') { const list = await this.getAllResource(res.datas.cmsDatas[0].datas) // res.datas.cmsDatas[0].datas.forEach(item => { // item.checked = false // }) // const list = await this.getAllResource(res.datas.cmsDatas[0].datas) console.log(list, 'currentlist'); this.setData({ learn: list, loading: false @@ -515,6 +517,7 @@ if (this.data.tabValue == 'jsek_teachingResources') { item.checked = false } else if (this.data.tabValue == 'jsek_cloudLearning') { item.checked = false item.isbuy = this.resourceIsBuy(item) item.isShopCar = this.isShoppingCart(item) } packageBookService/pages/bookServices/examination/examination.js
@@ -39,7 +39,9 @@ time: 0, // 答题剩余时间 datas: [], // 所有模考记录数据(题目列表,用户答题,考试报告) answer: [] } }, saveTime: 20, isNight: false }, /** @@ -80,7 +82,19 @@ * 生命周期函数--监听页面显示 */ onShow() { if (this.data.answerType == 'mock') { if (wx.timer) { clearInterval(wx.timer) } wx.timer = setInterval(() => { this.setData({ saveTime: this.data.saveTime - 1 }) if (this.data.saveTime == 0) { this.saveMockData() } }, 1000) } }, /** @@ -122,7 +136,12 @@ goBack() { wx.navigateBack(); }, //设置背景色 changeBGColor(e) { this.setData({ isNight: e.detail.value }) }, // 获取保存的倒计时时间 getSavedTime() { const savedTime = wx.getStorageSync('countdownTime') @@ -207,12 +226,17 @@ questionList.forEach(item => { if (item.id == id) { item.userAnswer = radioChecked item.isUserAnswer = this.isHaveAnswer(radioChecked) } }) this.setData({ questionDataList: questionList }) console.log(this.data.questionDataList); if (this.data.answerType == 'mock') { this.setData({ saveTime: 20 }) } }, // 输入框触发 onChangeInput(e) { @@ -222,13 +246,18 @@ const questionList = this.data.questionDataList questionList.forEach(item => { if (item.id == id) { item.userAnswer[index] = inputData item.userAnswer[index] = inputData, item.isUserAnswer = this.isHaveAnswer(item.userAnswer) } }) this.setData({ questionDataList: questionList }) console.log(this.data.questionDataList); if (this.data.answerType == 'mock') { this.setData({ saveTime: 20 }) } }, // 数组转为字符串方法 arrayToString(data) { @@ -267,10 +296,8 @@ this.setData({ submitStatus: true }) if (this.data.answerType == 'option') { this.toggleCountdown() const child = this.selectComponent('#question-options') if (this.data.answerType == 'option' || this.data.answerType == 'errorQuestion') { if (this.data.answerType == 'option' || this.data.answerType == 'errorQuestion' || this.data.answerType == 'mock') { // 先遍历所有题目,将未批改的题目批改 const qustionList = this.data.questionDataList for (let index = 0; index < qustionList.length; index++) { @@ -279,11 +306,51 @@ } } if (this.data.answerType == 'option') { this.toggleCountdown() this.recordAnswerData() child.openTestReportDialog() } } else if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') { this.goBack() } else if (this.data.answerType == 'mock') { this.toggleCountdown() // 设置模考状态为已完成 const mockData = this.data.mockData mockData.datas.forEach((item) => { if (item.id == this.data.uuid) { item.state = '3' item.report = { userScore: this.data.subjectiveNum } } }) this.setData({ mockData: mockData, submitStatus: true }) this.setMockInfo(mockData.datas) // 记录用户答题数据 let saveData = [] for (let index = 0; index < this.data.questionDataList.length; index++) { const item = this.data.questionDataList[index]; saveData.push({ id: item.id, answer: item.userAnswer, isRight: item.isRight }) } app.MG.identity.setUserKey({ setKeyRequests: [ { domain: 'mockAnswerData', key: this.data.uuid, value: JSON.stringify({ time: this.data.countdownTime, answerData: saveData }) } ] }) child.openTestReportDialog() } }, @@ -342,7 +409,14 @@ 'mockData.sumTime': oldMockData.time, cardList: oldQuestionList }) } if (oldMockData.state == '0' || oldMockData.state == '1' || oldMockData.state == '2') { this.startCountdown() } if (oldMockData.state == '3') { this.setData({ submitStatus: true }) } } }) @@ -377,9 +451,9 @@ setKeyRequests: [ { domain: 'mockAnswerData', key: route.query.uuid, key: this.data.uuid, value: JSON.stringify({ time: countDownRef.value.countdownTime, time: this.data.countdownTime, answerData: [] }) } @@ -542,6 +616,7 @@ item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '', isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false, isRight: oldObj ? oldObj.isRight : null, isComplete: oldObj ? oldObj.isComplete : false, isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false, @@ -623,7 +698,7 @@ aitem.infoList.forEach((bitem, bindex) => { questionList.push(bitem) bitem.number = bindex + 1 bitem.grade = 2 bitem.score = 2 }) }) this.setData({ @@ -685,13 +760,13 @@ if (item.questionType != 'shortAnswer') { this.setData({ subjectiveTotal: this.data.subjectiveTotal + 1, subjectiveGrade: this.data.subjectiveGrade + item.grade subjectiveGrade: this.data.subjectiveGrade + item.score }) } if (questionList[index].isRight && item.questionType != 'shortAnswer') { // 客观题回答正确 this.setData({ subjectiveNum: this.data.subjectiveNum + item.grade, subjectiveNum: this.data.subjectiveNum + item.score, correctNum: this.data.correctNum + 1 }) } @@ -725,6 +800,7 @@ console.log(res) }) } this.setData({ questionDataList: questionList }) @@ -1180,11 +1256,13 @@ }) try { this.setData({ 'mockData.time': JSON.parse(configRes.config).time * 1000 'mockData.time': JSON.parse(configRes.config).time * 1000, countdownTime: JSON.parse(configRes.config).time * 1000 }) } catch (error) { this.setData({ 'mockData.time': 3600 * 1000 'mockData.time': 3600 * 1000, countdownTime: 3600 * 1000, }) } this.setData({ @@ -1202,7 +1280,7 @@ numberIndex++ return { number: numberIndex, itemId: idItem.id, id: idItem.id, score: idItem.score } }) @@ -1216,7 +1294,7 @@ numberIndex++ return { number: numberIndex, itemId: extractCmsItem.id, id: extractCmsItem.id, score: extractCmsItem.score } }) @@ -1252,7 +1330,146 @@ await this.getMockDataList(this.data.cardList) // 请求题目数据 }) }, // 获取组卷题目列表 async getMockDataList(questionList, oldList) { console.log(questionList, oldList); const questionDataList = this.data.questionDataList questionList.forEach(async (pathitem, 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, // 解析 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: '' // 控制解析的折叠面板是否展开 } // 多选和填空答案肯为数组,要转换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) 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 // if (flag == this.data.idPathList.length) { cardUpdatedList.forEach(aitem => { aitem.infoList.forEach((bitem, bindex) => { questionList.push(bitem) bitem.number = bindex + 1 }) }) this.setData({ questionDataList: questionList, cardList: cardUpdatedList }) }) }) }) this.setData({ // questionDataList: questionDataList, loading: false }) }, // 获取组卷数据 getMockInfo(callback) { app.MG.identity @@ -1316,136 +1533,67 @@ .then((res) => { if (res[0]) { this.setData({ 'mockData.time': JSON.parse(res[0].value).timem, currentIndex: JSON.parse(res[0].value).currentIndex, 'mockData.time': JSON.parse(res[0].value).time, countdownTime: JSON.parse(res[0].value).time ? JSON.parse(res[0].value).time : this.data.mockData.sumTime, 'mockData.answer': JSON.parse(res[0].value).answerData }) console.log(JSON.parse(res[0].value)); data = JSON.parse(res[0].value).answerData } }) return data }, // 组卷获取题目列表 async getMockDataList(questionList, oldList) { const questionDataList = this.data.questionDataList questionList.forEach(async (pathitem, pathindex) => { let itemIds = [] pathitem.infoList.forEach(item => { itemIds.push(item.itemId + '') }) 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 = { id: item.id, 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, // 解析 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' ? [] : '', isRight: oldObj ? oldObj.isRight : null, // isComplete: oldObj ? oldObj.isComplete : false, isComplete: oldObj ? oldObj.isComplete : false, isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false, isUnfold: '' // 控制解析的折叠面板是否展开 } const cardList = this.data.cardList for (let a = 0; a < cardList.length; a++) { const cardItem = cardList[a]; for (let b = 0; b < cardItem.infoList.length; b++) { if (cardItem.infoList[b].itemId == item.id) { questionObj.number = cardItem.infoList[b].number; questionObj.score = cardItem.infoList[b].score; cardItem.infoList[b] = obj; } } } this.setData({ cardList: cardList }) // 多选和填空答案肯为数组,要转换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 (oldObj && oldObj.isRight) { this.setData({ correctNum: this.data.correctNum + 1 }) } if (item.questionType != 'shortAnswer') { this.setData({ subjectiveTotal: this.data.subjectiveTotal + 1 }) } // if (oldObj && isHaveAnswer(oldObj.answer)) countDownRef.value.changeAlready() questionDataList.push(questionObj) }) }) }) // 记录模考答题数据 saveMockData() { const data = this.data.mockData.datas.find((itme) => itme.id == this.data.uuid) if (data.state == '3') return true const saveData = this.data.mockData.answer for (let i = 0; i < this.data.questionDataList.length; i++) { const item = this.data.questionDataList[i] if (this.isHaveAnswer(item.userAnswer)) { const index = saveData.findIndex((saveitem) => saveitem.id == item.id) if (index + '' != '-1') { saveData[index].answer = item.userAnswer } else { saveData.push({ id: item.id, answer: item.userAnswer }) } } } // if (this.data.mockData.state == '1') { const datas = this.data.mockData.datas datas.forEach((item) => { if (item.id == this.data.uuid) { item.state = '2' } }) this.setMockInfo(datas) } // app.MG.identity .setUserKey({ setKeyRequests: [ { domain: 'mockAnswerData', key: this.data.uuid, value: JSON.stringify({ currentIndex: this.data.currentIndex, time: this.data.countdownTime, answerData: saveData }) } ] }) .then((res) => { this.setData({ questionDataList: questionDataList, loading: false saveTime: 20 }) console.log('模考答题数据已记录') }) } }) packageBookService/pages/bookServices/examination/examination.wxml
@@ -26,6 +26,7 @@ <question-schedule wx:if="{{!loading}}" id="countDownRef" isNight="{{isNight}}" answerType="{{answerType}}" countdownTime="{{countdownTime}}" currentIndex="{{currentIndex}}" @@ -34,6 +35,7 @@ ></question-schedule> <question-list wx:if="{{!loading}}" isNight="{{isNight}}" currentIndex="{{currentIndex}}" questionList="{{questionDataList}}" submitStatus="{{submitStatus}}" @@ -55,6 +57,7 @@ <view class="page-bottom"> <question-options id="question-options" isNight="{{isNight}}" submitStatus="{{submitStatus}}" answerType="{{answerType}}" countdownTime="{{countdownTime}}" @@ -65,9 +68,11 @@ subjectiveNum="{{subjectiveNum}}" subjectiveGrade="{{subjectiveGrade}}" correctNum="{{correctNum}}" mockSumTime="{{mock.sumTime}}" bind:setCollect="setCollect" bind:submitPaper="submitPaper" bind:restart="restart" bind:goQuestion="goQuestion" bind:changeBGColor="changeBGColor" ></question-options> </view> packageBookService/pages/bookServices/examination/examination.wxss
@@ -1,5 +1,6 @@ /* pages/examination/examination.wxss */ .nacigationBar { display: flex; align-items: center; @@ -29,3 +30,13 @@ padding: 20rpx; background-color: #F2F3F8; } .daytime { background-color: #fff; color: #000; } .night { background-color: #000; color: #fff; } packageBookService/pages/bookServices/examination/questionList/index.js
@@ -15,6 +15,10 @@ currentIndex: { type: Number, value: 1 }, isNight:{ type:Boolean, value:false } }, created() { packageBookService/pages/bookServices/examination/questionList/index.wxml
@@ -1,63 +1,35 @@ <!--pages/bookServices/examination/questionList/index.wxml--> <view class="question-list"> <view class="question-list" style="background-color:{{isNight ? '#000' : '#fff'}}"> <!-- 题型title --> <view class="question-title" wx:if="{{questionList[showIndex].type}}"> <text class="title-name">{{questionList[showIndex].type}}</text ><text class="title-score">(每题{{questionList[showIndex].grade}}分)</text> <view class="question-title" wx:if="{{questionList[showIndex].type}}" style="background-color:{{isNight ? '#000' : '#fff'}}"> <text class="title-name">{{questionList[showIndex].type}}</text><text class="title-score" style="color: {{isNight ? '#fff' : '#000'}};">(每题{{questionList[showIndex].score}}分)</text> </view> <!-- 题目列表 --> <swiper class="swiper" bind:change="changeSwiper" current="{{currentIndex}}"> <swiper-item wx:for="{{questionList}}" wx:key="{{item.id}}"> <!-- 题干 --> <view class="question-stem title-score"> <view class="question-stem title-score" style="color: {{isNight ? '#fff' : '#000'}};"> <!-- 题号 --> <text>{{item.number}}.</text> <!-- 仅文字 --> <view wx:if="{{item.stemStyle == 'Txt' && item.questionType != 'completion'}}" >{{item.stem.stemTxt}}</view > <view wx:if="{{item.stemStyle == 'Txt' && item.questionType != 'completion'}}">{{item.stem.stemTxt}}</view> <!-- 仅图片 --> <view wx:elif="{{item.stemStyle == 'Image'}}"> <t-image src="{{item.stem.stemImage}}" /> </view> <!-- 图片加文字 --> <view wx:elif="{{item.stemStyle == 'TxtAndImage'}}" class="title-TxtAndImage" > <view wx:elif="{{item.stemStyle == 'TxtAndImage'}}" class="title-TxtAndImage"> <text>{{item.stem.stemTxt}}</text> <t-image src="{{item.stem.stemImage}}"></t-image> </view> <!-- 富文本 --> <view wx:elif="{{item.stemStyle == 'RichText'}} " class="title-RichText" > <view wx:elif="{{item.stemStyle == 'RichText'}} " class="title-RichText"> <rich-text nodes="{{item.stem.stemTxt}}"></rich-text> </view> <!-- 填空题 --> <view wx:if="{{item.questionType == 'completion'}}"> <view class="completion-box" wx:for="{{item.stem}}" wx:for-item="inputItem" wx:for-index="inputIndex" wx:key="inputIndex" > <t-input disabled="{{item.isComplete}}" bind:change="onChangeInput" data-value="{{item.option}}" data-id="{{item.id}}" data-index="{{inputItem.num}}" class="title-input" style="{{inputstyle}}" placeholder-style="{{placeholderstyle}}" wx:if="{{inputItem.data == 'input'}}" placeholder="请输入文字" value="{{item.userAnswer[inputItem.num]}}" ></t-input> <view class="completion-box" wx:for="{{item.stem}}" wx:for-item="inputItem" wx:for-index="inputIndex" wx:key="inputIndex"> <t-input disabled="{{item.isComplete}}" bind:change="onChangeInput" data-value="{{item.option}}" data-id="{{item.id}}" data-index="{{inputItem.num}}" class="title-input" style="{{inputstyle}}" placeholder-style="{{placeholderstyle}}" wx:if="{{inputItem.data == 'input'}}" placeholder="请输入文字" value="{{item.userAnswer[inputItem.num]}}"></t-input> <text wx:else>{{inputItem}}</text> </view> </view> @@ -65,44 +37,19 @@ <!-- 答题区域 --> <view class="question-answer"> <!-- 单选题 --> <t-radio-group wx:if="{{item.questionType == 'singleChoice' || item.questionType == 'judge'}}" defaultValue="{{item.userAnswer}}" disabled="{{item.isComplete}}" bind:change="onChangeRadio" class="radio-group" data-value="{{item.option}}" data-id="{{item.id}}" > <view wx:for="{{item.option}}" wx:for-item="contentItem" wx:for-index="contentIndex" wx:key="contentIndex" > <t-radio value="{{contentItem.value}}" icon="none" placement="right" borderless > <view class="radio-item {{item.answer == contentItem.value && item.answer == item.userAnswer ? 'radio-correct' : item.userAnswer == contentItem.value && item.userAnswer != item.answer ?'radio-error' :''}}" > <t-radio-group wx:if="{{item.questionType == 'singleChoice' || item.questionType == 'judge'}}" defaultValue="{{item.userAnswer}}" disabled="{{item.isComplete}}" bind:change="onChangeRadio" class="radio-group" data-value="{{item.option}}" data-id="{{item.id}}"> <view wx:for="{{item.option}}" wx:for-item="contentItem" wx:for-index="contentIndex" wx:key="contentIndex"> <t-radio value="{{contentItem.value}}" icon="none" placement="right" borderless style="color: {{isNight ? '#fff' : '#000'}}; background-color:{{isNight ? '#000' : '#fff'}}"> <view class="radio-item {{item.answer == contentItem.value && item.answer == item.userAnswer ? 'radio-correct' : item.userAnswer == contentItem.value && item.userAnswer != item.answer ?'radio-error' :''}}" style="color: {{isNight ? '#fff' : '#000'}}; background-color:{{isNight ? '#000' : '#fff'}}"> <!-- 仅文字 --> <text wx:if="{{item.optionStyle == 'Txt'}}" >{{contentItem.value}}、{{contentItem.txt}}</text > <text wx:if="{{item.optionStyle == 'Txt'}}">{{contentItem.value}}、{{contentItem.txt}}</text> <!-- 仅图片 --> <view wx:if="{{item.optionStyle == 'Image'}}" class="fl-center"> <text>{{contentItem.value}}、</text> <t-image src="{{contentItem.img}}"></t-image> </view> <!-- 文字加图片 --> <view wx:if="{{item.optionStyle == 'TxtAndImage'}}" class="fl-center" > <view wx:if="{{item.optionStyle == 'TxtAndImage'}}" class="fl-center"> <text>{{contentItem.value}}、</text> <text>{{contentItem.txt}}</text> <t-image src="{{contentItem.img}}"></t-image> @@ -112,51 +59,25 @@ <text>{{contentItem.value}}、</text> <rich-text nodes="{{contentItem.txt}}"></rich-text> </view> <text wx:if="{{item.answer == contentItem.value && item.answer == item.userAnswer}}" >对</text > <text wx:if="{{item.userAnswer == contentItem.value && item.userAnswer != item.answer}}" >错</text > <text wx:if="{{item.answer == contentItem.value && item.answer == item.userAnswer}}">对</text> <text wx:if="{{item.userAnswer == contentItem.value && item.userAnswer != item.answer}}">错</text> </view> </t-radio> </view> </t-radio-group> <!-- 多选题 --> <t-checkbox-group disabled="{{item.isComplete}}" class="checkbox-group" wx:elif="{{item.questionType == 'multipleChoice'}}" t-class="box" borderless bind:change="onChangeRadio" data-value="{{item.option}}" data-id="{{item.id}}" defaultValue="{{item.userAnswer}}" > <view wx:for="{{item.option}}" wx:for-item="contentItem" wx:for-index="contentIndex" wx:key="contentIndex" > <t-checkbox-group disabled="{{item.isComplete}}" class="checkbox-group" wx:elif="{{item.questionType == 'multipleChoice'}}" t-class="box" borderless bind:change="onChangeRadio" data-value="{{item.option}}" data-id="{{item.id}}" defaultValue="{{item.userAnswer}}"> <view wx:for="{{item.option}}" wx:for-item="contentItem" wx:for-index="contentIndex" wx:key="contentIndex"> <t-checkbox block="{{false}}" value="{{contentItem.value}}"> <!-- 仅文字 --> <text wx:if="{{item.optionStyle == 'Txt'}}" >{{contentItem.value}}、{{contentItem.txt}}</text > <text wx:if="{{item.optionStyle == 'Txt'}}">{{contentItem.value}}、{{contentItem.txt}}</text> <!-- 仅图片 --> <view wx:if="{{item.optionStyle == 'Image'}}" class="fl-center"> <text>{{contentItem.value}}、</text> <t-image src="{{contentItem.img}}"></t-image> </view> <!-- 文字加图片 --> <view wx:if="{{item.optionStyle == 'TxtAndImage'}}" class="fl-center" > <view wx:if="{{item.optionStyle == 'TxtAndImage'}}" class="fl-center"> <text>{{contentItem.value}}、</text> <text>{{contentItem.txt}}</text> <t-image src="{{contentItem.img}}"></t-image> @@ -170,43 +91,21 @@ </view> </t-checkbox-group> <!-- 简答 翻译 --> <t-textarea disabled="{{item.isComplete}}" value="{{item.userAnswer}}" bind:change="onChangeRadio" data-value="{{item.option}}" data-id="{{item.id}}" class="option-textarea" wx:elif="{{item.questionType == 'shortAnswer'}}" t-class="external-class" placeholder="请输入文字" bordered maxlength="500" disableDefaultPadding="{{true}}" indicator style="{{style}}" /> <t-textarea disabled="{{item.isComplete}}" value="{{item.userAnswer}}" bind:change="onChangeRadio" data-value="{{item.option}}" data-id="{{item.id}}" class="option-textarea" wx:elif="{{item.questionType == 'shortAnswer'}}" t-class="external-class" placeholder="请输入文字" bordered maxlength="500" disableDefaultPadding="{{true}}" indicator style="{{style}}" /> </view> <!-- 解析 --> <view class="analysis" wx:if="{{item.isComplete}}"> <view class="analysis-answer"> <view class="answer-correct"> <text class="analysis-title-box">正确答案:</text> <rich-text nodes="{{item.answer}}" style="font-size: 40rpx" ></rich-text> <rich-text nodes="{{item.answer}}" style="font-size: 40rpx"></rich-text> </view> <view class="answer-error"> <text class="analysis-title-box">您的答案:</text ><text class="answer-text">{{item.userAnswer}}</text> <text class="analysis-title-box">您的答案:</text><text class="answer-text">{{item.userAnswer}}</text> </view> </view> <view class="analysis-text" wx:if="{{item.analysisCon}}"> 答案解析:<rich-text nodes="{{item.analysisCon}}" class="analysis-content" ></rich-text> 答案解析:<rich-text nodes="{{item.analysisCon}}" class="analysis-content"></rich-text> </view> </view> </swiper-item> packageBookService/pages/bookServices/examination/questionOptions/index.js
@@ -44,6 +44,10 @@ submitStatus: { type: Boolean, value: false }, mockSumTime: { type: Number, value: 0, } }, @@ -57,13 +61,19 @@ setUpPopup: false, testReportState: false, sliderValue: 0, useTime: '' useTime: '', radioItem: 'daytime' }, observers: { "countdownTime": function (newValue, oldValue) { if (this.properties.answerType == 'option') { this.setData({ useTime: this.formatTime(2 * 60 * 60 * 1000 - this.properties.countdownTime) }) } else if (this.properties.answerType == 'option') { this.setData({ useTime: this.formatTime(this.properties.mockSumTime - this.properties.countdownTime) }) } if (newValue == 0 && (this.properties.answerType == 'option' || this.properties.answerType == 'mock')) { @@ -163,6 +173,14 @@ setUpPopup: e.detail.visible }) }, // 设置模式切换 onRadioChange(e) { this.setData({ radioItem: e.detail.value }) const value = e.detail.value == 'night' ? true : false this.triggerEvent('changeBGColor', { value }) }, // 重做按钮 resterBtn() { wx.showModal({ @@ -203,9 +221,11 @@ // 底部提交按钮 submitBtn() { // 我的错题和收藏 直接走提交逻辑 if (this.properties.answerType !== 'option' || this.properties.answerType !== 'option') { return this.submitPaper() } if (this.properties.answerType == 'collectQuestion' || this.properties.answerType == 'errorQuestion') { this.submitPaper() return wx.navigateBack() } else if (this.properties.answerType == 'option' || this.properties.answerType == 'mock') { if (this.properties.submitStatus) return wx.navigateBack() this.properties.questionDataList.forEach(item => { if (!this.isHaveAnswer(item.userAnswer)) { this.setData({ @@ -220,6 +240,8 @@ // 做完了直接执行提交事件 this.submitPaper() } } }, // 提交事件 submitPaper() { packageBookService/pages/bookServices/examination/questionOptions/index.json
@@ -6,6 +6,8 @@ "t-button": "tdesign-miniprogram/button/button", "t-dialog": "tdesign-miniprogram/dialog/dialog", "t-popup": "tdesign-miniprogram/popup/popup", "t-slider": "tdesign-miniprogram/slider/slider" "t-slider": "tdesign-miniprogram/slider/slider", "t-radio": "tdesign-miniprogram/radio/radio", "t-radio-group": "tdesign-miniprogram/radio-group/radio-group" } } packageBookService/pages/bookServices/examination/questionOptions/index.wxml
@@ -1,48 +1,30 @@ <!--pages/bookServices/examination/questionOptions/index.wxml--> <view class="page-bottom"> <view class="li-option" bind:tap="setCollect"> <t-image src="{{ questionDataList[currentIndex].isCollect ? '/static/images/bookService/detail/collecting.png' : '/static/images/bookService/examination/collect.png'}}" > <t-image src="{{ questionDataList[currentIndex].isCollect ? '/static/images/bookService/detail/collecting.png' : '/static/images/bookService/examination/collect.png'}}"> </t-image> 收藏 </view> <view class="li-option" bind:tap="handlePopup"> <t-image src="/static/images/bookService/examination/questionCard.png" ></t-image> <t-image src="/static/images/bookService/examination/questionCard.png"></t-image> 答题卡 </view> <view class="li-option" bind:tap="setUpBtn"> <t-image src="/static/images/bookService/examination/setting.png"></t-image> 设置 </view> <view class="li-option" bind:tap="resterBtn" wx:if="{{answerType == 'option' || answerType == 'mock'}}" > <view class="li-option" bind:tap="resterBtn" wx:if="{{answerType == 'option' || answerType == 'mock'}}"> <t-image src="/static/images/bookService/examination/reset.png"></t-image> 重做 </view> <view class="bottom-submit"> <t-button theme="primary" size="large" style="{{btnStyle}}" bind:tap="submitBtn" >{{(answerType == 'option' || answerType == 'mock') ? '提交' : '退出'}}</t-button > <t-button theme="primary" size="large" style="{{btnStyle}}" bind:tap="submitBtn">{{(answerType == 'option' || answerType == 'mock') && !submitStatus ? '提交' : '退出'}}</t-button> </view> </view> <!-- 答题卡 --> <t-popup visible="{{questionCardState}}" bind:visible-change="onVisibleChange" placement="bottom" > <t-popup visible="{{questionCardState}}" bind:visible-change="onVisibleChange" placement="bottom"> <view class="popup-block"> <view class="popup-header"> <view class="popup-title">答题卡</view> @@ -65,14 +47,7 @@ <text class="title-text">{{item.catalogName}}</text> </view> <view class="question-list"> <view bind:tap="goQuestion" data-id="{{citem.id}}" wx:for="{{item.infoList}}" wx:for-item="citem" wx:for-index="cindex" class="question-box {{citem.isComplete ? 'answered' : 'un-answered'}}" > <view bind:tap="goQuestion" data-id="{{citem.id}}" wx:for="{{item.infoList}}" wx:for-item="citem" wx:for-index="cindex" class="question-box {{citem.isUserAnswer ? 'answered' : 'un-answered'}}"> {{citem.number}} </view> </view> @@ -82,34 +57,47 @@ </t-popup> <!-- 设置 --> <t-popup visible="{{setUpPopup}}" bind:visible-change="onSetUpChange" placement="bottom" > <t-popup visible="{{setUpPopup}}" bind:visible-change="onSetUpChange" placement="bottom"> <view class="popup-block set-up-popup"> <view class="popup-header"> <view class="popup-title">设置</view> </view> <!-- 亮度 --> <view> <view class="brightness"> <text>A-</text> <view class="brightness-slider"> <t-slider defaultValue="{{30}}" theme="capsule" /> </view> <text>A+</text> </view> <!-- 模式 --> <view> <t-radio-group class="test-radio" t-class="horizontal-box" value="{{radioItem}}" bind:change="onRadioChange" style="margin: 0px"> <view class="card {{radioItem == 'daytime' ? 'card--active' : ''}}"> <t-radio value="daytime" icon="none" borderless> <view class="radio-content" slot="content"> <t-image src="{{ radioItem == 'daytime' ? '/static/images/bookService/detail/practice-icon.png' : '/static/images/bookService/detail/notest.png'}}"></t-image> <text style="color: {{radioItem == 'daytime' ? '#fff':''}};">日间模式</text> </view> </t-radio> </view> <view class="card {{radioItem == 'night' ? 'card--active' : ''}}"> <t-radio value="night" icon="none" borderless> <view class="radio-content" slot="content"> <t-image src="{{ radioItem == 'night' ? '/static/images/bookService/detail/practice-icon.png' : '/static/images/bookService/detail/notest.png'}}"></t-image> <text style="color: {{radioItem == 'night' ? '#fff':''}};">夜间模式</text> </view> </t-radio> </view> </t-radio-group> </view> </view> </t-popup> <!-- 测试报告 --> <t-dialog class="test-report" visible="{{testReportState}}" cancel-btn="{{null}}" confirm-btn="{{null}}" close-btn="{{true}}" title="测试报告" bind:close="closeTestReportDialog" > <t-dialog class="test-report" visible="{{testReportState}}" cancel-btn="{{null}}" confirm-btn="{{null}}" close-btn="{{true}}" title="测试报告" bind:close="closeTestReportDialog"> <view slot="content" class="test-report"> <view class="report-content-top"> <view class="report-li"> @@ -122,34 +110,24 @@ </view> <view class="report-li"> <view class="report-li-left">其中客观题:</view> <view class="report-li-right" >{{subjectiveTotal}}道,分值{{subjectiveGrade}}分</view > <view class="report-li-right">{{subjectiveTotal}}道,分值{{subjectiveGrade}}分</view> </view> <view class="report-li"> <view class="report-li-left">答对:</view> <view class="report-li-right" ><text class="correct-color">{{correctNum}}</text> 道</view > <view class="report-li-right"><text class="correct-color">{{correctNum}}</text> 道</view> </view> <view class="report-li"> <view class="report-li-left">答错:</view> <view class="report-li-right" ><text class="error-color">{{subjectiveTotal - correctNum}}</text> 道</view > <view class="report-li-right"><text class="error-color">{{subjectiveTotal - correctNum}}</text> 道</view> </view> <view class="report-li"> <view class="report-li-left">客观题得分:</view> <view class="report-li-right" ><text class="score-color">{{subjectiveNum}}</text> 分</view > <view class="report-li-right"><text class="score-color">{{subjectiveNum}}</text> 分</view> </view> </view> <view class="report-content-bottom"> <t-button theme="primary" bind:tap="viewAnswer" style="width: 560rpx" >查看答案与解析</t-button > <t-button theme="primary" bind:tap="viewAnswer" style="width: 560rpx">查看答案与解析</t-button> </view> </view> </t-dialog> packageBookService/pages/bookServices/examination/questionOptions/index.wxss
@@ -185,3 +185,52 @@ .score-color { color: #ff6c00; } .brightness { display: flex; justify-content: space-evenly; align-items: center; margin-bottom: 40rpx; } .brightness-slider { width: 80%; } .test-radio { height: 80rpx; display: flex; justify-content: space-evenly; --td-radio-content-font-size: 28rpx; --td-radio-vertical-padding: 0 } .test-radio image { width: 34rpx; height: 34rpx; } .card { position: relative; border-radius: 10rpx; overflow: hidden; box-sizing: border-box; /* border: 3rpx solid #ff6c00; */ --td-radio-content-color: #0F1214; --td-radio-bg-color: #EFF0F1; } .card--active { border-color: #ff6c00; --td-radio-bg-color: #ff6c00; --td-radio-content-color: #fff; } .radio-content { display: flex; align-items: center; justify-content: center; width: 300rpx; height: 68rpx; } packageBookService/pages/bookServices/examination/questionSchedule/index.js
@@ -24,9 +24,15 @@ answerType: { type: String, value: '' }, isNight:{ type:Boolean, value:false } }, created() { created( ) { }, detached() { }, @@ -37,7 +43,8 @@ data: { showTime: '', // percentage: 0, ready: 0 ready: 0, scheduleStyle: 'back', }, observers: { 'countdownTime': function (newValue) { @@ -58,12 +65,19 @@ }) } } }, 'ready': function (newValue) { this.setData({ percentage: (this.data.ready / this.data.questionList.length) * 100 }) } }, /** * 组件的方法列表 */ methods: { // 夜间和日间模式 // 判断是否有用户答案 isHaveAnswer(data) { if (typeof data == 'string') { packageBookService/pages/bookServices/examination/questionSchedule/index.wxml
@@ -1,15 +1,10 @@ <!--pages/bookServices/examination/questionSchedule/questionSchedule.wxml--> <view class="schedule"> <view class="schedule" id="schedule" style="background-color:{{isNight ? '#000' : '#fff'}}"> <view class="schedule-top"> <view class="question-schedule" >答题进度<text class="parimary-color question-num">{{ready}}</text> <text>/{{questionList.length}}</text></view > <view class="remainder" wx:if="{{!submitStatus && (answerType == 'option' || answerType == 'mock')}}" >剩余时间 <text class="parimary-color">{{showTime}}</text></view > <view class="question-schedule" style="color: {{isNight ? '#fff' : '#000'}};">答题进度<text class="parimary-color question-num">{{ready}}</text> <text>/{{questionList.length}}</text> </view> <view class="remainder" wx:if="{{!submitStatus && (answerType == 'option' || answerType == 'mock')}}" style="color: {{isNight ? '#fff' : '#000'}};">剩余时间 <text class="parimary-color">{{showTime}}</text></view> </view> <view class="schedule-progress"> <t-progress percentage="{{percentage}}" color="#ff6c00" label="" /> static/images/bookService/examination/rijian.png
static/images/bookService/examination/yejian.png