From 3b9668925cee7a1fd371a5c36e9c149c6ea6346c Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期二, 14 五月 2024 21:17:25 +0800 Subject: [PATCH] 题目 --- src/books/childHealth/view/index.vue | 307 -------------------------------------------------- 1 files changed, 5 insertions(+), 302 deletions(-) diff --git a/src/books/childHealth/view/index.vue b/src/books/childHealth/view/index.vue index a1e4711..7683b14 100644 --- a/src/books/childHealth/view/index.vue +++ b/src/books/childHealth/view/index.vue @@ -6,7 +6,7 @@ <script> import examinations from "./components/examinations/index.vue"; -import { getPublicImage } from "@/assets/js/middleGround/tool"; +import testData from '../assets/examinationList.json' import pageContent from "./content/index.vue"; export default { name: "child-health", @@ -16,6 +16,7 @@ }, data() { return { + bookData:{}, type: "option", idPathList: [], cardList: [], @@ -65,308 +66,10 @@ }, }; this.MG.store.getProductDetail(query).then((res) => { - console.log("鍥句功淇℃伅", res.datas.cmsDatas[0].datas); - const testData = res.datas.cmsDatas[0].datas.find( - (item) => item.refCode == "questionBank" - ); - this.getResourceData(testData); + console.log("鍥句功淇℃伅",res.datas.cmsDatas[0].datas); + this.$data.bookData = res.datas.cmsDatas[0].datas + }); - }, - getResourceData(type) { - let query = { - path: "*", - queryType: "*", - productId: this.config.bookId, - cmsPath: type.productLinkPath, - itemFields: { - SysType: "CmsFolder", - // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁� - selectType: [], - freeFile: [], - file: [], - protectedFile: [], - resourcesClassification: [], - isDownload: [], - jsek_resourceBrief: [], - jsek_link: [], - jsek_questionBank: [], - }, - pading: { - start: 0, - size: 999, - }, - }; - this.MG.store - .getProductDetail(query) - .then(async (res) => { - if (type.refCode == "questionBank") { - const data = res.datas.cmsDatas[0].datas.filter( - (item) => item.refCode == "jsek_questionBank" - ); - if (data.length) return this.getResourceData(data[0]); - } - if (type.refCode == "jsek_questionBank") { - const testDataList = res.datas.cmsDatas[0].datas; - if (testDataList.length > 0) { - // console.log("棰樼洰鍒楄〃", testDataList); - this.$store.commit("setTestList", testDataList); - // this.getIdPathList(testDataList[1]) - } else { - console.log("鏆傛棤璧勬簮"); - } - } - }) - .catch((e) => { - console.log(e); - }); - }, - getIdPathList(data) { - let query = { - path: "*", - queryType: "*", - productId: this.config.bookId, - cmsPath: data.productLinkPath, - pading: { - start: 0, - size: 999, - }, - }; - this.MG.store.getProductDetail(query).then((res) => { - console.log("棰樼洰", res.datas.cmsDatas[0].datas); - this.$data.idPathList = res.datas.cmsDatas[0].datas; - this.getQuestionList(); - }); - }, - // 鑾峰彇棰樺簱棰樼洰 - getQuestionList(oldData) { - // 娓呯┖姝g‘棰樻暟璁板綍 - let flag = 0; - 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, - catalogName: pathitem.name, - infoList: [], - }); - this.$data.cardList = pathList; - // 鑾峰彇棰樼洰 - let query = { - path: "*", - queryType: "*", - productId: this.config.bookId, - cmsPath: pathitem.productLinkPath, - 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: [], - }, - pading: { - start: 0, - size: 999, - }, - }; - this.MG.store.getProductDetail(query).then((res) => { - let oldList; - if (oldData) { - // 鎻愪氦杩囷紝瀛樺湪绛旈璁板綍 - oldList = oldData.find( - (item) => item.path == pathitem.productLinkPath - ).infoList; - this.setData({ - submitStatus: true, - }); - } - res.datas.cmsDatas[0].datas.forEach((item, index) => { - let oldObj = ""; - if (oldList) - oldObj = oldList.find((oldItem) => oldItem.id == item.id); - let questionObj = { - // 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), // 棰樺共 - answer: item.Embedded_QuestionBank_Answer, // 绛旀 - option: item.Embedded_QuestionBank_Option - ? JSON.parse(item.Embedded_QuestionBank_Option) - : "", // 閫夋嫨棰橀�夐」 - analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽 - 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" - ? [] - : "", - isUserAnswer: oldObj - ? this.isHaveAnswer(oldObj.userAnswer) - : false, - isRight: oldObj ? oldObj.isRight : null, - isComplete: oldObj ? oldObj.isComplete : false, - isCollect: false, - isUnfold: "", // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮� - }; - // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲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 (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 == "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", app.config.requestCtx + "/file"); - } - // 閫夐」瀵屾枃鏈鐞� - 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"') - .replace("../file", app.config.requestCtx + "/file"); - }); - } - // 瑙f瀽瀵屾枃鏈鐞� - 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 ( - 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 (questionObj.questionType !== "shortAnswer") { - // this.setData({ - // subjectiveGrade: this.data.subjectiveGrade + 2, - // }); - } - // 鏃ф暟鎹噷 棰樼洰姝g‘ 璁板綍姝g‘鏁伴噺 - if (questionObj.isRight) { - // this.setData({ - // correctNum: this.data.correctNum + 1, - // }); - } - if ( - pathitem.name == "鍒ゆ柇棰�" || - pathitem.name == "濉┖棰�" || - pathitem.name == "澶氶�夐" || - pathitem.name == "鍗曢�夐" || - pathitem.name == "鍚姏棰�" - ) { - if (oldObj) { - // this.setData({ - // subjectiveTotal: this.data.subjectiveTotal + 1, - // }); - } - } - // cardList璧嬪�� - let cardIndex = this.$data.cardList.findIndex( - (item) => item.path == pathitem.productLinkPath - ); - let infoList = this.$data.cardList[cardIndex].infoList; - infoList.push(questionObj); - // this.setData({ - // [`cardList[${cardIndex}].infoList`]: infoList, - // }); - this.$data.cardList[cardIndex].infoList = infoList; - flag++; - let questionList = []; - let grade = 0; - const cardUpdatedList = this.$data.cardList; - // if (flag == this.data.idPathList.length) { - cardUpdatedList.forEach((aitem) => { - aitem.infoList.forEach((bitem, bindex) => { - questionList.push(bitem); - bitem.number = bindex + 1; - bitem.score = 2; - }); - }); - // this.setData({ - // questionDataList: questionList, - // cardList: cardUpdatedList, - // }); - this.$data.cardList = cardUpdatedList; - console.log("棰樼洰鍛�", this.$data.cardList); - }); - }); - } }, getParentWithClass(element, className) { while (element.parentElement) { -- Gitblit v1.9.1