diff --git a/src/renderer/src/components/exam-question/examDetailsDrawer.vue b/src/renderer/src/components/exam-question/examDetailsDrawer.vue new file mode 100644 index 0000000..12de43c --- /dev/null +++ b/src/renderer/src/components/exam-question/examDetailsDrawer.vue @@ -0,0 +1,74 @@ + + + + + + \ No newline at end of file diff --git a/src/renderer/src/components/set-homework/index.vue b/src/renderer/src/components/set-homework/index.vue index 17127b8..08b92a8 100644 --- a/src/renderer/src/components/set-homework/index.vue +++ b/src/renderer/src/components/set-homework/index.vue @@ -259,9 +259,10 @@ const onSubmit = (formEl) => { classworkarray: JSON.stringify(ary) }) .then((res) => { + setLoading.value = false ElMessage.success('操作成功') - emit('on-success', res.data) + emit('on-success', res) cloneDialog(formEl) }) .catch(() => { 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 diff --git a/src/renderer/src/store/modules/overview.js b/src/renderer/src/store/modules/overview.js index 46f58f6..40acf50 100644 --- a/src/renderer/src/store/modules/overview.js +++ b/src/renderer/src/store/modules/overview.js @@ -4,13 +4,18 @@ const overviewStore = defineStore( { state: () => { return { - tableList:[] + tableList:[], + allData:[] } }, actions: { getTableList(data){ this.tableList = [...data] - } + }, + //整理的所有列表 + getAllData(data){ + this.allData = [...data] + } } }) export default overviewStore diff --git a/src/renderer/src/utils/chat.js b/src/renderer/src/utils/chat.js index b3b06a8..aaefa2c 100644 --- a/src/renderer/src/utils/chat.js +++ b/src/renderer/src/utils/chat.js @@ -18,13 +18,13 @@ export class Chat { } return Chat.instance; } - /** - * 初始化 获取IM签名 - * @param {*} isInit : 是否初始化IM - * @param {*} isLogin : 是否登录IM - * @param {*} callback: 监听消息回调函数 - * @returns Promise - */ + /** + * 初始化 获取IM签名 + * @param {*} isInit : 是否初始化IM + * @param {*} isLogin : 是否登录IM + * @param {*} callback: 监听消息回调函数 + * @returns Promise + */ async init(isInit = true, isLogin = true, callback) { // 特殊处理,只传1个参数且为函数,则默认为callback,isInit和isLogin默认为true if (typeof isInit == 'function'){ diff --git a/src/renderer/src/utils/tool.js b/src/renderer/src/utils/tool.js index 0203045..84fc77b 100644 --- a/src/renderer/src/utils/tool.js +++ b/src/renderer/src/utils/tool.js @@ -343,7 +343,7 @@ const eventHandles = (type, win) => { // 监听窗口的激活事件 win.on('focus', async () => { toolState.isTaskWin=true - win&&win.reload(); //刷新该窗口 + // win&&win.reload(); //刷新该窗口 }); // 监听窗口关闭事件 win.on('closed', function () { diff --git a/src/renderer/src/views/classTask/container/classOverview.vue b/src/renderer/src/views/classTask/container/classOverview.vue index b6c6d7e..e3d51b7 100644 --- a/src/renderer/src/views/classTask/container/classOverview.vue +++ b/src/renderer/src/views/classTask/container/classOverview.vue @@ -10,7 +10,7 @@ 等级分布 - + @@ -72,7 +72,6 @@ const props = defineProps({ }, }) let studentList = ref([]) // 学生数据 -const stuHasAnswers = ref([]) // 已经答过题的学生不管对错 // 初始-数据处理 const initData = () => { @@ -81,6 +80,7 @@ const initData = () => { studentList.value = props.activeData.studentList || [] const activeWorkFeedList = props.activeData.workFeedList || [] const quizlist = props.activeData.quizlist || [] + const timeArr = groupByField(props.activeData.workFeedList,'entpcourseworkid') // 习题特殊处理 let data = quizlist.map(o => { // 解析题选项 @@ -91,6 +91,13 @@ const initData = () => { let hasAnswers= [] // 答过题的学生 let timeAnalyse = [] // 平均时长和编号 const quizFeedList = activeWorkFeedList.filter(f => f.entpcourseworkid == o.id) // 做该题的列表 + // 获取所有的做题时间 + timeArr.forEach((item,index) => { + const arr = item.reduce((acc, cur) => { + return acc + (cur.timelength ? Number(cur.timelength) : 0); + },0) + timeAnalyse.push(arr) + }) let children = [] const allStudents = []; if (o.worktype == '单选题') { // '单选题','多选题' @@ -215,12 +222,10 @@ const initData = () => { } // def: 原始题数据 type 类型 active: 选中 points: 得分率, accSum 题解答人数 - return { def: o, id: o.id, type: o.worktype, active: [], points, accSum, rightSum, children,hasAnswers } + return { def: o, id: o.id, type: o.worktype, active: [], points, accSum, rightSum, children,hasAnswers,timeAnalyse } }) - console.log('获取数据: ', data) if (data.length === 0) return - if (!data[0].hasAnswers[0]) return - stuHasAnswers.value = [...data[0].hasAnswers] + useOverview.getAllData([...data]) } // 百分比现在 0-100 const percent = v => v > 1 ? 1 : v < 0 ? 0 : Math.round(v * 100) @@ -233,6 +238,20 @@ const isJson = str => {if(typeof str == 'string'){ if(typeof res == 'object' && res) return true } catch (error) {}}return false } +// 获取到学生的平均回答时间 +const groupByField = (array, field) => { + const groupedMap = {}; + array.forEach(item => { + const key = item[field]; + if (!groupedMap[key]) { + groupedMap[key] = []; + } + groupedMap[key].push(item); + }); + + // 将映射对象转换为二维数组 + return Object.values(groupedMap); +} watch(() => props.tableList,() => { useOverview.getTableList(props.tableList) diff --git a/src/renderer/src/views/classTask/container/classOverview/distribution.vue b/src/renderer/src/views/classTask/container/classOverview/distribution.vue index bf55cd5..ab7a702 100644 --- a/src/renderer/src/views/classTask/container/classOverview/distribution.vue +++ b/src/renderer/src/views/classTask/container/classOverview/distribution.vue @@ -3,26 +3,19 @@ - + - +