From f6f804a09eb5abac7a6f63a83462b2c75eb81be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czouyf=E2=80=9D?= <80906036@qq.com> Date: Thu, 10 Oct 2024 17:32:13 +0800 Subject: [PATCH 1/2] 1 --- src/renderer/src/hooks/useProcessList.js | 207 +------------------- src/renderer/src/views/examReport/index.vue | 6 +- 2 files changed, 7 insertions(+), 206 deletions(-) diff --git a/src/renderer/src/hooks/useProcessList.js b/src/renderer/src/hooks/useProcessList.js index d53f73e..1a1ca4f 100644 --- a/src/renderer/src/hooks/useProcessList.js +++ b/src/renderer/src/hooks/useProcessList.js @@ -305,210 +305,11 @@ export const processList = (row) => { .join('、') row[i].workanswerFormat = answer } + // else { + // // 其余类型试题类型(因学科不同, 大多为主观题类型, 结构为数组) + // row[i].workanswerFormat = workAnswerArr.join('、') + // } } - - /* - //2、处理单选题 - if(row[i].worktype == '单选题' || row[i].worktype == '多选题' ){ - //1.选项前增加ABCD workdesc: "①②#&①③#&②④#&③④" || "
为了活着
#&
为了填报肚子
#&
为了吃饭而吃饭
" - let workDescArr = []; - if(row[i].workdesc.indexOf('[')!==-1 && row[i].workdesc.indexOf(']')!==-1) { - //123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符 - workDescArr = JSON.parse(row[i].workdesc); - } - else if(row[i].workdesc.indexOf('#&')) { - workDescArr = row[i].workdesc.split('#&'); - } - else if(row[i].workdesc.indexOf(',')){ - workDescArr = row[i].workdesc.split(','); - } - else { - // 待考虑 - workDescArr.push(item.workdesc) - } - - - - //2.答案 - 数字转为ABCD - if(row[i].worktype == '单选题') { - const str2Char = String.fromCharCode(65+Number(row[i].workanswer)); - row[i].workanswerFormat = str2Char; - } else if (row[i].worktype == '多选题') { - const answerArr = row[i].workanswer.split('#&'); - let arr2Char = ''; - for(let k=0; k]*>/g, "").split('#&'),'????') - // 填空题答案 - row[i].workanswerFormat = row[i].workanswer.replace(/#&/g,", "); - // 填空选项不需要展示, - row[i].workdescFormat = ''; - } - else if(row[i].worktype == '判断题'){ - // console.log(row[i].workanswer.replace(/<[^>]*>/g, "").split('#&'),'????') - // 判断题答案 - row[i].workanswerFormat = row[i].workanswer.replace(/#&/g,", "); - // 判断选项不需要展示, - row[i].workdescFormat = ''; - } - else if(row[i].worktype == '复合题') { - // 1.选项解析替换 - const options = JSON.parse(row[i].workdesc); - // 题目(背景材料+复合题目) - const bjTitle = row[i].title.split('!@#$%')[0]; - const tmTitles = row[i].title.split('!@#$%').filter((it,ix)=>ix>0); - // console.log(bjTitle,'背景标题'); - // console.log(tmTitles,'复合题目'); - let titls = []; - options.forEach((element,index1) => { - const workDescArr = element.split('#&'); - let tmp = ''; - let j=0; - for(; j`; - } - const char = String.fromCharCode(65+j); - tmp += `
${char}.${jsonArr[j]}
`; - if(j%2 == 1){ - tmp += ''; - } - } - - if(j%2== 0){ - tmp += ''; - } - workdesc = tmp; - } - - row[i].workdescFormat = workdesc; // 题目选项 - - - // 答案处理 - let workanswer = ''; - if(row[i].workanswer && row[i].workanswer != '') { - // 因答案内容存在多种格式: 1.["123","1234"] 2.123#&1234 3.123 - if(row[i].workanswer.indexOf('[')!==-1 && row[i].workanswer.indexOf(']')!==-1) { - //123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符 - let json = JSON.parse(row[i].workanswer); - // 单选、多选 需要 数字转为ABCD - if(row[i].worktype == '单选题') { - const str2Char = String.fromCharCode(65+Number(json[0])); - workanswer = str2Char; - } else if (row[i].worktype == '多选题') { - // const answerArr = row[i].workanswer.split('#&'); - let arr2Char = ''; - for(let k=0; k'; - } - workanswer = arr2Char; - row[i].titleFormat = row[i].titleFormat.replace(/!@#\$%/g, ''); - } else { - workanswer = json.join('、'); - } - } else if(row[i].workanswer.indexOf('#&')) { - // 意味着多个答案或者填空内容 - let workanswerList = row[i].workanswer.split('#&'); - if(row[i].worktype == '多选题') { - // 数字转为ABCD - let arr2Char = ''; - for(let k=0; k { - const arrTmp = item.answer.split('#&'); - let value = `(${indexLabel})`; - arrTmp.forEach((element,i) => { - if(item.type == '单选题' || item.type == '多选题'){ - value += `${String.fromCharCode(65+Number(element))}`; - } - if(item.type == '判断题' || item.type == '填空题'){ - // 去除下 html标签 - value += `${element.replace(/<[^>]+>/g, '')}`+ (i==arrTmp.length-1?'':'、'); - } - }) - arr.push(value); - indexLabel++; - }) - const answer = arr.join('
'); - - row[i].workanswerFormat = answer; - } - else if(row[i].worktype == '主观题') { - // 1.选项解析替换---主观题没选项 - // 题目(背景材料+主观题目) - const bjTitle = row[i].title.split('!@#$%')[0]; - const tmTitles = row[i].title.split('!@#$%').filter((it,ix)=>ix>0); - // console.log(bjTitle,'背景标题'); - // console.log(tmTitles,'主观题目'); - let titls = []; - const s = []; - tmTitles.map((it,ix)=>{ - s.push(it); - }) - // console.log(s,'?????????????????') - - row[i].titleFormat = bjTitle + s.join(''); - // 填空选项不需要展示, - row[i].workdescFormat = ''; - - //2.答案 - // 填空题答案 - const workanswerList = JSON.parse(row[i].workanswer); - let tmp=''; - workanswerList&&workanswerList.map((item,index)=>{ - tmp += '
'+(index+1)+'.'+item.replace(/#&/g, ',')+'
'; - }) - row[i].workanswerFormat = tmp; - - } - else { - //处理答案 - row[i].workanswerFormat = '见试题解答内容'; - } - */ } } } diff --git a/src/renderer/src/views/examReport/index.vue b/src/renderer/src/views/examReport/index.vue index 37d73e2..e45fa83 100644 --- a/src/renderer/src/views/examReport/index.vue +++ b/src/renderer/src/views/examReport/index.vue @@ -75,7 +75,7 @@ import { ArrowRight } from '@element-plus/icons-vue' import useResoureStore from '@/views/resource/store' import ChooseTextbook from '@/components/choose-textbook/index.vue' import {listEntpcoursework, listEntpcourseworkNew} from '@/api/education/entpCourseWork' -import {processExamQuestion} from '@/utils/examQuestion/tool' +import { processList } from '@/hooks/useProcessList' import { JYApiListCT} from "@/utils/examQuestion/jyeoo" import examReview from './container/examReview.vue' @@ -154,7 +154,7 @@ const getData = async (data) => { listExamQuestion.value = res.data; // queryParams.total = res.total; // 格式化试题 - processExamQuestion(listExamQuestion.value); + processList(listExamQuestion.value); loading.value = false; } @@ -222,7 +222,7 @@ const queryExamQuestionByParams = async () => { listExamQuestion.value = res.data; // queryParams.total = res.total; // 格式化试题 - processExamQuestion(listExamQuestion.value); + processList(listExamQuestion.value); loading.value = false; } From cd5abd864d50a91e9a584c8df8ef3c2f0ff1d17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czouyf=E2=80=9D?= <80906036@qq.com> Date: Fri, 11 Oct 2024 16:03:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E8=80=83=E8=AF=95=E5=88=86=E6=9E=90]=20-?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E9=9D=9E=E7=BB=91=E5=AE=9A=E8=8F=81?= =?UTF-8?q?=E4=BC=98=E7=BD=91=E7=AB=A0=E8=8A=82=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=AF=95=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/choose-textbook/index.vue | 3 +- src/renderer/src/views/examReport/index.vue | 58 +++++++++++-------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/renderer/src/components/choose-textbook/index.vue b/src/renderer/src/components/choose-textbook/index.vue index 028cd02..3c4414d 100644 --- a/src/renderer/src/components/choose-textbook/index.vue +++ b/src/renderer/src/components/choose-textbook/index.vue @@ -49,7 +49,7 @@ import { useGetSubject } from '@/hooks/useGetSubject' const BaseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH // 定义要发送的emit事件 -const emit = defineEmits(['nodeClick']) +const emit = defineEmits(['nodeClick', 'changeBook']) let useSubject = null const subjectList = ref([]) const dialogVisible = ref(false) @@ -164,7 +164,6 @@ const handleNodeClick = (data) => { sessionStore.set('subject.defaultExpandedKeys', defaultExpandedKeys) sessionStore.set('subject.curNode', nodeData) emit('nodeClick', curData) - } onMounted( async () => { treeLoading.value = true diff --git a/src/renderer/src/views/examReport/index.vue b/src/renderer/src/views/examReport/index.vue index e45fa83..9a4c791 100644 --- a/src/renderer/src/views/examReport/index.vue +++ b/src/renderer/src/views/examReport/index.vue @@ -58,8 +58,8 @@ v-else-if="curTask.viewkey=='考点分析' " /> - @@ -81,6 +81,7 @@ import { JYApiListCT} from "@/utils/examQuestion/jyeoo" import examReview from './container/examReview.vue' import pointAnalysis from './container/pointAnalysis.vue' import examMocks from './container/examMocks.vue' +import { ElMessage } from 'element-plus' const {proxy} = getCurrentInstance(); const sourceStore = useResoureStore(); @@ -106,6 +107,19 @@ const listWorkType = ref([{ value: 0, }]); +const getCourseWorkList = async (params) => { + const res = await listEntpcourseworkNew(params); + if(res.data == null) { + listExamQuestion.value = []; + // queryParams.total = 0 + return; + } + listExamQuestion.value = res.data; + // queryParams.total = res.total; + // 格式化试题 + processList(listExamQuestion.value); +} + /** * @desc: 选中单元章节后的回调, 获取单元章节信息 * @return: {*} @@ -134,6 +148,15 @@ const getData = async (data) => { // const res = await listEntpcoursework(params); // listExamQuestion.value = res.rows; + // 当前不存在对应绑定的菁优网章节id时, 不进行处理 + // 注意: 菁优网章节id绑定需在网页端[/evaluation/bind]中进行绑定 + if (curNode.value.bookId == null || curNode.value.bookId == '' || curNode.value.bookId == '0') { + listExamQuestion.value = []; + loading.value = false; + ElMessage.error("当前单元/章节下无试题"); + return; + } + // 查询本地+菁优网(后端处理) const params = { eid: curNode.value.id, @@ -144,17 +167,7 @@ const getData = async (data) => { edustage: curNode.value.edustage, sectionName: curNode.value.itemtitle, } - const res = await listEntpcourseworkNew(params); - if(res.data == null) { - listExamQuestion.value = []; - // queryParams.total = 0 - loading.value = false; - return; - } - listExamQuestion.value = res.data; - // queryParams.total = res.total; - // 格式化试题 - processList(listExamQuestion.value); + await getCourseWorkList(params); loading.value = false; } @@ -202,6 +215,13 @@ const queryExamQuestionByParams = async () => { // const res = await listEntpcoursework(params); // listExamQuestion.value = res.rows; + if (curNode.value.bookId == null || curNode.value.bookId == '' || curNode.value.bookId == '0') { + listExamQuestion.value = []; + loading.value = false; + ElMessage.error("当前单元/章节下无试题"); + return; + } + // 查询本地+菁优网(后端处理) const params = { eid: curNode.value.id, @@ -212,17 +232,7 @@ const queryExamQuestionByParams = async () => { edustage: curNode.value.edustage, sectionName: curNode.value.itemtitle, } - const res = await listEntpcourseworkNew(params); - if(res.data == null) { - listExamQuestion.value = []; - // queryParams.total = 0 - loading.value = false; - return; - } - listExamQuestion.value = res.data; - // queryParams.total = res.total; - // 格式化试题 - processList(listExamQuestion.value); + await getCourseWorkList(params); loading.value = false; }