From a0327ad556db442b7e8d1e1d7826934f3aa470c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=A8?= <666> Date: Thu, 31 Oct 2024 14:08:20 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E7=9F=A5=E8=AF=86=E7=82=B9?= =?UTF-8?q?=E5=88=86=E6=95=B0=E8=AE=A1=E7=AE=97;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../container/classOverview/knowledge.vue | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/renderer/src/views/classTask/container/classOverview/knowledge.vue b/src/renderer/src/views/classTask/container/classOverview/knowledge.vue index 0ed7dd4..02ec2a9 100644 --- a/src/renderer/src/views/classTask/container/classOverview/knowledge.vue +++ b/src/renderer/src/views/classTask/container/classOverview/knowledge.vue @@ -27,7 +27,9 @@ const tableData = ref([]) const konwledge = ref([]) const hasStudents = ref([]) // 获取的所有得分 -const allScore = ref([]) +const allScore = ref(0) +// 平均分 +const avatarScore = ref() //所有题目的知识点 const getKonwledge = () => { const getScoreRate = [] @@ -41,7 +43,7 @@ const getKonwledge = () => { if(!ledges.includes(title.id)){ ledges.push(title.id) // 假如分数是0 或者 得分率为空 - konwledge.value.push({title:title.title,allPoint:allScore.value,id:title.id}) + konwledge.value.push({title:title.title,allPoint:allScore.value,id:title.id,point:avatarScore.value}) } // 判断学生是否答过题 if(useOverview.allData[0].hasAnswers.includes(item.studentid)) @@ -51,29 +53,12 @@ const getKonwledge = () => { // 看看有几个知识点 konwledge.value.forEach(item => { - let sunRate = 0 - let num = 0 - if(getScoreRate.length === 0) return - - getScoreRate.forEach(item2 => { - if(item.id === item2.id){ - sunRate += extractedNumber(item2.rate) - num ++ - } - }) - const scoreRate = sunRate / num tableData.value.push({ - scoingRate:scoreRate.toFixed(2), + scoingRate:(item.point / item.allPoint * 100).toFixed(2), ...item, - point:(item.allPoint * scoreRate / 100).toFixed(2) }) }) } -// 获取百分比的数字 -const extractedNumber = (score) => { - const match = score.match(/\d+/); - return match ? parseInt(match[0], 10) : null; -} //组装tableList表格 watch(() => useOverview.tableList,() => { @@ -93,6 +78,15 @@ watch(() => useOverview.tableList,() => { allScore.value = useOverview.allData.reduce((acc, cur) => { return acc + Number(cur.score) },0) + // 平均分 + const studentList = useOverview.tableList.filter(item => useOverview.allData[0].hasAnswers.includes(item.studentid)) + avatarScore.value = studentList.reduce((acc, cur) => { + return acc + Number(cur.getScore) + },0) / studentList.length + console.log(avatarScore.value,'useOverview.tableList'); + + + // 计算得分率 getKonwledge() }) -- 2.44.0.windows.1