|
@@ -14,6 +14,7 @@ class StudentService extends CrudService {
|
|
|
this.umodel = this.ctx.model.User;
|
|
|
this.tmodel = this.ctx.model.Trainplan;
|
|
|
this.clamodel = this.ctx.model.Class;
|
|
|
+ this.upmodel = this.ctx.model.Uploadtask;
|
|
|
}
|
|
|
|
|
|
// 查询
|
|
@@ -129,6 +130,23 @@ class StudentService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 根据班级id查出班级各个学生的分数
|
|
|
+ async findscore({ skip, limit, ...info }) {
|
|
|
+ const total = await this.model.count(info);
|
|
|
+ const students = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
|
|
|
+ const data = [];
|
|
|
+ for (const student of students) {
|
|
|
+ const _student = _.cloneDeep(student);
|
|
|
+ const group = await this.ctx.service.group.findbystuid({ stuid: _student.id });
|
|
|
+ if (group && group.score) {
|
|
|
+ _student.groupscore = group.score;
|
|
|
+ }
|
|
|
+ const tasks = await this.upmodel.find({ studentid: _student.id });
|
|
|
+ _student.tasks = tasks;
|
|
|
+ data.push(_student);
|
|
|
+ }
|
|
|
+ return { total, data };
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = StudentService;
|