| | |
| | | import { activeBook } from "@/assets/js/config"; |
| | | import MG from "@/assets/js/middleGround/WebMiddleGroundApi"; |
| | | import getPublicImage from '@/assets/js/middleGround/tool' |
| | | const getQuestionList = (rootCmsItemId, questionList) => { |
| | | let questionArr = []; |
| | | import getPublicImage from "@/assets/js/middleGround/tool"; |
| | | const getQuestionList = (questionList) => { |
| | | let cardList = [ |
| | | { |
| | | catalogName: "单选题", |
| | |
| | | const qitem = questionList[qindex]; |
| | | let query = { |
| | | path: "*", |
| | | cmsPath: rootCmsItemId, |
| | | cmsPath: activeBook.rootCmsItemId, |
| | | cmsType: "*", |
| | | productId: activeBook.bookId, |
| | | queryType: "*", |
| | |
| | | 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), // 题干 |
| | | 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) : "", // 选择题选项 |
| | | 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: item.Embedded_QuestionBank_QuestionType == "completion" || |
| | | item.Embedded_QuestionBank_QuestionType == "multipleChoice" ? [] : "", |
| | | difficulty: item.Embedded_QuestionBank_Difficulty |
| | | ? 4 - item.Embedded_QuestionBank_Difficulty |
| | | : 0, // 难度等级 |
| | | userAnswer: |
| | | item.Embedded_QuestionBank_QuestionType == "completion" || |
| | | item.Embedded_QuestionBank_QuestionType == "multipleChoice" |
| | | ? [] |
| | | : "", |
| | | isSubmit: false, // 查看解析 |
| | | isRight: null, // 是否正确 |
| | | isComplete: false, |
| | | isCollect: true, |
| | | isUnfold:'' |
| | | isUnfold: "", |
| | | }; |
| | | // 多选和填空答案肯为数组,要转换JSON格式 |
| | | if ( |
| | |
| | | /\<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'); |
| | | .replace(/\<p/gi, '<p class="stem-rich-p"') |
| | | .replace("../file", app.config.requestCtx + "/file"); |
| | | } |
| | | // 选项富文本处理 |
| | | if ( |
| | |
| | | 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'); |
| | | .replace(/\<img/gi, '<img class="option-rich-img"') |
| | | .replace(/\<p/gi, '<p class="stem-rich-p"') |
| | | .replace("../file", app.config.requestCtx + "/file"); |
| | | }); |
| | | } |
| | | // 解析富文本处理 |
| | |
| | | if (item.Embedded_QuestionBank_QuestionType == "judge") { |
| | | questionObj.type = "判断题"; |
| | | judgeArr.push(questionObj); |
| | | } else if ( |
| | | item.Embedded_QuestionBank_QuestionType == "singleChoice" |
| | | ) { |
| | | } else if (item.Embedded_QuestionBank_QuestionType == "singleChoice") { |
| | | questionObj.type = "单选题"; |
| | | singleChoiceArr.push(questionObj); |
| | | } else if ( |
| | |
| | | for (let cindex = 0; cindex < item.infoList.length; cindex++) { |
| | | const citem = item.infoList[cindex]; |
| | | citem.number = cindex + 1; |
| | | questionArr.push(citem); |
| | | } |
| | | } |
| | | console.log(cardList); |
| | | return cardList |
| | | return cardList; |
| | | }; |
| | | |
| | | export default getQuestionList; |
| | | const getQuestionData = (chapterData) => { |
| | | const data = { ...chapterData }; |
| | | for (let key in chapterData) { |
| | | data[key] = getQuestionList(chapterData[key]); |
| | | } |
| | | return data; |
| | | }; |
| | | |
| | | export default getQuestionData; |