| | |
| | | import { |
| | | getPublicImage |
| | | } from "../../../../assets/js/middleGround/tool"; |
| | | import { |
| | | loginInfo |
| | | } from '../../../../assets/js/login'; |
| | | const app = getApp(); |
| | | Page({ |
| | | /** |
| | |
| | | countdownInterval: null, // 计时器 |
| | | isCountdownRunning: true, // 是否倒计时 |
| | | countdownTime: 0, // 倒计时时间 |
| | | storeInfo: '', |
| | | jslx: '', |
| | | bookId: "", |
| | | productLinkPath: "", |
| | | rootCmsItemId: "", |
| | |
| | | sliderValue: 0, // 字体滑块 |
| | | startTime: "", //进入页面当前时间 |
| | | pauseTime: 0, //暂停时间 |
| | | showDialog: false // 未提交退出拦截弹窗 |
| | | showDialog: false, // 未提交退出拦截弹窗 |
| | | showId: '', |
| | | isShowDialog: false, // 测试报告弹窗是否显示 |
| | | }, |
| | | |
| | | /** |
| | |
| | | rootCmsItemId: options.rootCmsItemId, |
| | | idPathList: options.idPathList ? JSON.parse(options.idPathList) : [], |
| | | answerType: options.answerType, |
| | | storeInfo: options.storeInfo, |
| | | jslx: options.jslx, |
| | | }); |
| | | // wx.setNavigationBarTitle({ |
| | | // title: options.answerTitle, |
| | | // }) |
| | | wx.setNavigationBarTitle({ |
| | | title: options.answerTitle, |
| | | }) |
| | | if (this.data.answerType == "mock") { |
| | | this.setData({ |
| | | uuid: options.uuid, |
| | | mockid: options.mockid, |
| | | }); |
| | | } |
| | | this.init(); |
| | | |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | this.init(); |
| | | } else { |
| | | this.init(); |
| | | } |
| | | }) |
| | | } else { |
| | | this.init() |
| | | } |
| | | |
| | | }, |
| | | |
| | | /** |
| | |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() {}, |
| | | onShareTimeline() {}, |
| | | |
| | | // 监听watch |
| | | watch(context, variableName, callback) { |
| | |
| | | }, |
| | | }); |
| | | }, |
| | | |
| | | // 修改nav颜色 |
| | | changeNavBarColor(e) { |
| | | if (type == 'night') { |
| | | wx.setNavigationBarColor({ |
| | | backgroundColor: '#000000', |
| | | frontColor: '#ffffff', |
| | | }) |
| | | } else { |
| | | wx.setNavigationBarColor({ |
| | | backgroundColor: '#ffffff', |
| | | frontColor: '#000000', |
| | | }) |
| | | } |
| | | }, |
| | | // 正则找出听力src |
| | | extractSourceSrc(htmlString) { |
| | | // 正则表达式匹配<source>标签中的src属性值 |
| | |
| | | }, |
| | | // 返回拦截 |
| | | beforeleave() { |
| | | wx.showModal({ |
| | | title: "提示", |
| | | content: "未提交,是否退出答题", |
| | | confirmColor: "#ff6c00", |
| | | cancelColor: "#949494", |
| | | complete: (res) => { |
| | | if (res.cancel) { |
| | | this.setData({ |
| | | showDialog: true |
| | | }) |
| | | } |
| | | if (res.confirm) { |
| | | this.setData({ |
| | | submitStatus: true, |
| | | showDialog: false |
| | | }); |
| | | wx.navigateBack(); |
| | | } |
| | | }, |
| | | }); |
| | | if ((this.data.answerType == 'option' || this.data.answerType == 'mock') && !this.data.submitStatus) { |
| | | wx.showModal({ |
| | | title: "提示", |
| | | content: "未提交,是否退出答题", |
| | | confirmColor: "#ff6c00", |
| | | cancelColor: "#949494", |
| | | complete: (res) => { |
| | | if (res.cancel) { |
| | | this.setData({ |
| | | showDialog: true |
| | | }) |
| | | } |
| | | if (res.confirm) { |
| | | this.setData({ |
| | | submitStatus: true, |
| | | showDialog: false |
| | | }); |
| | | wx.navigateBack(); |
| | | } |
| | | }, |
| | | }); |
| | | } |
| | | }, |
| | | onChangeSlider(e) { |
| | | this.setData({ |
| | |
| | | }, |
| | | //设置背景色 |
| | | changeBGColor(e) { |
| | | const flag = e.detail.value |
| | | this.setData({ |
| | | isNight: e.detail.value, |
| | | isNight: flag, |
| | | }); |
| | | if (flag) { |
| | | wx.setNavigationBarColor({ |
| | | backgroundColor: '#000000', |
| | | frontColor: '#ffffff', |
| | | }) |
| | | } else { |
| | | wx.setNavigationBarColor({ |
| | | backgroundColor: '#ffffff', |
| | | frontColor: '#000000', |
| | | }) |
| | | } |
| | | }, |
| | | // 获取保存的倒计时时间 |
| | | getSavedTime() { |
| | |
| | | }, |
| | | // 切换题目 |
| | | changeSwiper(e) { |
| | | this.setData({ |
| | | currentIndex: e.detail.index, |
| | | }); |
| | | let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0; |
| | | const item = this.data.questionDataList[index]; |
| | | const lastItem = this.data.questionDataList[index + 1]; |
| | | this.setData({ |
| | | currentIndex: e.detail.index, |
| | | showId: lastItem.id |
| | | }); |
| | | if ( |
| | | (this.data.answerType == "collectQuestion" || |
| | | this.data.answerType == "errorQuestion") && |
| | |
| | | const inputData = e.detail.value.detail.value; |
| | | const id = e.detail.value.currentTarget.dataset.id; |
| | | const index = Number(e.detail.value.currentTarget.dataset.index); |
| | | console.log(index); |
| | | const questionList = this.data.questionDataList; |
| | | questionList.forEach((item) => { |
| | | if (item.id == id) { |
| | |
| | | // 提交逻辑 |
| | | submitPaper() { |
| | | this.setData({ |
| | | showDialog: false, |
| | | submitStatus: true, |
| | | loading: true, |
| | | }); |
| | | const child = this.selectComponent("#question-options"); |
| | | const child = this.selectComponent('#question-options'); |
| | | |
| | | if ( |
| | | this.data.answerType == "option" || |
| | | this.data.answerType == "errorQuestion" || |
| | |
| | | if (this.data.answerType == "option") { |
| | | this.toggleCountdown(); |
| | | this.recordAnswerData(); |
| | | child.openTestReportDialog(); |
| | | // this.selectComponent 拿不到 组件了, 改为监听组件传值 打开弹窗 |
| | | // child.openTestReportDialog(); |
| | | this.setData({ |
| | | isShowDialog: true |
| | | }) |
| | | } else if ( |
| | | this.data.answerType == "collectQuestion" || |
| | | this.data.answerType == "errorQuestion" |
| | |
| | | }), |
| | | }, ], |
| | | }); |
| | | child.openTestReportDialog(); |
| | | // child.openTestReportDialog(); |
| | | this.setData({ |
| | | isShowDialog: true |
| | | }) |
| | | } |
| | | this.setData({ |
| | | loading: false, |
| | | showDialog: false, |
| | | }); |
| | | }, |
| | | // 初始化函数 |
| | |
| | | subjectiveNum: 0, |
| | | currentIndex: 0, |
| | | submitStatus: false, |
| | | showDialog: true |
| | | }); |
| | | if (this.data.answerType == "option") { |
| | | this.setData({ |
| | |
| | | let query = { |
| | | path: "*", |
| | | queryType: "*", |
| | | |
| | | productId: this.data.bookId, |
| | | cmsPath: pathitem.productLinkPath, |
| | | itemFields: { |
| | |
| | | size: 999, |
| | | }, |
| | | }; |
| | | if (this.data.storeInfo) { |
| | | query.storeInfo = this.data.storeInfo |
| | | } |
| | | await app.MG.store.getProductDetail(query).then((res) => { |
| | | this.setData({ |
| | | total: res.datas.cmsDatas[0].datas.length, |
| | |
| | | }); |
| | | } |
| | | res.datas.cmsDatas[0].datas.forEach((item, index) => { |
| | | if (this.data.storeInfo || this.data.jslx) { |
| | | if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') { |
| | | pathitem.name = "单选题" |
| | | } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') { |
| | | pathitem.name = "简答题" |
| | | } else if (item.Embedded_QuestionBank_QuestionType == "completion") { |
| | | pathitem.name = "填空题"; |
| | | } else if (item.Embedded_QuestionBank_QuestionType == "multipleChoice") { |
| | | pathitem.name = "多选题"; |
| | | } else if (item.Embedded_QuestionBank_QuestionType == "judge") { |
| | | pathitem.name = "判断题"; |
| | | } |
| | | } |
| | | let oldObj = ""; |
| | | if (oldList) |
| | | oldObj = oldList.find((oldItem) => oldItem.id == item.id); |
| | |
| | | questionDataList: questionList, |
| | | cardList: cardUpdatedList, |
| | | }); |
| | | console.log( |
| | | '题目', this.data.questionDataList |
| | | ); |
| | | }); |
| | | }); |
| | | } |
| | |
| | | } |
| | | this.setData({ |
| | | loading: false, |
| | | showId: this.data.questionDataList[0].id |
| | | }); |
| | | }, |
| | | // 批改题目 (练习,我的错题,我的收藏,,组卷) |
| | |
| | | // 简答 翻译 |
| | | questionList[index].isRight = null; |
| | | } else if (item.questionType == "completion") { |
| | | if (item.answer == "string") { |
| | | if (typeof item.answer == "string") { |
| | | item.isRight = item.answer == item.userAnswer[0]; |
| | | } else { |
| | | if (item.answer.length != item.userAnswer.length) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.setAnswerInfo(setInfoData); |
| | | }, |
| | | // 提交答题数据 |
| | |
| | | Embedded_QuestionBank_Difficulty: [], |
| | | }, |
| | | }; |
| | | if (this.data.storeInfo) { |
| | | query.storeInfo = this.data.storeInfo |
| | | } |
| | | await app.MG.store.getProductDetail(query).then((res) => { |
| | | let questionArr = []; |
| | | res.datas.cmsDatas[0].datas.forEach((item, index) => { |
| | |
| | | } |
| | | this.setData({ |
| | | questionDataList: questionArr, |
| | | showId: questionArr[0].id, |
| | | cardList: cardList, |
| | | loading: false, |
| | | }); |
| | |
| | | Embedded_QuestionBank_Difficulty: [], |
| | | }, |
| | | }; |
| | | if (this.data.storeInfo) { |
| | | query.storeInfo = this.data.storeInfo |
| | | } |
| | | await app.MG.store.getProductDetail(query).then((res) => { |
| | | let questionArr = []; |
| | | res.datas.cmsDatas[0].datas.forEach((item, index) => { |
| | |
| | | } |
| | | this.setData({ |
| | | questionDataList: questionArr, |
| | | showId: questionArr[0].id, |
| | | cardList: cardList, |
| | | loading: false, |
| | | }); |
| | | }); |
| | | // loadings.value = false |
| | | }, |
| | | // 获取组卷结果 |
| | | async getEduQuizConfig() { |
| | |
| | | Embedded_QuestionBank_Difficulty: [], |
| | | }, |
| | | }; |
| | | if (this.data.storeInfo) { |
| | | query.storeInfo = this.data.storeInfo |
| | | } |
| | | await app.MG.store.getProductDetail(query).then((res) => { |
| | | res.datas.cmsDatas[0].datas.forEach((item, index) => { |
| | | // 循环questionList,给每题赋值分数 |
| | |
| | | } |
| | | this.setData({ |
| | | loading: false, |
| | | showId: this.data.questionDataList[0].id |
| | | }); |
| | | }, |
| | | // 获取组卷数据 |