|
1 | 1 | import { EntityRepository } from '@mikro-orm/core'; |
2 | 2 | import { EntityManager } from '@mikro-orm/mysql'; |
| 3 | +import { InjectRepository } from '@mikro-orm/nestjs'; |
3 | 4 | import { BadRequestException, forwardRef, Inject, Injectable } from '@nestjs/common'; |
| 5 | +import { GradingResponseData } from 'shared/model/Gradings'; |
4 | 6 | import { Grading } from '../../database/entities/grading.entity'; |
5 | 7 | import { HandIn } from '../../database/entities/ratedEntity.entity'; |
6 | 8 | import { Student } from '../../database/entities/student.entity'; |
| 9 | +import { Team } from '../../database/entities/team.entity'; |
| 10 | +import { GradingList, GradingListsForStudents } from '../../helpers/GradingList'; |
7 | 11 | import { ScheinexamService } from '../scheinexam/scheinexam.service'; |
8 | 12 | import { SheetService } from '../sheet/sheet.service'; |
9 | 13 | import { ShortTestService } from '../short-test/short-test.service'; |
10 | 14 | import { GradingDTO } from './student.dto'; |
11 | 15 | import { StudentService } from './student.service'; |
12 | | -import { GradingList, GradingListsForStudents } from '../../helpers/GradingList'; |
13 | | -import { Team } from '../../database/entities/team.entity'; |
14 | | -import { GradingResponseData } from 'shared/model/Gradings'; |
15 | | -import { InjectRepository } from '@mikro-orm/nestjs'; |
16 | 16 |
|
17 | 17 | @Injectable() |
18 | 18 | export class GradingService { |
@@ -194,11 +194,18 @@ export class GradingService { |
194 | 194 | } |
195 | 195 |
|
196 | 196 | async findAllHandInGradingsOfTeam(team: Team, handIn: HandIn): Promise<Grading[]> { |
197 | | - const studentIds = team.getStudents().map((s) => s.id); |
198 | | - return this.repository.find({ |
199 | | - handInId: handIn.id, |
200 | | - students: { $contains: studentIds }, |
201 | | - }); |
| 197 | + const gradings = await Promise.all( |
| 198 | + team.getStudents().map((s) => |
| 199 | + this.repository.find( |
| 200 | + { |
| 201 | + handInId: handIn.id, |
| 202 | + students: s, |
| 203 | + }, |
| 204 | + { populate: true } |
| 205 | + ) |
| 206 | + ) |
| 207 | + ); |
| 208 | + return [...new Set(gradings.flat())]; |
202 | 209 | } |
203 | 210 |
|
204 | 211 | private async updateGradingOfStudent({ |
|
0 commit comments