| | |
| | | import { getPublicImage } from '../../../../assets/js/middleGround/tool' |
| | | import { |
| | | getPublicImage |
| | | } from '../../../../assets/js/middleGround/tool' |
| | | const app = getApp() |
| | | Page({ |
| | | |
| | |
| | | barHeight: "", |
| | | navBarHeight: "", |
| | | loading: false, |
| | | answerTitle: "", // 导航栏标题 |
| | | countdownInterval: null, // 计时器 |
| | | answerTitle: "", // 导航栏标题 |
| | | countdownInterval: null, // 计时器 |
| | | isCountdownRunning: true, // 是否倒计时 |
| | | countdownTime: 0, // 倒计时时间 |
| | | countdownTime: 0, // 倒计时时间 |
| | | bookId: "", |
| | | productLinkPath: "", |
| | | rootCmsItemId: "", |
| | | idPathList: [], // 题目列表 |
| | | answerType: "", // 答题模式 |
| | | submitStatus: false, // 提交状态 |
| | | idPathList: [], // 题目列表 |
| | | answerType: "", // 答题模式 |
| | | submitStatus: false, // 提交状态 |
| | | currentIndex: 0, // 当前显示的题号 |
| | | collectList: [], // 收藏题目列表 |
| | | errorList: [], // 错题列表 |
| | | subjectiveTotal: 0, // 客观题总数 |
| | | collectList: [], // 收藏题目列表 |
| | | errorList: [], // 错题列表 |
| | | subjectiveTotal: 0, // 客观题总数 |
| | | subjectiveNum: 0, // 客观题得分 |
| | | subjectiveGrade: 0, // 客观题总分 |
| | | correctNum: 0, // 正确题目数量 |
| | | total: 0, // 题目总数 |
| | | cardList: [], // 提交项, |
| | | questionDataList: [], // 显示题目列表 |
| | | correctNum: 0, // 正确题目数量 |
| | | total: 0, // 题目总数 |
| | | cardList: [], // 提交项, |
| | | questionDataList: [], // 显示题目列表 |
| | | mockid: 0, |
| | | uuid: 0, |
| | | mockData: { |
| | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | }, |
| | | onReady() {}, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | }, |
| | | onShareAppMessage() {}, |
| | | |
| | | // 监听watch |
| | | watch(context, variableName, callback) { |
| | |
| | | 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 |
| | |
| | | item.userAnswer = radioChecked |
| | | item.isUserAnswer = this.isHaveAnswer(radioChecked) |
| | | if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) { |
| | | debugger |
| | | let index = this.data.currentIndex - 1 >= 0 ? this.data.currentIndex - 1 : 0 |
| | | this.handleQuestion(index) |
| | | this.handleQuestion(this.data.currentIndex) |
| | | } |
| | | } |
| | | } |
| | |
| | | }, |
| | | // 提交逻辑 |
| | | submitPaper() { |
| | | |
| | | // 关闭退出页面监听 |
| | | wx.disableAlertBeforeUnload() |
| | | this.setData({ |
| | |
| | | }) |
| | | } |
| | | app.MG.identity.setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'mockAnswerData', |
| | | key: this.data.uuid, |
| | | value: JSON.stringify({ |
| | | time: this.data.countdownTime, |
| | | answerData: saveData |
| | | }) |
| | | } |
| | | ] |
| | | setKeyRequests: [{ |
| | | domain: 'mockAnswerData', |
| | | key: this.data.uuid, |
| | | value: JSON.stringify({ |
| | | time: this.data.countdownTime, |
| | | answerData: saveData |
| | | }) |
| | | }] |
| | | }) |
| | | child.openTestReportDialog() |
| | | } |
| | |
| | | }) |
| | | // 测试答题 |
| | | await this.getCollectIdList() // 获取收藏id列表 |
| | | await this.getErrorList() // 获取错题id列表 |
| | | await this.getErrorList() // 获取错题id列表 |
| | | } else if (this.data.answerType == 'collectQuestion') { |
| | | this.setData({ |
| | | submitStatus: true |
| | |
| | | // 组卷模式 |
| | | // 清空答题记录 |
| | | await app.MG.identity.setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'mockAnswerData', |
| | | key: this.data.uuid, |
| | | value: JSON.stringify({ |
| | | time: this.data.countdownTime, |
| | | answerData: [] |
| | | }) |
| | | } |
| | | ] |
| | | setKeyRequests: [{ |
| | | domain: 'mockAnswerData', |
| | | key: this.data.uuid, |
| | | value: JSON.stringify({ |
| | | time: this.data.countdownTime, |
| | | answerData: [] |
| | | }) |
| | | }] |
| | | }) |
| | | this.init() |
| | | } else { |
| | |
| | | this.setData({ |
| | | collectList: JSON.parse(res[0].value) |
| | | }) |
| | | } catch (error) { |
| | | } |
| | | } catch (error) {} |
| | | if (this.data.answerType == 'option') { |
| | | // 先获取用户答题记录 |
| | | this.getAnswerInfo(async (res) => { |
| | |
| | | this.setData({ |
| | | errorList: JSON.parse(res[0].value) |
| | | }) |
| | | } catch (error) { |
| | | } |
| | | } catch (error) {} |
| | | }) |
| | | }, |
| | | // 获取题库题目 |
| | |
| | | // num: index, // 题号 |
| | | id: item.id, |
| | | type: pathitem.name, |
| | | stem: |
| | | item.Embedded_QuestionBank_QuestionType == 'completion' |
| | | ? JSON.parse(item.Embedded_QuestionBank_Stem) |
| | | .stemTxt.replaceAll('<vacancy>', ',input,') |
| | | .split(',') |
| | | : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干 |
| | | 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) |
| | | : '', // 选择题选项 |
| | | 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.userAnswer |
| | | : item.Embedded_QuestionBank_QuestionType == 'completion' || |
| | | item.Embedded_QuestionBank_QuestionType == 'multipleChoice' |
| | | ? [] |
| | | : '', |
| | | difficulty: item.Embedded_QuestionBank_Difficulty ? |
| | | 4 - item.Embedded_QuestionBank_Difficulty : 0, // 难度等级 |
| | | userAnswer: oldObj ? |
| | | oldObj.userAnswer : 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, |
| | |
| | | index++ |
| | | } |
| | | } |
| | | } |
| | | // 题干富文本处理 |
| | | 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 (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { |
| | |
| | | }) |
| | | }, |
| | | // 批改题目 (练习,我的错题,我的收藏,,组卷) |
| | | handleQuestion(num) { |
| | | handleQuestion(index) { |
| | | const questionList = this.data.questionDataList |
| | | const index = num |
| | | if (questionList[index].isComplete) { |
| | | // 题目已完成,跳过 |
| | | return true |
| | |
| | | // 简答 翻译 |
| | | 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] |
| | |
| | | // 记录错题 |
| | | app.MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'errorData', |
| | | key: this.data.rootCmsItemId, |
| | | value: JSON.stringify(this.data.errorList) |
| | | } |
| | | ] |
| | | setKeyRequests: [{ |
| | | domain: 'errorData', |
| | | key: this.data.rootCmsItemId, |
| | | value: JSON.stringify(this.data.errorList) |
| | | }] |
| | | }) |
| | | .then((res) => { |
| | | console.log(res) |
| | |
| | | } |
| | | app.MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'collectData', |
| | | key: this.data.rootCmsItemId, |
| | | value: JSON.stringify(this.data.collectList) |
| | | } |
| | | ] |
| | | setKeyRequests: [{ |
| | | domain: 'collectData', |
| | | key: this.data.rootCmsItemId, |
| | | value: JSON.stringify(this.data.collectList) |
| | | }] |
| | | }) |
| | | .then((res) => { }) |
| | | .then((res) => {}) |
| | | }, |
| | | // 处理答题数据 |
| | | recordAnswerData() { |
| | | this.data.cardList.push( |
| | | { |
| | | name: '客观题得分', |
| | | score: this.data.subjectiveNum, |
| | | path: this.data.productLinkPath, |
| | | // infoList: [], |
| | | // catalogName: '' |
| | | } |
| | | ) |
| | | this.data.cardList.push({ |
| | | name: '客观题得分', |
| | | score: this.data.subjectiveNum, |
| | | path: this.data.productLinkPath, |
| | | // infoList: [], |
| | | // catalogName: '' |
| | | }) |
| | | let setInfoData = { |
| | | currentIndex: this.data.currentIndex, |
| | | dataList: JSON.parse(JSON.stringify(this.data.cardList)) |
| | |
| | | setAnswerInfo(data) { |
| | | app.MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'answerData', |
| | | key: this.data.productLinkPath, |
| | | value: JSON.stringify(data) |
| | | } |
| | | ] |
| | | setKeyRequests: [{ |
| | | domain: 'answerData', |
| | | key: this.data.productLinkPath, |
| | | value: JSON.stringify(data) |
| | | }] |
| | | }) |
| | | .then((res) => { }) |
| | | .then((res) => {}) |
| | | }, |
| | | // 获取答题数据 |
| | | getAnswerInfo(callback) { |
| | |
| | | collectList: JSON.parse(res[0].value) |
| | | }) |
| | | // total.value = collectList.value.length |
| | | } catch (error) { |
| | | } |
| | | } catch (error) {} |
| | | if (this.data.collectList && this.data.collectList.length) { |
| | | await this.getCollectDataList() |
| | | } else { |
| | |
| | | }) |
| | | wx.showModal({ |
| | | title: '提示', |
| | | content: '收藏夹暂无数据',//editable如果为true,这就是输入框的内容 |
| | | editable: false,//是否显示输入框 |
| | | content: '收藏夹暂无数据', //editable如果为true,这就是输入框的内容 |
| | | editable: false, //是否显示输入框 |
| | | showCancel: false, |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | |
| | | // 获取收藏夹 |
| | | async getCollectDataList() { |
| | | let questionArr = [] |
| | | // this.setData({ |
| | | // cardList: [{ |
| | | // catalogName: '收藏夹', |
| | | // infoList: [] |
| | | // }] |
| | | // }) |
| | | this.setData({ |
| | | cardList: [ |
| | | { |
| | | catalogName: '收藏夹', |
| | | infoList: [] |
| | | } |
| | | ] |
| | | cardList: [{ |
| | | 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, |
| | |
| | | const questionObj = { |
| | | number: index + 1, // 题号 |
| | | 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), // 题干 |
| | | 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) |
| | | : '', // 选择题选项 |
| | | 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: |
| | | item.Embedded_QuestionBank_QuestionType == 'completion' || |
| | | item.Embedded_QuestionBank_QuestionType == 'multipleChoice' |
| | | ? [] |
| | | : '', |
| | | difficulty: item.Embedded_QuestionBank_Difficulty ? |
| | | 4 - item.Embedded_QuestionBank_Difficulty : 0, // 难度等级 |
| | | userAnswer: item.Embedded_QuestionBank_QuestionType == 'completion' || |
| | | item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '', |
| | | isSubmit: false, // 查看解析 |
| | | isRight: null, // 是否正确 |
| | | isComplete: false, |
| | |
| | | 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 |
| | | }) |
| | | }) |
| | | }, |
| | |
| | | this.setData({ |
| | | errorList: JSON.parse(res[0].value) |
| | | }) |
| | | } catch (error) { |
| | | } |
| | | } catch (error) {} |
| | | if (this.data.errorList && this.data.errorList.length) { |
| | | this.getErrorDataList() |
| | | } else { |
| | |
| | | }) |
| | | wx.showModal({ |
| | | title: '提示', |
| | | content: '错题集暂无数据',//editable如果为true,这就是输入框的内容 |
| | | editable: false,//是否显示输入框 |
| | | content: '错题集暂无数据', //editable如果为true,这就是输入框的内容 |
| | | editable: false, //是否显示输入框 |
| | | showCancel: false, |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | |
| | | }, |
| | | // 获取错题集 |
| | | async getErrorDataList() { |
| | | // this.setData({ |
| | | // cardList: [{ |
| | | // catalogName: '错题集', |
| | | // infoList: [] |
| | | // }] |
| | | // }) |
| | | this.setData({ |
| | | cardList: [ |
| | | { |
| | | catalogName: '错题集', |
| | | infoList: [] |
| | | } |
| | | ] |
| | | cardList: [{ |
| | | 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, |
| | |
| | | const questionObj = { |
| | | number: index + 1, // 题号 |
| | | 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), // 题干 |
| | | 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) |
| | | : '', // 选择题选项 |
| | | 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: |
| | | item.Embedded_QuestionBank_QuestionType == 'completion' || |
| | | item.Embedded_QuestionBank_QuestionType == 'multipleChoice' |
| | | ? [] |
| | | : '', |
| | | difficulty: item.Embedded_QuestionBank_Difficulty ? |
| | | 4 - item.Embedded_QuestionBank_Difficulty : 0, // 难度等级 |
| | | userAnswer: item.Embedded_QuestionBank_QuestionType == 'completion' || |
| | | item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '', |
| | | isSubmit: false, // 查看解析 |
| | | isRight: null, // 是否正确 |
| | | isComplete: false, |
| | |
| | | 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 |
| | | }) |
| | | }) |
| | |
| | | // 获取必含题目 |
| | | let list = item.cmsItemList.map((idItem) => { |
| | | itemIds.push(idItem.id + '') |
| | | questionIds.push({ id: idItem.id + '', score: idItem.score }) |
| | | questionIds.push({ |
| | | id: idItem.id + '', |
| | | score: idItem.score |
| | | }) |
| | | numberIndex++ |
| | | return { |
| | | number: numberIndex, |
| | |
| | | const extractItem = item.generatorResultList[i] |
| | | let extractItemList = extractItem.cmsItemList.map((extractCmsItem) => { |
| | | itemIds.push(extractCmsItem.id + '') |
| | | questionIds.push({ id: extractCmsItem.id + '', score: extractCmsItem.score }) |
| | | questionIds.push({ |
| | | id: extractCmsItem.id + '', |
| | | score: extractCmsItem.score |
| | | }) |
| | | numberIndex++ |
| | | return { |
| | | number: numberIndex, |
| | |
| | | // 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), // 题干 |
| | | 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) |
| | | : '', // 选择题选项 |
| | | 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' |
| | | ? [] |
| | | : '', |
| | | 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, |
| | |
| | | index++ |
| | | } |
| | | } |
| | | } |
| | | // 题干富文本处理 |
| | | 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"') |
| | | } |
| | | // 选项富文本处理 |
| | | 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"') |
| | | }) |
| | | } |
| | | // 获取图片 |
| | | if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { |
| | |
| | | // 记录购买组卷时间 |
| | | setMockInfo(data) { |
| | | app.MG.identity.setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'mockData', |
| | | key: this.data.bookId + '', |
| | | value: JSON.stringify(data) |
| | | } |
| | | ] |
| | | setKeyRequests: [{ |
| | | domain: 'mockData', |
| | | key: this.data.bookId + '', |
| | | value: JSON.stringify(data) |
| | | }] |
| | | }) |
| | | }, |
| | | // 记录组卷题目列表 |
| | | saveMockQuestionList(data) { |
| | | app.MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'mockQuestionData', |
| | | key: this.data.uuid, |
| | | value: JSON.stringify(data) |
| | | } |
| | | ] |
| | | setKeyRequests: [{ |
| | | domain: 'mockQuestionData', |
| | | key: this.data.uuid, |
| | | value: JSON.stringify(data) |
| | | }] |
| | | }) |
| | | .then((res) => { |
| | | console.log('模考题目列表已记录') |
| | |
| | | // |
| | | app.MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'mockAnswerData', |
| | | key: this.data.uuid, |
| | | value: JSON.stringify({ |
| | | currentIndex: this.data.currentIndex, |
| | | time: this.data.countdownTime, |
| | | answerData: saveData |
| | | }) |
| | | } |
| | | ] |
| | | setKeyRequests: [{ |
| | | domain: 'mockAnswerData', |
| | | key: this.data.uuid, |
| | | value: JSON.stringify({ |
| | | currentIndex: this.data.currentIndex, |
| | | time: this.data.countdownTime, |
| | | answerData: saveData |
| | | }) |
| | | }] |
| | | }) |
| | | .then((res) => { |
| | | this.setData({ |
| | |
| | | }) |
| | | console.log('模考答题数据已记录') |
| | | }) |
| | | }, |
| | | |
| | | // 富文本处理 |
| | | formatRichText(html) { |
| | | console.log(html); |
| | | let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) { |
| | | match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, ''); |
| | | match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, ''); |
| | | match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, ''); |
| | | return match; |
| | | }); |
| | | newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) { |
| | | match = match |
| | | .replace(/<p>/gi, '<p class="p_class">') |
| | | .replace(/width:[^;]+;/gi, 'max-width:100%;') |
| | | .replace(/width:[^;]+;/gi, 'max-width:100%;'); |
| | | return match; |
| | | }); |
| | | newContent = newContent.replace(/<br[^>]*\/>/gi, ""); |
| | | newContent = newContent.replace(/<a>/gi, '<a class="p_class "'); |
| | | newContent = newContent.replace(/<li>/gi, '<li class="p_class "'); |
| | | newContent = newContent.replace(/\<p/gi, '<p class="p_class "'); |
| | | newContent = newContent.replace(/\<span/gi, '<span class="p_class "'); |
| | | newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"'); |
| | | return newContent; |
| | | } |
| | | }) |