|
@@ -75,11 +75,14 @@ class StudentService extends CrudService {
|
|
|
const newdata = { ...JSON.parse(JSON.stringify(elm)) };
|
|
|
if (plan) {
|
|
|
const term = await plan.termnum.id(elm.termid);
|
|
|
- newdata.termname = term.term;
|
|
|
- if (elm.batchid) {
|
|
|
- const _batch = await term.batchnum.id(elm.batchid);
|
|
|
- newdata.batchname = _batch.batch;
|
|
|
+ if (term) {
|
|
|
+ newdata.termname = term.term;
|
|
|
+ if (elm.batchid) {
|
|
|
+ const _batch = await term.batchnum.id(elm.batchid);
|
|
|
+ newdata.batchname = _batch.batch;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
if (elm.classid) {
|
|
|
const classs = await this.clamodel.findById(elm.classid);
|
|
@@ -311,7 +314,7 @@ class StudentService extends CrudService {
|
|
|
// 排名
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
let num = 0;
|
|
|
- for (let student of studentList) {
|
|
|
+ for (const student of studentList) {
|
|
|
// 先判断是否超过第10位,超过就跳出
|
|
|
if (num > 10) break;
|
|
|
const { score, is_fine, job, name, _id } = student;
|
|
@@ -366,14 +369,15 @@ class StudentService extends CrudService {
|
|
|
const arr = [];
|
|
|
for (let i of studentList) {
|
|
|
const slist = scoreList[i._id];
|
|
|
+ const obj = {};
|
|
|
if (slist) {
|
|
|
const score = slist.reduce((p, n) => p + (n.score * 1 || 0), 0);
|
|
|
- // i.score = _.round((i.score * 1 || 0) + score, 2);
|
|
|
- const obj = {};
|
|
|
obj[type] = score;
|
|
|
- i = Object.assign(i, obj);
|
|
|
- arr.push(i);
|
|
|
+ } else {
|
|
|
+ obj[type] = 0;
|
|
|
}
|
|
|
+ i = Object.assign(i, obj);
|
|
|
+ arr.push(i);
|
|
|
}
|
|
|
|
|
|
return arr;
|
|
@@ -407,6 +411,8 @@ class StudentService extends CrudService {
|
|
|
if (r) {
|
|
|
// i.score = _.round((i.score * 1 || 0) + (r.score * 1 || 0), 2);
|
|
|
i.groupscore = r.score * 1 || 0;
|
|
|
+ } else {
|
|
|
+ i.groupscore = 0;
|
|
|
}
|
|
|
return i;
|
|
|
});
|