feat(backend): Functionaliteit toegevoegd om alle submissions zichtbaar voor een bepaalde leerling of leerkracht op te vragen.

This commit is contained in:
Gerald Schmittinger 2025-04-07 19:23:46 +02:00
parent 03fa7c7b14
commit 9135b9c5b0
9 changed files with 338 additions and 156 deletions

View file

@ -6,6 +6,19 @@ export class AssignmentRepository extends DwengoEntityRepository<Assignment> {
public async findByClassAndId(within: Class, id: number): Promise<Assignment | null> {
return this.findOne({ within: within, id: id });
}
public async findAllByResponsibleTeacher(teacherUsername: string): Promise<Assignment[]> {
return this.findAll({
where: {
within: {
teachers: {
$some: {
username: teacherUsername
}
}
}
}
});
}
public async findAllAssignmentsInClass(within: Class): Promise<Assignment[]> {
return this.findAll({ where: { within: within } });
}

View file

@ -3,6 +3,7 @@ import { Group } from '../../entities/assignments/group.entity.js';
import { Submission } from '../../entities/assignments/submission.entity.js';
import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier.js';
import { Student } from '../../entities/users/student.entity.js';
import {Assignment} from "../../entities/assignments/assignment.entity";
export class SubmissionRepository extends DwengoEntityRepository<Submission> {
public async findSubmissionByLearningObjectAndSubmissionNumber(
@ -50,6 +51,30 @@ export class SubmissionRepository extends DwengoEntityRepository<Submission> {
);
}
public async findAllSubmissionsForAllGroupsOfStudent(studentUsername: string): Promise<Submission[]> {
return this.findAll({
where: {
onBehalfOf: {
members: {
$some: {
username: studentUsername
}
},
}
}
});
}
public async findAllSubmissionsForAssignment(assignment: Assignment): Promise<Submission[]> {
return this.findAll({
where: {
onBehalfOf: {
assignment
}
}
});
}
public async findAllSubmissionsForStudent(student: Student): Promise<Submission[]> {
return this.find(
{ submitter: student },

View file

@ -1,4 +1,4 @@
import { Entity, ManyToMany, ManyToOne, PrimaryKey } from '@mikro-orm/core';
import {Collection, Entity, ManyToMany, ManyToOne, PrimaryKey} from '@mikro-orm/core';
import { Assignment } from './assignment.entity.js';
import { Student } from '../users/student.entity.js';
import { GroupRepository } from '../../data/assignments/group-repository.js';
@ -19,5 +19,5 @@ export class Group {
@ManyToMany({
entity: () => Student,
})
members!: Student[];
members!: Collection<Student>;
}