| | |
| | | item.isUserAnswer = this.isHaveAnswer(radioChecked) |
| | | } |
| | | }) |
| | | const cardListUpdata = this.data.cardList |
| | | cardListUpdata.forEach(item => { |
| | | item.infoList.forEach(citem => { |
| | | if (citem.id == id) { |
| | | citem.userAnswer = radioChecked |
| | | citem.isUserAnswer = this.isHaveAnswer(radioChecked) |
| | | } |
| | | }) |
| | | }) |
| | | this.setData({ |
| | | questionDataList: questionList |
| | | questionDataList: questionList, |
| | | cardList: cardListUpdata |
| | | }) |
| | | if (this.data.answerType == 'mock') { |
| | | this.setData({ |
| | |
| | | onChangeInput(e) { |
| | | const inputData = e.detail.value.detail.value |
| | | const id = e.detail.value.currentTarget.dataset.id |
| | | const index = e.detail.value.currentTarget.dataset.index |
| | | const index = Number(e.detail.value.currentTarget.dataset.index) |
| | | console.log(index); |
| | | const questionList = this.data.questionDataList |
| | | questionList.forEach(item => { |
| | | if (item.id == id) { |
| | | item.userAnswer[index] = inputData, |
| | | item.isUserAnswer = this.isHaveAnswer(item.userAnswer) |
| | | item.userAnswer[index] = inputData |
| | | return item.isUserAnswer = this.isHaveAnswer(inputData) |
| | | } |
| | | }) |
| | | const cardListUpdata = this.data.cardList |
| | | cardListUpdata.forEach(item => { |
| | | item.infoList.forEach(citem => { |
| | | if (citem.id == id) { |
| | | citem.userAnswer[index] = inputData |
| | | return citem.isUserAnswer = this.isHaveAnswer(inputData) |
| | | } |
| | | }) |
| | | }) |
| | | this.setData({ |
| | | questionDataList: questionList |
| | | questionDataList: questionList, |
| | | cardList: cardListUpdata, |
| | | }) |
| | | if (this.data.answerType == 'mock') { |
| | | this.setData({ |
| | |
| | | errorList: JSON.parse(res[0].value) |
| | | }) |
| | | } catch (error) { |
| | | |
| | | } |
| | | }) |
| | | }, |
| | | // 获取题库题目 |
| | | getQuestionList(oldData) { |
| | | async getQuestionList(oldData) { |
| | | // 清空正确题数记录 |
| | | this.setData({ |
| | | cardList: [], |
| | | correctNum: 0, |
| | | }) |
| | | let flag = 0 |
| | | this.data.idPathList.forEach((pathitem) => { |
| | | for (let index = 0; index < this.data.idPathList.length; index++) { |
| | | const pathitem = this.data.idPathList[index]; |
| | | const pathList = this.data.cardList |
| | | pathList.push({ |
| | | path: pathitem.productLinkPath, |
| | |
| | | size: 999 |
| | | } |
| | | } |
| | | app.MG.store.getProductDetail(query).then((res) => { |
| | | await app.MG.store.getProductDetail(query).then((res) => { |
| | | this.setData({ |
| | | total: res.datas.cmsDatas[0].datas.length |
| | | }) |
| | |
| | | }) |
| | | this.setData({ |
| | | questionDataList: questionList, |
| | | cardList: cardUpdatedList |
| | | cardList: cardUpdatedList, |
| | | }) |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | | this.setData({ |
| | | loading: false, |
| | | loading: false |
| | | }) |
| | | }, |
| | | // 批改题目 (练习,我的错题,我的收藏,,组卷) |
| | |
| | | // 获取组卷题目列表 |
| | | async getMockDataList(questionList, oldList) { |
| | | const questionDataList = this.data.questionDataList |
| | | // for (let pathindex = 0; pathindex < questionList.length; pathindex++) { |
| | | // const pathitem = questionList[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) |
| | | // debugger |
| | | // 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 |
| | | // cardUpdatedList.forEach(aitem => { |
| | | // aitem.infoList.forEach((bitem, bindex) => { |
| | | // questionList.push(bitem) |
| | | // bitem.number = bindex + 1 |
| | | // }) |
| | | // }) |
| | | // this.setData({ |
| | | // questionDataList: questionList, |
| | | // cardList: cardUpdatedList |
| | | // }) |
| | | // console.log('组卷题目列表', this.data.questionDataList); |
| | | // }) |
| | | // }) |
| | | // } |
| | | questionList.forEach(async (pathitem, pathindex) => { |
| | | let itemIds = [] |
| | | pathitem.infoList.forEach(item => { |
| | |
| | | }) |
| | | }) |
| | | this.setData({ |
| | | // questionDataList: questionDataList, |
| | | loading: false |
| | | }) |
| | | }, |