From ef75fb75705689af73c3342124cd70093cfc8517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czouyf=E2=80=9D?= <80906036@qq.com> Date: Tue, 22 Oct 2024 14:47:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AF=95=E9=A2=98=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=A0=B7=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/hooks/useProcessList.js | 84 ++++++++++++++---------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/src/renderer/src/hooks/useProcessList.js b/src/renderer/src/hooks/useProcessList.js index 1a1ca4f..e7329eb 100644 --- a/src/renderer/src/hooks/useProcessList.js +++ b/src/renderer/src/hooks/useProcessList.js @@ -15,9 +15,10 @@ export const isJson = (str) => { /** * @description processList 格式化试题 - * @param {*} row + * @param {*} row + * @param {*} aloneOption 选择题中选项是否为每行一个 */ -export const processList = (row) => { +export const processList = (row, aloneOption=false) => { for (var i = 0; i < row.length; i++) { if (isJson(row[i].workanalysis)) { //1、先默认格式化 格式化各项内容(待优化, 后续界面显示的为format的值) @@ -55,19 +56,25 @@ export const processList = (row) => { const workDescArr = element.split('#&') let tmp = '' let j = 0 - for (; j < workDescArr.length; j++) { - if (j % 2 == 0) { - tmp += `
` + for(; j${char}.${workDescArr[j]}
`; } - const char = String.fromCharCode(65 + j) - tmp += `
${char}.${workDescArr[j]}
` - if (j % 2 == 1) { - tmp += '' + else { + if(j%2 == 0){ + tmp += `
`; + } + + tmp += `
${char}.${workDescArr[j]}
`; + if(j%2 == 1){ + tmp += '
'; + } } } // j此刻已自增1, 故当选项为单数时, 需要补充结束标签 - if (j % 2 == 1) { - tmp += '' + if(!aloneOption && j%2 == 1){ + tmp += ''; } // workDescArr为 [''] 表示为 判断题或者填空题,这里不需要选项 @@ -136,31 +143,36 @@ export const processList = (row) => { * ] */ let workDescArr = JSON.parse(row[i].workdesc) - let workDescHtml = `
` workDescArr.map((item, index) => { if (item.type == '单选题' || item.type == '多选题') { - workDescHtml += `
${index + 1}. ${item.title}
` + workDescHtml += `
${index + 1}. ${item.title}
` let tmp = '' let j = 0 let optionsArr = item.options - for (; j < optionsArr.length; j++) { - if (j % 2 == 0) { - tmp += `
` + for(; j${char}.${optionsArr[j]}
`; } - const char = String.fromCharCode(65 + j) - tmp += `
${char}.${optionsArr[j]}
` - if (j % 2 == 1) { - tmp += '
' + else { + if(j%2 == 0){ + tmp += `
`; + } + + tmp += `
${char}.${optionsArr[j]}
`; + if(j%2 == 1){ + tmp += '
'; + } } } // j此刻已自增1, 故当选项为单数时, 需要补充结束标签 - if (j % 2 == 1) { - tmp += '' + if(!aloneOption && j%2 == 1){ + tmp += ''; } - workDescHtml += tmp } else if (item.type == '填空题' || item.type == '判断题' || item.type == '主观题') { - workDescHtml += `
${index + 1}. ${item.title}
` + workDescHtml += `
${index + 1}. ${item.title}
` } }) workDescHtml += '' @@ -265,18 +277,24 @@ export const processList = (row) => { // 处理[选项显示] - 拼接ABCD首序号 let tmp = '' let j = 0 - for (; j < workDescArr.length; j++) { - if (j % 2 == 0) { - tmp += `
` + for(; j${char}.${workDescArr[j]}
`; } - const char = String.fromCharCode(65 + j) - tmp += `
${char}.${workDescArr[j]}
` - if (j % 2 == 1) { - tmp += '' + else { + if(j%2 == 0){ + tmp += `
`; + } + + tmp += `
${char}.${workDescArr[j]}
`; + if(j%2 == 1){ + tmp += '
'; + } } } - if (j % 2 == 0) { - tmp += '' + if(!aloneOption && j%2== 0){ + tmp += ''; } row[i].workdescFormat = tmp -- 2.44.0.windows.1 From cca640e945168a27d77ae2e92975aa9684eb26d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czouyf=E2=80=9D?= <80906036@qq.com> Date: Tue, 22 Oct 2024 16:45:55 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[=E9=80=90=E9=A2=98=E8=AE=B2=E8=AF=84]=20-?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E5=8F=B3=E4=BE=A7=E8=AF=95=E9=A2=98?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/classTask/container/item-dialog.vue | 1 + .../views/classTask/container/quizStats.vue | 83 ++++++++++++++++--- .../src/views/classTask/teachClassTask.vue | 1 + 3 files changed, 72 insertions(+), 13 deletions(-) diff --git a/src/renderer/src/views/classTask/container/item-dialog.vue b/src/renderer/src/views/classTask/container/item-dialog.vue index 819082e..7f7423d 100644 --- a/src/renderer/src/views/classTask/container/item-dialog.vue +++ b/src/renderer/src/views/classTask/container/item-dialog.vue @@ -261,6 +261,7 @@ const openDialog = (data) => { } classWorkAnalysis.quizlist = idres.rows classWorkActiveData.quizlist = idres.rows // zdg: 作业概览组件使用 + processList(classWorkActiveData.quizlist); // 统计每个题目的正误率 // 这个学习任务所有题目+所有学生的答题数据 , pageSize: 100 diff --git a/src/renderer/src/views/classTask/container/quizStats.vue b/src/renderer/src/views/classTask/container/quizStats.vue index de5b73b..70a5c8c 100644 --- a/src/renderer/src/views/classTask/container/quizStats.vue +++ b/src/renderer/src/views/classTask/container/quizStats.vue @@ -1,9 +1,9 @@