| | |
| | | domain: 'collectData', |
| | | keys: [props.activeBook.bookId] |
| | | }) |
| | | .then((res) => { |
| | | .then((res:any) => { |
| | | console.log('收藏数据', res) |
| | | try { |
| | | const collect = JSON.parse(res[0].value) |
| | | if (collect.length) { |
| | | examination.collectList = collect.find((citem) => citem.type == 'bits').collectList |
| | | examination.collectList = collect.find((citem:any) => citem.type == 'bits').collectList |
| | | examination.allCollect[0].collectList = collect.find( |
| | | (citem) => citem.type == 'bits' |
| | | (citem:any) => citem.type == 'bits' |
| | | ).collectList |
| | | examination.allCollect[1].collectList = collect.find( |
| | | (citem) => citem.type == 'json' |
| | | (citem:any) => citem.type == 'json' |
| | | ).collectList |
| | | } |
| | | } catch (error) { |
| | | console.log('暂无数据') |
| | | } |
| | | if (props.type == 'option') { |
| | | getAnswerInfo(async (res) => { |
| | | getAnswerInfo(async (res:any) => { |
| | | if (res.length) { |
| | | // 有记录,不能答题,状态设为已提交 |
| | | examination.submitStatus = true |
| | |
| | | } |
| | | // 获取收藏夹 |
| | | const getCollectDataList = async () => { |
| | | if (!examination.collectList.length) { |
| | | examination.loading = false |
| | | examination.noData = true |
| | | return false |
| | | } |
| | | // 开始请求 |
| | | let oldData = null |
| | | let oldList = [] |
| | |
| | | |
| | | for (let index = 0; index < jsonCollectList.length; index++) { |
| | | const item = jsonCollectList[index] |
| | | if (item.type && item.type == 'material') { |
| | | examination.cardList.push(item) |
| | | } else 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[3].infoList.push(item) |
| | | } else if (item.questionType == 'shortAnswer') { |
| | | 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) |
| | |
| | | domain: 'errorData', |
| | | keys: [props.activeBook.bookId] |
| | | }) |
| | | .then(async (res) => { |
| | | .then(async (res:any) => { |
| | | try { |
| | | const error = JSON.parse(res[0].value) |
| | | if (error.length) { |
| | | console.log('有吗', error) |
| | | examination.errorList = error.find((citem) => citem.type == 'bits').errorList |
| | | examination.allError[0].errorList = error.find((citem) => citem.type == 'bits').errorList |
| | | examination.allError[1].errorList = error.find((citem) => 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) { |
| | | examination.cardList = (await getErrorDataList()) as any |
| | | await getJsonError() |
| | | } else { |
| | | examination.noData = true |
| | | examination.loading = false |
| | | ElMessageBox.confirm('错题集暂无数据!', '提示', { |
| | | confirmButtonText: '确定', |
| | |
| | | } |
| | | // 获取错题集 |
| | | const getErrorDataList = async () => { |
| | | if (!examination.errorList.length) { |
| | | examination.loading = false |
| | | examination.noData = true |
| | | return false |
| | | } |
| | | // 开始请求 |
| | | let oldData = null |
| | | let oldList = [] |
| | | let oldList:any = [] |
| | | let cardList = [ |
| | | { |
| | | catalogName: '单选题', |
| | |
| | | infoList: [] |
| | | } |
| | | ] |
| | | let singleChoiceArr = [] // 单选 |
| | | let judgeArr = [] // 判断 |
| | | let shortArr = [] // 简答 |
| | | let multipleChoiceArr = [] // 多选 |
| | | let completionArr = [] // 填空 |
| | | 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, index) => { |
| | | res.datas.cmsDatas[0].datas.forEach((item:any, index:number) => { |
| | | let oldObj = {} |
| | | if (oldList) { |
| | | oldObj = oldList.find((item) => item.id == qitem) |
| | | oldObj = oldList.find((item:any) => item.id == qitem) |
| | | } |
| | | const questionObj = { |
| | | number: index + 1, // 题号 |
| | |
| | | questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) |
| | | } |
| | | if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { |
| | | questionObj.option.forEach((optionItem) => { |
| | | questionObj.option.forEach((optionItem:any) => { |
| | | if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) |
| | | }) |
| | | } |
| | |
| | | questionObj.questionType == 'judge' || |
| | | questionObj.questionType == 'multipleChoice') |
| | | ) { |
| | | questionObj.option.forEach((item) => { |
| | | questionObj.option.forEach((item:any) => { |
| | | if (item.txt) |
| | | item.txt = item.txt |
| | | .replace(/\<img/gi, '<img class="option-rich-img"') |
| | |
| | | |
| | | for (let index = 0; index < jsonCollectList.length; index++) { |
| | | const item = jsonCollectList[index] |
| | | if (item.type && item.type == 'material') { |
| | | examination.cardList.push(item) |
| | | } else 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[3].infoList.push(item) |
| | | } else if (item.questionType == 'shortAnswer') { |
| | | 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) |
| | |
| | | } |
| | | ] |
| | | }) |
| | | .then((res) => { |
| | | .then((res:any) => { |
| | | console.log('错题已保存', examination.allError) |
| | | }) |
| | | if (props.type == 'option') { |
| | |
| | | setUserAnswer(arr) |
| | | } |
| | | // 未提交退出答题,保存用户答案 |
| | | const setUserAnswer = (data) => { |
| | | const setUserAnswer = (data:any) => { |
| | | MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [ |
| | |
| | | } |
| | | ] |
| | | }) |
| | | .then((res) => { |
| | | .then((res:any) => { |
| | | console.log('提交用户答题数据成功') |
| | | }) |
| | | } |
| | |
| | | domain: 'beforeAnswerData', |
| | | keys: [props.info.id] |
| | | }) |
| | | .then((res) => { |
| | | .then((res:any) => { |
| | | if(res) { |
| | | data = JSON.parse(res[0].value) |
| | | } |
| | |
| | | return data |
| | | } |
| | | // 获取用户旧答题数据(提交后) |
| | | const getAnswerInfo = (callback) => { |
| | | const getAnswerInfo = (callback:any) => { |
| | | MG.identity |
| | | .getUserKey({ |
| | | domain: 'answerData', |
| | | keys: [props.info.id] |
| | | }) |
| | | .then((res) => { |
| | | .then((res:any) => { |
| | | if (callback) callback(res) |
| | | }) |
| | | } |
| | |
| | | } |
| | | ] |
| | | }) |
| | | .then((res) => { |
| | | .then((res:any) => { |
| | | console.log('提交用户答题数据成功') |
| | | }) |
| | | } |
| | | // 删除用户答题数据 |
| | | const deleteAnswerInfo = (callback) => { |
| | | const deleteAnswerInfo = (callback:any) => { |
| | | MG.identity |
| | | .delUserKey({ |
| | | domain: 'answerData', |
| | | keys: [props.info.id] |
| | | }) |
| | | .then((res) => { |
| | | .then((res:any) => { |
| | | if (callback) callback() |
| | | }) |
| | | } |
| | |
| | | } |
| | | ] |
| | | }) |
| | | .then((res) => { |
| | | .then((res:any) => { |
| | | console.log('收藏/取消成功') |
| | | }) |
| | | } |
| | |
| | | } |
| | | ] |
| | | }) |
| | | .then((res) => { |
| | | console.log('错题已保存', examination.allError) |
| | | .then((res:any) => { |
| | | console.log('错题已清空') |
| | | }) |
| | | } |
| | | defineExpose({ handleExaminationDialog }) |