| | |
| | | <div |
| | | v-if=" |
| | | (type == 'option' && examination.submitStatus) || |
| | | type == 'collectQuestion' || |
| | | type == 'errorQuestion' |
| | | type == 'errorQuestion' || type == 'collectQuestion' |
| | | " |
| | | > |
| | | <div class="resolving-btn" @click="showCollaspe()" v-if="!examination.isCollapse"> |
| | |
| | | :cardList="examination.cardList" |
| | | @setCollect="setCollect" |
| | | @onChangeRadio="onChangeRadio" |
| | | @onChangeInput="onChangeInput" |
| | | /> |
| | | </div> |
| | | </li> |
| | |
| | | } else { |
| | | examination.dialogVisible = false |
| | | // handleQuestion() |
| | | if(props.type == 'errorQuestion') { |
| | | if (props.type == 'errorQuestion') { |
| | | handleQuestion() |
| | | } |
| | | examination.cardList = [] |
| | |
| | | getErrorList() |
| | | } else if (props.type == 'collectQuestion') { |
| | | examination.submitStatus = true |
| | | await getcollectId() // 获取收藏题目 |
| | | await getcollectId() // 获取收藏题目id |
| | | // 收藏夹 |
| | | } else if (props.type == 'errorQuestion') { |
| | | examination.submitStatus = true |
| | |
| | | examination.loading = true |
| | | examination.submitStatus = false |
| | | examination.cardList = [] |
| | | examination.collectList = [] |
| | | // examination.collectList = [] |
| | | examination.errorList = [] |
| | | goTop() |
| | | if (props.type == 'option') { |
| | |
| | | const correctQuestion = (num: number, number: number) => { |
| | | const item = examination.cardList[num].infoList[number] |
| | | item.isComplete = true |
| | | //多选判断 |
| | | if (item.questionType == 'multipleChoice') { |
| | | console.log(item.answer,item.userAnswer) |
| | | if (item.answer.length == item.userAnswer.length) { |
| | | const sortedArr1 = item.answer.slice().sort() |
| | | const sortedArr2 = item.userAnswer.slice().sort() |
| | | console.log(sortedArr1,sortedArr2) |
| | | item.isRight = sortedArr1.every((value: string, index: number) => value === sortedArr2[index]) |
| | | } else { |
| | | item.isRight = false |
| | |
| | | } else if (item.questionType == 'singleChoice' || item.questionType == 'judge') { |
| | | // 单选 判断 |
| | | item.isRight = item.answer == item.userAnswer |
| | | } else if (item.questionType == 'shortAnswer') { |
| | | } else if (item.questionType == 'shortAnswer' || item.questionType == 'formula') { |
| | | // 简答 翻译 |
| | | item.isRight = null |
| | | } else if (item.questionType == 'completion') { |
| | |
| | | for (let cindex = 0; cindex < item.infoList.length; cindex++) { |
| | | const citem = item.infoList[cindex] |
| | | console.log(citem) |
| | | |
| | | if (type == 'noshow') { |
| | | citem.isUnfold = '' |
| | | examination.isCollapse = false |
| | | } else { |
| | | citem.questionType == 'shortAnswer' ? (citem.isUnfold = true) : (citem.isUnfold = citem.id) |
| | | // citem.questionType == 'shortAnswer' || citem.questionType == 'formula' ? (citem.isUnfold = true) : (citem.isUnfold = citem.id) |
| | | citem.isUnfold = citem.id |
| | | examination.isCollapse = true |
| | | } |
| | | } |
| | |
| | | examination.submitStatus = true |
| | | } |
| | | // 题目收藏按钮,收藏和取消同一接口,取消数组减去该项id |
| | | const setCollect = (num: number, number: number) => { |
| | | const item = examination.cardList[num].infoList[number] |
| | | const setCollect = (num: number, number?: number) => { |
| | | let item = null |
| | | if (number) { |
| | | item = examination.cardList[num].infoList[number] |
| | | } else { |
| | | item = examination.cardList[num] |
| | | } |
| | | item.isCollect = !item.isCollect |
| | | if (item.isJson) { |
| | | // json题目收藏取消 |
| | |
| | | domain: 'collectData', |
| | | keys: [props.activeBook.bookId] |
| | | }) |
| | | .then((res:any) => { |
| | | .then((res: any) => { |
| | | console.log('收藏数据', res) |
| | | try { |
| | | const collect = JSON.parse(res[0].value) |
| | | if (collect.length) { |
| | | examination.collectList = collect.find((citem:any) => citem.type == 'bits').collectList |
| | | examination.collectList = collect.find((citem: any) => citem.type == 'bits').collectList |
| | | examination.allCollect[0].collectList = collect.find( |
| | | (citem:any) => citem.type == 'bits' |
| | | (citem: any) => citem.type == 'bits' |
| | | ).collectList |
| | | examination.allCollect[1].collectList = collect.find( |
| | | (citem:any) => citem.type == 'json' |
| | | (citem: any) => citem.type == 'json' |
| | | ).collectList |
| | | } |
| | | } catch (error) { |
| | | console.log('暂无数据') |
| | | } |
| | | if (props.type == 'option') { |
| | | getAnswerInfo(async (res:any) => { |
| | | getAnswerInfo(async (res: any) => { |
| | | if (res.length) { |
| | | // 有记录,不能答题,状态设为已提交 |
| | | examination.submitStatus = true |
| | |
| | | } |
| | | } else { |
| | | const userAnswerList = await getUserAnswer() |
| | | if(userAnswerList) { |
| | | if (userAnswerList) { |
| | | examination.cardList = (await getQuestionList(userAnswerList)) as any |
| | | } else { |
| | | examination.cardList = (await getQuestionList([])) as any |
| | |
| | | domain: 'collectData', |
| | | keys: [props.activeBook.bookId] |
| | | }) |
| | | .then(async (res:any) => { |
| | | .then(async (res: any) => { |
| | | try { |
| | | const collect = JSON.parse(res[0].value) |
| | | if (collect.length) { |
| | | examination.collectList = collect.find((citem:any) => citem.type == 'bits').collectList |
| | | examination.collectList = collect.find((citem: any) => citem.type == 'bits').collectList |
| | | examination.allCollect[0].collectList = collect.find( |
| | | (citem:any) => citem.type == 'bits' |
| | | (citem: any) => citem.type == 'bits' |
| | | ).collectList |
| | | examination.allCollect[1].collectList = collect.find( |
| | | (citem:any) => citem.type == 'json' |
| | | (citem: any) => citem.type == 'json' |
| | | ).collectList |
| | | } |
| | | } catch (error) {} |
| | |
| | | } |
| | | // 获取收藏夹 |
| | | const getCollectDataList = async () => { |
| | | console.log('收藏id', examination.allCollect) |
| | | // 开始请求 |
| | | let oldData = null |
| | | let oldList:any = [] |
| | | let oldList: any = [] |
| | | let cardList = [ |
| | | { |
| | | catalogName: '单选题', |
| | |
| | | infoList: [] |
| | | } |
| | | ] |
| | | let singleChoiceArr:any = [] // 单选 |
| | | let judgeArr:any = [] // 判断 |
| | | let shortArr:any = [] // 简答 |
| | | let multipleChoiceArr:any = [] // 多选 |
| | | let completionArr:any = [] // 填空 |
| | | let singleChoiceArr: any = [] // 单选 |
| | | let judgeArr: any = [] // 判断 |
| | | let shortArr: any = [] // 简答 |
| | | let multipleChoiceArr: any = [] // 多选 |
| | | let completionArr: any = [] // 填空 |
| | | // 11 |
| | | for (let qindex = 0; qindex < examination.collectList.length; qindex++) { |
| | | const qitem = examination.collectList[qindex] |
| | | let query = { |
| | | storeInfo: props.activeBook.storeRefcode, |
| | | path: '*', |
| | | cmsPath: props.activeBook.rootCmsItemId, |
| | | cmsType: '*', |
| | | productId: props.activeBook.bookId, |
| | | queryType: '*', |
| | | itemIds: qitem + '', |
| | | 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: [] |
| | | } |
| | | } |
| | | const res = await MG.store.getProductDetail(query) |
| | | if (!res.datas) return false |
| | | res.datas.cmsDatas[0].datas.forEach((item, index) => { |
| | | let oldObj = {} |
| | | if (oldList) { |
| | | oldObj = oldList.find((item) => item.id == qitem) |
| | | } |
| | | 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), // 题干 |
| | | 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.userAnswer |
| | | : item.Embedded_QuestionBank_QuestionType == 'completion' || |
| | | item.Embedded_QuestionBank_QuestionType == 'multipleChoice' |
| | | ? [] |
| | | : '', |
| | | isSubmit: false, // 查看解析 |
| | | isRight: null, // 是否正确 |
| | | isComplete: false, |
| | | isCollect: examination.collectList.indexOf(item.id) > -1 ? true : false, |
| | | isUnfold: '' |
| | | } |
| | | // 多选和填空答案肯为数组,要转换JSON格式 |
| | | if ( |
| | | questionObj.questionType == 'completion' || |
| | | questionObj.questionType == 'multipleChoice' |
| | | ) { |
| | | try { |
| | | questionObj.answer = JSON.parse(questionObj.answer).toString() |
| | | } catch (error) { |
| | | questionObj.answer = item.Embedded_QuestionBank_Answer |
| | | if (qitem) { |
| | | let query = { |
| | | storeInfo: props.activeBook.storeRefcode, |
| | | path: '*', |
| | | cmsPath: props.activeBook.rootCmsItemId, |
| | | cmsType: '*', |
| | | productId: props.activeBook.bookId, |
| | | queryType: '*', |
| | | itemIds: qitem + '', |
| | | 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: [] |
| | | } |
| | | } |
| | | // 填空题改造 |
| | | 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' |
| | | } |
| | | questionObj.userAnswer[index] = '' |
| | | index++ |
| | | const res = await MG.store.getProductDetail(query) |
| | | if (!res.datas) return false |
| | | res.datas.cmsDatas[0].datas.forEach((item, index) => { |
| | | let oldObj = {} |
| | | if (oldList) { |
| | | oldObj = oldList.find((item) => item.id == qitem) |
| | | } |
| | | 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), // 题干 |
| | | 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.userAnswer |
| | | : item.Embedded_QuestionBank_QuestionType == 'completion' || |
| | | item.Embedded_QuestionBank_QuestionType == 'multipleChoice' |
| | | ? [] |
| | | : '', |
| | | isSubmit: false, // 查看解析 |
| | | isRight: null, // 是否正确 |
| | | isComplete: false, |
| | | isCollect: true, |
| | | 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.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { |
| | | questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) |
| | | } |
| | | if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { |
| | | questionObj.option.forEach((optionItem:any) => { |
| | | if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) |
| | | }) |
| | | } |
| | | // 题干富文本处理 |
| | | if (questionObj.stemStyle == 'RichText') { |
| | | // questionObj.option.txt = '' |
| | | questionObj.stem.stemTxt = questionObj.stem.stemTxt |
| | | .replace( |
| | | // 填空题改造 |
| | | 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' |
| | | } |
| | | 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: any) => { |
| | | if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) |
| | | }) |
| | | } |
| | | // 题干富文本处理 |
| | | 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"') |
| | | .replace('../file', requestCtx + '/file') |
| | | } |
| | | // 选项富文本处理 |
| | | if ( |
| | | questionObj.optionStyle == 'RichText' && |
| | | (questionObj.questionType == 'singleChoice' || |
| | | questionObj.questionType == 'judge' || |
| | | questionObj.questionType == 'multipleChoice') |
| | | ) { |
| | | questionObj.option.forEach((item: any) => { |
| | | if (item.txt) |
| | | item.txt = item.txt |
| | | .replace(/\<img/gi, '<img class="option-rich-img"') |
| | | .replace(/\<p/gi, '<p class="stem-rich-p"') |
| | | .replace('../file', requestCtx + '/file') |
| | | }) |
| | | } |
| | | // 解析富文本处理 |
| | | 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" ' |
| | | ) |
| | | .replace(/\<p/gi, '<p class="stem-rich-p"') |
| | | .replace('../file', requestCtx + '/file') |
| | | } |
| | | // 选项富文本处理 |
| | | if ( |
| | | questionObj.optionStyle == 'RichText' && |
| | | (questionObj.questionType == 'singleChoice' || |
| | | questionObj.questionType == 'judge' || |
| | | questionObj.questionType == 'multipleChoice') |
| | | ) { |
| | | questionObj.option.forEach((item:any) => { |
| | | if (item.txt) |
| | | item.txt = item.txt |
| | | .replace(/\<img/gi, '<img class="option-rich-img"') |
| | | .replace(/\<p/gi, '<p class="stem-rich-p"') |
| | | .replace('../file', requestCtx + '/file') |
| | | }) |
| | | } |
| | | // 解析富文本处理 |
| | | 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.questionType == 'singleChoice') { |
| | | // const src = this.extractSourceSrc(questionObj.stem.stemTxt) |
| | | // if (src) { |
| | | // questionObj.src = src |
| | | // questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt) |
| | | // } |
| | | // } |
| | | 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) |
| | | } |
| | | }) |
| | | } |
| | | // 听力题修改 |
| | | // if (questionObj.questionType == 'singleChoice') { |
| | | // const src = this.extractSourceSrc(questionObj.stem.stemTxt) |
| | | // if (src) { |
| | | // questionObj.src = src |
| | | // questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt) |
| | | // } |
| | | // } |
| | | 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) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | // 22 |
| | | cardList[0].infoList = singleChoiceArr |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | console.log('收藏json', jsonCollectList) |
| | | for (let index = 0; index < jsonCollectList.length; index++) { |
| | | const item = jsonCollectList[index] |
| | | if (item.questionType == 'singleChoice') { |
| | | if (item.questionType == 'singleChoice') { |
| | | examination.cardList[0].infoList.push(item) |
| | | } else if (item.questionType == 'judge') { |
| | | examination.cardList[1].infoList.push(item) |
| | |
| | | examination.cardList[2].infoList.push(item) |
| | | } else if (item.questionType == 'completion') { |
| | | examination.cardList[3].infoList.push(item) |
| | | } else if (item.questionType == 'shortAnswer') { |
| | | } else if (item.questionType == 'shortAnswer' || item.questionType == 'formula') { |
| | | examination.cardList[4].infoList.push(item) |
| | | } else if (item.type && item.type == 'material') { |
| | | examination.cardList[examination.cardList.length] = item |
| | |
| | | domain: 'errorData', |
| | | keys: [props.activeBook.bookId] |
| | | }) |
| | | .then(async (res:any) => { |
| | | .then(async (res: any) => { |
| | | try { |
| | | const error = JSON.parse(res[0].value) |
| | | if (error.length) { |
| | | console.log('有吗', error) |
| | | examination.errorList = error.find((citem:any) => citem.type == 'bits').errorList |
| | | examination.allError[0].errorList = error.find((citem:any) => citem.type == 'bits').errorList |
| | | examination.allError[1].errorList = error.find((citem:any) => citem.type == 'json').errorList |
| | | examination.errorList = error.find((citem: any) => citem.type == 'bits').errorList |
| | | examination.allError[0].errorList = error.find( |
| | | (citem: any) => citem.type == 'bits' |
| | | ).errorList |
| | | examination.allError[1].errorList = error.find( |
| | | (citem: any) => citem.type == 'json' |
| | | ).errorList |
| | | } |
| | | } catch (error) {} |
| | | if (examination.allError[0].errorList || examination.allError[1].errorList) { |
| | | if (examination.allError[0].errorList.length || examination.allError[1].errorList.length) { |
| | | examination.cardList = (await getErrorDataList()) as any |
| | | await getJsonError() |
| | | } else { |
| | |
| | | // 获取错题集 |
| | | const getErrorDataList = async () => { |
| | | let oldData = null |
| | | let oldList:any = [] |
| | | let oldList: any = [] |
| | | let cardList = [ |
| | | { |
| | | catalogName: '单选题', |
| | |
| | | infoList: [] |
| | | } |
| | | ] |
| | | let singleChoiceArr:any = [] // 单选 |
| | | let judgeArr:any = [] // 判断 |
| | | let shortArr:any = [] // 简答 |
| | | let multipleChoiceArr:any = [] // 多选 |
| | | let completionArr:any = [] // 填空 |
| | | let singleChoiceArr: any = [] // 单选 |
| | | let judgeArr: any = [] // 判断 |
| | | let shortArr: any = [] // 简答 |
| | | let multipleChoiceArr: any = [] // 多选 |
| | | let completionArr: any = [] // 填空 |
| | | // 11 |
| | | for (let qindex = 0; qindex < examination.errorList.length; qindex++) { |
| | | const qitem = examination.errorList[qindex] |
| | |
| | | } |
| | | const res = await MG.store.getProductDetail(query) |
| | | if (!res.datas) return false |
| | | res.datas.cmsDatas[0].datas.forEach((item:any, index:number) => { |
| | | res.datas.cmsDatas[0].datas.forEach((item: any, index: number) => { |
| | | let oldObj = {} |
| | | if (oldList) { |
| | | oldObj = oldList.find((item:any) => item.id == qitem) |
| | | oldObj = oldList.find((item: any) => item.id == qitem) |
| | | } |
| | | const questionObj = { |
| | | number: index + 1, // 题号 |
| | |
| | | questionObj.questionType == 'multipleChoice' |
| | | ) { |
| | | try { |
| | | questionObj.answer = JSON.parse(questionObj.answer).toString() |
| | | questionObj.answer = JSON.parse(questionObj.answer) |
| | | } catch (error) { |
| | | questionObj.answer = item.Embedded_QuestionBank_Answer |
| | | } |
| | |
| | | questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) |
| | | } |
| | | if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { |
| | | questionObj.option.forEach((optionItem:any) => { |
| | | questionObj.option.forEach((optionItem: any) => { |
| | | if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) |
| | | }) |
| | | } |
| | |
| | | questionObj.questionType == 'judge' || |
| | | questionObj.questionType == 'multipleChoice') |
| | | ) { |
| | | questionObj.option.forEach((item:any) => { |
| | | questionObj.option.forEach((item: any) => { |
| | | if (item.txt) |
| | | item.txt = item.txt |
| | | .replace(/\<img/gi, '<img class="option-rich-img"') |
| | |
| | | for (let cindex = 0; cindex < examination.allError[1].errorList.length; cindex++) { |
| | | const citem = examination.allError[1].errorList[cindex] |
| | | if (item.id == citem) { |
| | | item.isCollect = examination.allCollect[1].collectList.indexOf(item.id) > -1 ? true :false |
| | | item.isCollect = examination.allCollect[1].collectList.indexOf(item.id) > -1 ? true : false |
| | | item.isJson = true |
| | | jsonCollectList.push(item) |
| | | } |
| | |
| | | examination.cardList[2].infoList.push(item) |
| | | } else if (item.questionType == 'completion') { |
| | | examination.cardList[3].infoList.push(item) |
| | | } else if (item.questionType == 'shortAnswer') { |
| | | } else if (item.questionType == 'shortAnswer' || item.questionType == 'formula') { |
| | | examination.cardList[4].infoList.push(item) |
| | | } else if (item.type && item.type == 'material') { |
| | | examination.cardList[examination.cardList.length] = item |
| | |
| | | examination.cardList = examination.cardList.filter((item) => item.infoList.length > 0) |
| | | } |
| | | // 批改题目 (练习,我的做题,我的收藏模式下) |
| | | const handleQuestion = () => { |
| | | const handleQuestion = () => { |
| | | for (let index = 0; index < examination.cardList.length; index++) { |
| | | const item = examination.cardList[index] |
| | | for (let cindex = 0; cindex < item.infoList.length; cindex++) { |
| | |
| | | } else if (citem.questionType == 'singleChoice' || citem.questionType == 'judge') { |
| | | if (citem.id == '63825') console.log('i', item) |
| | | citem.isRight = citem.answer == citem.userAnswer |
| | | } else if (citem.questionType == 'shortAnswer') { |
| | | } else if (citem.questionType == 'shortAnswer' || item.questionType == 'formula') { |
| | | // 简答 翻译 |
| | | citem.isRight = null |
| | | } else if (citem.questionType == 'completion') { |
| | |
| | | } |
| | | } |
| | | } |
| | | if (!citem.isRight && citem.questionType != 'shortAnswer') { |
| | | |
| | | if ( |
| | | !citem.isRight && |
| | | citem.questionType != 'shortAnswer' && |
| | | citem.questionType != 'formula' |
| | | ) { |
| | | // 客观题回答错误 记录错题 |
| | | if (citem.isJson) { |
| | | if ( |
| | |
| | | } |
| | | ] |
| | | }) |
| | | .then((res:any) => { |
| | | .then((res: any) => { |
| | | console.log('错题已保存', examination.allError) |
| | | }) |
| | | if (props.type == 'option') { |
| | | recordAnswerData() |
| | | } |
| | | console.log('提交错题',examination.errorList,examination.allError); |
| | | |
| | | console.log('提交错题', examination.errorList, examination.allError) |
| | | } |
| | | // 处理答题数据 |
| | | const recordAnswerData = () => { |
| | |
| | | } |
| | | // 未提交保存答案方法 |
| | | const saveAnswerData = () => { |
| | | let arr = [] |
| | | let arr = [] |
| | | for (let index = 0; index < examination.cardList.length; index++) { |
| | | const item = examination.cardList[index]; |
| | | const item = examination.cardList[index] |
| | | for (let cindex = 0; cindex < item.infoList.length; cindex++) { |
| | | const citem = item.infoList[cindex]; |
| | | if(citem.userAnswer && citem.userAnswer.length) { |
| | | const citem = item.infoList[cindex] |
| | | if (citem.userAnswer && citem.userAnswer.length) { |
| | | arr.push({ |
| | | id:citem.id, |
| | | userAnswer:citem.userAnswer |
| | | id: citem.id, |
| | | userAnswer: citem.userAnswer |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | console.log('用户答案',arr); |
| | | console.log('用户答案', arr) |
| | | setUserAnswer(arr) |
| | | } |
| | | // 未提交退出答题,保存用户答案 |
| | | const setUserAnswer = (data:any) => { |
| | | const setUserAnswer = (data: any) => { |
| | | MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [ |
| | |
| | | } |
| | | ] |
| | | }) |
| | | .then((res:any) => { |
| | | .then((res: any) => { |
| | | console.log('提交用户答题数据成功') |
| | | }) |
| | | } |
| | | // 获取未提交退出答题的用户答案 |
| | | const getUserAnswer = async() => { |
| | | const getUserAnswer = async () => { |
| | | let data |
| | | await MG.identity |
| | | .getUserKey({ |
| | | domain: 'beforeAnswerData', |
| | | keys: [props.info.id] |
| | | }) |
| | | .then((res:any) => { |
| | | if(res.length) { |
| | | .then((res: any) => { |
| | | if (res.length) { |
| | | data = JSON.parse(res[0].value) |
| | | } |
| | | }) |
| | | return data |
| | | } |
| | | return data |
| | | } |
| | | // 获取用户旧答题数据(提交后) |
| | | const getAnswerInfo = (callback:any) => { |
| | | const getAnswerInfo = (callback: any) => { |
| | | MG.identity |
| | | .getUserKey({ |
| | | domain: 'answerData', |
| | | keys: [props.info.id] |
| | | }) |
| | | .then((res:any) => { |
| | | .then((res: any) => { |
| | | if (callback) callback(res) |
| | | }) |
| | | } |
| | |
| | | } |
| | | ] |
| | | }) |
| | | .then((res:any) => { |
| | | .then((res: any) => { |
| | | console.log('提交用户答题数据成功') |
| | | }) |
| | | } |
| | | // 删除用户答题数据 |
| | | const deleteAnswerInfo = (callback:any) => { |
| | | const deleteAnswerInfo = (callback: any) => { |
| | | MG.identity |
| | | .delUserKey({ |
| | | domain: 'answerData', |
| | | keys: [props.info.id] |
| | | }) |
| | | .then((res:any) => { |
| | | .then((res: any) => { |
| | | if (callback) callback() |
| | | }) |
| | | } |
| | |
| | | } |
| | | ] |
| | | }) |
| | | .then((res:any) => { |
| | | .then((res: any) => { |
| | | console.log('收藏/取消成功') |
| | | }) |
| | | } |
| | |
| | | } |
| | | ] |
| | | }) |
| | | .then((res:any) => { |
| | | .then((res: any) => { |
| | | console.log('错题已清空') |
| | | }) |
| | | } |
| | | const onChangeInput = (value: any, index: number, cindex: number, dindex: number) => { |
| | | examination.cardList[index].infoList[cindex].userAnswer[dindex] = value |
| | | } |
| | | defineExpose({ handleExaminationDialog }) |
| | | </script> |
| | |
| | | .examintaion-box { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | li:last-child { |
| | | flex: 1; |
| | | } |
| | | .examintaion-box-list { |
| | | padding-right: 10px; |
| | | height: 850px; |