[作业批改] - 优化

This commit is contained in:
“zouyf” 2024-09-26 14:10:27 +08:00
parent 23b9ab3801
commit 4066992aa2
4 changed files with 195 additions and 90 deletions

View File

@ -109,13 +109,13 @@ const changeEndDate = (val) => {
}
//
const getData = () => {
const getData = async () => {
classWorkList.value = []
loading.value = true
// 1
getClassList()
// 2
getClassWorkList()
await getClassWorkList()
// 3
getStudentClassWorkData()
loading.value = false
@ -133,10 +133,10 @@ const getClassList = () => {
/**
* 2获取班级作业
*/
const getClassWorkList = () => {
const getClassWorkList = async () => {
if(classTaskStore.classListIds.length>0){
// homeworklist
listByDeadDate({
const response = await listByDeadDate({
classidarray: classTaskStore.classListIds.join(','),
edituserid: userStore.userId, // id
edustage: userStore.edustage, //
@ -146,63 +146,63 @@ const getClassWorkList = () => {
// orderby: 'concat(deaddate,uniquekey) DESC',
orderby: 'deaddate DESC',
pageSize: 100,
}).then((response) => {
for (var i = 0; i < response.rows.length; i++) {
//
response.rows[i].workdatalist = []
response.rows[i].workdatacount = 0 //
response.rows[i].workdatalistVisible = false
response.rows[i].workdatafeedbackcount = 0 //
response.rows[i].feedtimelength = 0
response.rows[i].rightAnswerCount = 0
response.rows[i].scoingRate = 0 + '%' //
response.rows[i].averagetime = 0 //
// ----------------------------------------------
// UI
if (response.rows[i].worktype == '学习目标定位') {
response.rows[i].workclass = 'success'
response.rows[i].workcodesList = JSON.parse(response.rows[i].workcodes)
} else if (response.rows[i].worktype == '教材研读') {
response.rows[i].workclass = 'primary'
} else if (response.rows[i].worktype == '框架梳理') {
response.rows[i].workclass = 'warning'
} else if (response.rows[i].worktype == '学科定位') {
response.rows[i].workclass = 'info'
} else if (response.rows[i].worktype == '习题训练') {
response.rows[i].workclass = 'danger'
} else {
response.rows[i].workclass = ''
}
//
if (response.rows[i].entpcourseworklist != '') {
response.rows[i].entpcourseworklistarray = JSON.parse(
'[' + response.rows[i].entpcourseworklist + ']'
)
} else {
response.rows[i].entpcourseworklistarray = []
}
// classworkdatastudentids
if (
response.rows[i].classworkdatastudentids != '' &&
response.rows[i].classworkdatastudentids != null &&
response.rows[i].classworkdatastudentids != 'null'
) {
const stuList = JSON.parse('[' + response.rows[i].classworkdatastudentids + ']')
response.rows[i].workdatacount = stuList.length
}
}
// (workdatacount)>0
if (response.rows && response.rows.length > 0) {
classWorkList.value = response.rows && response.rows.filter((item) => item.workdatacount > 0)
//TODO total
total.value = response.total
}else{
classWorkList.value = []
total.value = 0
}
loading.value = false
})
for (var i = 0; i < response.rows.length; i++) {
//
response.rows[i].workdatalist = []
response.rows[i].workdatacount = 0 //
response.rows[i].workdatalistVisible = false
response.rows[i].workdatafeedbackcount = 0 //
response.rows[i].feedtimelength = 0
response.rows[i].rightAnswerCount = 0
response.rows[i].scoingRate = 0 + '%' //
response.rows[i].averagetime = 0 //
// ----------------------------------------------
// UI
if (response.rows[i].worktype == '学习目标定位') {
response.rows[i].workclass = 'success'
response.rows[i].workcodesList = JSON.parse(response.rows[i].workcodes)
} else if (response.rows[i].worktype == '教材研读') {
response.rows[i].workclass = 'primary'
} else if (response.rows[i].worktype == '框架梳理') {
response.rows[i].workclass = 'warning'
} else if (response.rows[i].worktype == '学科定位') {
response.rows[i].workclass = 'info'
} else if (response.rows[i].worktype == '习题训练') {
response.rows[i].workclass = 'danger'
} else {
response.rows[i].workclass = ''
}
//
if (response.rows[i].entpcourseworklist != '') {
response.rows[i].entpcourseworklistarray = JSON.parse(
'[' + response.rows[i].entpcourseworklist + ']'
)
} else {
response.rows[i].entpcourseworklistarray = []
}
// classworkdatastudentids
if (
response.rows[i].classworkdatastudentids != '' &&
response.rows[i].classworkdatastudentids != null &&
response.rows[i].classworkdatastudentids != 'null'
) {
const stuList = JSON.parse('[' + response.rows[i].classworkdatastudentids + ']')
response.rows[i].workdatacount = stuList.length
}
}
// (workdatacount)>0
if (response.rows && response.rows.length > 0) {
classWorkList.value = response.rows && response.rows.filter((item) => item.workdatacount > 0)
//TODO total
total.value = response.total
}else{
classWorkList.value = []
total.value = 0
}
loading.value = false
}
}
@ -211,15 +211,18 @@ const getClassWorkList = () => {
*/
const getStudentClassWorkData = () => {
if(classTaskStore.classListIds.length>0){
//listClassworkdata({
listClassworkdataByDeadDate({
edituserid: userStore.userId, // id
classids: classTaskStore.classListIds.join(','),
edusubject: userStore.edusubject,//
deaddate: tabActive.value === '进行中'? getTomorrow() : EndDate.value,//
//status: '1', // 1-
orderby: "deaddate DESC",// TODO deaddate
//entpcourseid: 8945,
// listClassworkdataByDeadDate({
// edituserid: userStore.userId, // id
// classids: classTaskStore.classListIds.join(','),
// edusubject: userStore.edusubject,//
// deaddate: tabActive.value === ''? getTomorrow() : EndDate.value,//
// //status: '1', // 1-
// orderby: "deaddate DESC",// TODO deaddate
// pageSize: 1000,
// })
const ids = classWorkList.value.map((item) => item.id).join(',');
listClassworkdata({
classworkids: ids,
pageSize: 1000,
}).then((res) => {
for (var t = 0; t < classWorkList.value.length; t++) {
@ -287,10 +290,10 @@ const getStudentClassWorkData = () => {
//
// 2024-04-12by jackyshen
//
if (classWorkList.value[t].workdatafeedbackcount > 0) {
classWorkList.value[t].averagetime = (classWorkList.value[t].feedtimelength / classWorkList.value[t].workdatafeedbackcount).toFixed(0)
classWorkList.value[t].averagetime = Math.ceil(classWorkList.value[t].feedtimelength / classWorkList.value[t].workdatafeedbackcount / 60).toFixed(0)
} else {
classWorkList.value[t].averagetime = 0
}
@ -372,6 +375,7 @@ const getStudentVisible = async () => {
//
const response = await listByDeadDate({
classidarray: classTaskStore.classListIds.join(','),
edituserid: userStore.userId, // id
edustage: userStore.edustage,//
edusubject: userStore.edusubject,//
deaddate: tabActive.value === '进行中'? getTomorrow() : EndDate.value,//
@ -402,7 +406,7 @@ const getStudentVisible = async () => {
)
//
if (classWorkList.value[t].workdatafeedbackcount > 0) {
classWorkList.value[t].averagetime = (classWorkList.value[t].feedtimelength / classWorkList.value[t].workdatafeedbackcount).toFixed(0)
classWorkList.value[t].averagetime = Math.ceil(classWorkList.value[t].feedtimelength / classWorkList.value[t].workdatafeedbackcount / 60).toFixed(0)
} else {
classWorkList.value[t].averagetime = 0
}

View File

@ -17,7 +17,13 @@
<div class="respond">
<div class="c-label">
<b t1>作答情况</b>
<span>(已经完成 <el-text type="danger">{{item.accSum}}</el-text> )</span>
<template v-if="item.type=='单选题'||item.type == '多选题'||item.type == '判断题'">
<span>(已经完成 <el-text type="danger">{{item.accSum}}</el-text> -</span>
<span>回答正确 <el-text type="danger">{{item.rightSum}}</el-text> )</span>
</template>
<template v-else>
<span>(已经完成 <el-text type="danger">{{item.accSum}}</el-text> )</span>
</template>
</div>
<div class="c-childen">
<template v-for="(it, ind) in item.children">
@ -111,6 +117,14 @@ colorArr = [
onMounted(() => {})
// === (methods) ===
const isSame = (a,b) => {
if (a.length != b.length) return false
return !a.some(v => !b.includes(v))
}
// -
// -
const initData = () => {
// console.log('xxx', props)
@ -124,43 +138,128 @@ const initData = () => {
const workdesc = o.workdesc || ''
let accSum = 0 //
let activeIds = [] //
let rightIds = [] //
const quizFeedList = activeWorkFeedList.filter(f => f.entpcourseworkid == o.id) //
let children = []
if (['单选题','多选题'].includes(o.worktype)) { // '',''
const list = workdesc.includes('#&') ? workdesc.split('#&') : isJson(workdesc)?JSON.parse(workdesc):[]
const allStudents = [];
if (o.worktype == '单选题') { // '',''
const list = workdesc.includes('#&') ? workdesc.split('#&') : isJson(workdesc)?JSON.parse(workdesc):[];
children = list.map((v,i) => {
const code = toCode(i) // A-Z
const isOk = (isJson(workdesc)?JSON.parse(o.workanswer):o.workanswer||'').includes(i+'') // ()
// id
const studentIds = quizFeedList.filter(f => f.feedcontent==v&&f.finishtimelength!='0').map(f => f.studentid)||[];
accSum += studentIds.length;
if (isOk) {
activeIds.push(...studentIds)
}
return { def: v, code, isOk, studentIds }
})
}
else if (o.worktype == '多选题') {
//
rightIds = quizFeedList.filter(f => {
const workanswer = (isJson(o.workanswer)) ? JSON.parse(o.workanswer) : o.workanswer || [];
const res = isSame((f.feedcontent||'').split(','), workanswer);
return f.entpcourseworkid == o.id && f.finishtimelength!='0' && res;
});
const list = workdesc.includes('#&') ? workdesc.split('#&') : isJson(workdesc)?JSON.parse(workdesc):[];
children = list.map((v,i) => {
const isOne = o.worktype == '单选题'
const code = toCode(i) // A-Z
// const isOk = isOne ? i == o.workanswer : o.workanswer.includes(i) // ()
const isOk = (isJson(workdesc)?JSON.parse(o.workanswer):o.workanswer||'').includes(i+'') // ()
// id
const studentIds = quizFeedList.filter(f => isOne ? f.feedcontent==v : f.feedcontent.includes(i)).map(f => f.studentid)||[]
accSum += studentIds.length
if(isOk) isOne ? activeIds.push(...studentIds) : activeIds=[...new Set(activeIds.concat(studentIds))] //
const studentIds = quizFeedList.filter(f => f.feedcontent.includes(i)&&f.finishtimelength!='0').map(f => f.studentid)||[];
accSum += studentIds.length;
if (studentIds.length>0) {
allStudents.push(...studentIds);
}
if(isOk) {
activeIds=[...new Set(activeIds.concat(studentIds))] //
}
return { def: v, code, isOk, studentIds }
})
} else if (o.worktype == '填空题') { //
}
else if (o.worktype == '填空题') { //
const regex = /<!--BA-->(.*?)<!--EA-->/g // <!--BA-->xxx<!--EA-->
children = (o.title||'').match(regex).map((v,i) => {
const def = `填空项 ${i+1}`
const code = '(&emsp;)', txt=v
//const code = '(&emsp;)'
const code = '(略)', txt=v
// id
const studentIds = quizFeedList.filter(f => !!(f.feedcontent||'').replace(/#$/,'').split('#')[i]).map(f => f.studentid)||[]
const studentIds = quizFeedList.filter(f => !!(f.feedcontent||'').replace(/#$/,'').split('#')[i] && f.finishtimelength!='0').map(f => f.studentid)||[]
activeIds=[...new Set(activeIds.concat(studentIds))] //
accSum = activeIds.length
return { def, code, txt, isOk:true, studentIds }
})
} else if (o.worktype == '论述题') { //
const code = '(&emsp;)', def = '论述内容'
const studentIds = quizFeedList.filter(f => !!(f.feedcontent||'').replace(/#$/,'')).map(f => f.studentid)||[]
} else if (o.worktype == '判断题') { //
const list = ['正确', '错误'];
children = list.map((v,i) => {
const workanswer = o.workanswer
.replace('×', '0')
.replace('√', '1')
.replace('错误', '0')
.replace('正确', '1')
.replace('正确。', '1')
.replace('F', '0')
.replace('T', '1')
.replace('错', '0')
.replace('对', '1');
const workanswerFormat = isJson(workanswer) ? JSON.parse(workanswer) : workanswer||''
const code = v=='正确' ? '1' : '0'
let isOk = (workanswerFormat).includes(code)
// warn:
// if (workanswerFormat == '0') {
// isOk = !isOk;
// }
// id
const studentIds = quizFeedList.filter(f => {
const feedcontent = f.feedcontent
.replace('×', '0')
.replace('√', '1')
.replace('错误', '0')
.replace('正确', '1')
.replace('正确。', '1')
.replace('F', '0')
.replace('T', '1')
.replace('错', '0')
.replace('对', '1');
if(feedcontent == code&&f.finishtimelength!='0'){
return f
}
}).map(f => f.studentid)||[];
accSum += studentIds.length;
if(isOk) activeIds.push(...studentIds)
return { def: v, code: v, isOk, studentIds }
})
} else { //
// code = '(&emsp;)'
const code = '(略)', def = '解答内容'
const studentIds = quizFeedList.filter(f => !!(f.feedcontent||'').replace(/#$/,'')&&f.finishtimelength!='0').map(f => f.studentid)||[]
activeIds=[...new Set(activeIds.concat(studentIds))] //
accSum = activeIds.length
children = [{ def, code, isOk:true, studentIds }]
}
const studentSum = studentList.value.length || 0 //
const points = percent((activeIds.length / (studentSum||1)).toFixed(2)) //
let points = percent((activeIds.length / (studentSum||1)).toFixed(2)) //
let rightSum = activeIds.length; //
//
if (o.worktype == '多选题') {
//
const uniqueTmpStuents = [...new Set(allStudents)];
accSum = uniqueTmpStuents.length;
//
points = percent((rightIds.length / (studentSum||1)).toFixed(2)) //
//
rightSum = rightIds.length;
}
// def: type active: points: , accSum
return { def: o, id: o.id, type: o.worktype, active: [], points, accSum, children }
return { def: o, id: o.id, type: o.worktype, active: [], points, accSum, rightSum, children }
})
console.log('获取数据: ', data)
dataList.value = data
@ -170,7 +269,7 @@ const ratio_1 = (row, sum = 1) => percent(((row.studentIds.length||0) / (sum||1)
// --
const ratio_2 = row => percent(((row.accSum||0) / (studentList.value.length||1)).toFixed(2))
// --txt
const getRatioTxt = row => row.type.includes('选题') ? '得分率' : '完成度'
const getRatioTxt = row => ['单选题', '多选题', '判断题'].includes(row.type) ? '得分率' : '完成度'
// --
const getStatus = row => row.isOk ? 'success' : 'exception'
// -(id)

View File

@ -30,7 +30,7 @@
<div class="class-reserv-item-tool">
<span>
<!-- {{ item.averagetime?item.averagetime:0 }} -->
<span v-if=" item.averagetime<60 ">
<!-- <span v-if=" item.averagetime<60 ">
<span style="color: #007fff; font-weight: 900; font-size: 15px">{{ item.averagetime }}</span>分钟
</span>
<span v-if=" item.averagetime==60 ">
@ -39,7 +39,8 @@
<span v-if=" item.averagetime>60 ">
<span style="color: #007fff; font-weight: 900; font-size: 15px">{{ Math.floor(item.averagetime / 60)}}</span>小时
<span style="color: #007fff; font-weight: 900; font-size: 15px">{{ Math.floor(item.averagetime % 60)}}</span>分钟
</span>
</span> -->
<span style="color: #007fff; font-weight: 900; font-size: 15px">{{ item.averagetime }}</span>分钟
</span>
<span>平均用时</span>
</div>

View File

@ -65,7 +65,8 @@ const getHomework = async () => {
try {
const { rows } = await homeworklist({ edituserid: user.userId, edustage, edusubject, deaddate: getTomorrow(), status: '1', orderby: 'uniquekey DESC', pageSize: 500 })
//
homeworkList.value = rows.filter(item => item.deaddate && item.uniquekey && getCurrentTime('YYYY-MM-DD HH:mm') < item.deaddate)
// homeworkList.value = rows.filter(item => item.deaddate && item.uniquekey && getCurrentTime('YYYY-MM-DD HH:mm') < item.deaddate)
homeworkList.value = rows.filter(item => item.deaddate && item.uniquekey && getTomorrow() <= item.deaddate) //
homeworkList.value.forEach((item) => {
item.workdatacount = JSON.parse('[' + item.classworkdatastudentids + ']').length
//