fix:知识点分数计算;

This commit is contained in:
小杨 2024-10-31 14:08:20 +08:00
parent ada6659666
commit a0327ad556
1 changed files with 14 additions and 20 deletions

View File

@ -27,7 +27,9 @@ const tableData = ref([])
const konwledge = ref([]) const konwledge = ref([])
const hasStudents = ref([]) const hasStudents = ref([])
// //
const allScore = ref([]) const allScore = ref(0)
//
const avatarScore = ref()
// //
const getKonwledge = () => { const getKonwledge = () => {
const getScoreRate = [] const getScoreRate = []
@ -41,7 +43,7 @@ const getKonwledge = () => {
if(!ledges.includes(title.id)){ if(!ledges.includes(title.id)){
ledges.push(title.id) ledges.push(title.id)
// 0 // 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)) if(useOverview.allData[0].hasAnswers.includes(item.studentid))
@ -51,29 +53,12 @@ const getKonwledge = () => {
// //
konwledge.value.forEach(item => { 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({ tableData.value.push({
scoingRate:scoreRate.toFixed(2), scoingRate:(item.point / item.allPoint * 100).toFixed(2),
...item, ...item,
point:(item.allPoint * scoreRate / 100).toFixed(2)
}) })
}) })
} }
//
const extractedNumber = (score) => {
const match = score.match(/\d+/);
return match ? parseInt(match[0], 10) : null;
}
//tableList //tableList
watch(() => useOverview.tableList,() => { watch(() => useOverview.tableList,() => {
@ -93,6 +78,15 @@ watch(() => useOverview.tableList,() => {
allScore.value = useOverview.allData.reduce((acc, cur) => { allScore.value = useOverview.allData.reduce((acc, cur) => {
return acc + Number(cur.score) return acc + Number(cur.score)
},0) },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() getKonwledge()
}) })
</script> </script>