Compare commits
No commits in common. "4afa20808c6ffa61eee86fe78b7bbcd28c4c95a1" and "ada665966649f3bf75371165d0ced9404bbefc31" have entirely different histories.
4afa20808c
...
ada6659666
|
@ -27,9 +27,7 @@ const tableData = ref([])
|
|||
const konwledge = ref([])
|
||||
const hasStudents = ref([])
|
||||
// 获取的所有得分
|
||||
const allScore = ref(0)
|
||||
// 平均分
|
||||
const avatarScore = ref()
|
||||
const allScore = ref([])
|
||||
//所有题目的知识点
|
||||
const getKonwledge = () => {
|
||||
const getScoreRate = []
|
||||
|
@ -43,7 +41,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,point:avatarScore.value})
|
||||
konwledge.value.push({title:title.title,allPoint:allScore.value,id:title.id})
|
||||
}
|
||||
// 判断学生是否答过题
|
||||
if(useOverview.allData[0].hasAnswers.includes(item.studentid))
|
||||
|
@ -53,12 +51,29 @@ 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:(item.point / item.allPoint * 100).toFixed(2),
|
||||
scoingRate:scoreRate.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,() => {
|
||||
|
@ -78,15 +93,6 @@ 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()
|
||||
})
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue