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() })