Compare commits
No commits in common. "fe078e7ce54052a287bb1e0a7fe5d738b4314ee8" and "4816a4565b01b0aea4719d8dbd636ef16318cb00" have entirely different histories.
fe078e7ce5
...
4816a4565b
|
@ -20,58 +20,82 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import {ref, watch} from 'vue'
|
import {ref, watch} from 'vue'
|
||||||
import overviewStore from '@/store/modules/overview'
|
import overviewStore from '@/store/modules/overview'
|
||||||
|
import {listEntpcoursework} from '@/api/education/entpCourseWork'
|
||||||
|
|
||||||
const useOverview = overviewStore()
|
const useOverview = overviewStore()
|
||||||
const tableData = ref([])
|
const tableData = ref([])
|
||||||
|
//获取题目id
|
||||||
|
const ids = ref('')
|
||||||
|
//总分
|
||||||
|
const allScore = ref(0)
|
||||||
//用来获取所有知识点
|
//用来获取所有知识点
|
||||||
const konwledge = ref([])
|
const konwledge = ref([])
|
||||||
//所有题目的知识点
|
//所有题目的知识点
|
||||||
const getKonwledge = () => {
|
const getKonwledge = () => {
|
||||||
const getScoreRate = []
|
|
||||||
// 获取知识点的种数
|
|
||||||
const ledges = []
|
|
||||||
useOverview.tableList.forEach(item => {
|
useOverview.tableList.forEach(item => {
|
||||||
//判断是否存在知识点
|
|
||||||
if(item.knowledgePoint){
|
if(item.knowledgePoint){
|
||||||
const title = JSON.parse(item.knowledgePoint)
|
konwledge.value.push({...JSON.parse(item.knowledgePoint),...{scoingRate:Number(item.scoingRate),point:item.point,allPoint:allScore.value}})
|
||||||
//判断知识点是否重复
|
|
||||||
if(!ledges.includes(title.id)){
|
|
||||||
ledges.push(title.id)
|
|
||||||
konwledge.value.push({title:title.title,allPoint:item.point,id:title.id})
|
|
||||||
}
|
|
||||||
// 判断学生是否答过题
|
|
||||||
if(useOverview.allData[0].hasAnswers.includes(item.studentid))
|
|
||||||
getScoreRate.push({rate:item.scoingRate,id:title.id})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
tableData.value = getTableList(konwledge.value)
|
||||||
// 看看有几个知识点
|
tableData.value = tableData.value.map(item => {
|
||||||
konwledge.value.forEach(item => {
|
return{
|
||||||
let sunRate = 0
|
|
||||||
let num = 0
|
|
||||||
getScoreRate.forEach(item2 => {
|
|
||||||
if(item.id === item2.id){
|
|
||||||
sunRate += extractedNumber(item2.rate)
|
|
||||||
num ++
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const scoreRate = sunRate / num
|
|
||||||
tableData.value.push({
|
|
||||||
scoingRate:scoreRate.toFixed(2),
|
|
||||||
...item,
|
...item,
|
||||||
point:(item.allPoint * scoreRate / 100).toFixed(2)
|
allPoint: allScore.value
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
|
console.log(tableData.value,'tableData.value')
|
||||||
}
|
}
|
||||||
// 获取百分比的数字
|
//获取总分
|
||||||
const extractedNumber = (score) => {
|
const getScore = async () => {
|
||||||
const match = score.match(/\d+/);
|
const scoreId = useOverview.tableList[0].entpcourseworklist
|
||||||
return match ? parseInt(match[0], 10) : null;
|
const fixedJsonString = `[${scoreId}]`;
|
||||||
|
const objects = JSON.parse(fixedJsonString);
|
||||||
|
const id = objects.map(obj => obj.id);
|
||||||
|
ids.value = id.join(',')
|
||||||
|
const res = await listEntpcoursework({ids: ids.value, pageSize: 500})
|
||||||
|
if(res.code === 200){
|
||||||
|
allScore.value = res.rows.reduce((acc, cur) => acc + cur.workScore, 0);
|
||||||
|
getKonwledge()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//组装tableList表格
|
//组装tableList表格
|
||||||
|
const getTableList = (data) => {
|
||||||
|
const result = [];
|
||||||
|
data.forEach(item => {
|
||||||
|
const existingItem = result.find(i => i.id === item.id);
|
||||||
|
if (existingItem) {
|
||||||
|
// 累加point和scoingRate
|
||||||
|
existingItem.pointTotal += parseInt(item.point);
|
||||||
|
existingItem.scoingRateTotal += parseFloat(item.scoingRate);
|
||||||
|
existingItem.count++;
|
||||||
|
} else {
|
||||||
|
// 新的对象
|
||||||
|
result.push({
|
||||||
|
id: item.id,
|
||||||
|
title: item.title,
|
||||||
|
pointTotal: item.point,
|
||||||
|
scoingRateTotal: parseFloat(item.scoingRate),
|
||||||
|
count: 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 计算平均值
|
||||||
|
result.forEach(item => {
|
||||||
|
item.point = Math.round(item.pointTotal / item.count);
|
||||||
|
// item.scoingRate = Math.round((item.scoingRateTotal / item.count) * 100) / 100;
|
||||||
|
item.scoingRate = Math.round((item.point / allScore.value) * 100);
|
||||||
|
delete item.pointTotal;
|
||||||
|
delete item.scoingRateTotal;
|
||||||
|
delete item.count;
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
watch(() => useOverview.tableList,() => {
|
watch(() => useOverview.tableList,() => {
|
||||||
getKonwledge()
|
console.log(useOverview.tableList,'useOverview.tableList')
|
||||||
|
getScore()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue