feat(backend): Assignment-, Group- en SubmissionRepository aangemaakt
This commit is contained in:
parent
bd93e5fae3
commit
2837618fd5
8 changed files with 75 additions and 4 deletions
15
backend/src/data/assignments/assignment-repository.ts
Normal file
15
backend/src/data/assignments/assignment-repository.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import {DwengoEntityRepository} from "../dwengo-entity-repository";
|
||||
import {Assignment} from "../../entities/assignments/assignment.entity";
|
||||
import {Class} from "../../entities/classes/class.entity";
|
||||
|
||||
export class AssignmentRepository extends DwengoEntityRepository<Assignment> {
|
||||
public findByClassAndId(within: Class, id: number): Promise<Assignment | null> {
|
||||
return this.findOne({within: within, id: id});
|
||||
}
|
||||
public findAllAssignmentsInClass(within: Class): Promise<Assignment[]> {
|
||||
return this.findAll({where: {within: within}});
|
||||
}
|
||||
public deleteByClassAndId(within: Class, id: number): Promise<void> {
|
||||
return this.deleteWhere({within: within, id: id});
|
||||
}
|
||||
}
|
15
backend/src/data/assignments/group-repository.ts
Normal file
15
backend/src/data/assignments/group-repository.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import {DwengoEntityRepository} from "../dwengo-entity-repository";
|
||||
import {Group} from "../../entities/assignments/group.entity";
|
||||
import {Assignment} from "../../entities/assignments/assignment.entity";
|
||||
|
||||
export class GroupRepository extends DwengoEntityRepository<Group> {
|
||||
public findByAssignmentAndGroupNumber(assignment: Assignment, groupNumber: number): Promise<Group | null> {
|
||||
return this.findOne({assignment: assignment, groupNumber: groupNumber});
|
||||
}
|
||||
public findAllGroupsForAssignment(assignment: Assignment): Promise<Group[]> {
|
||||
return this.findAll({where: {assignment: assignment}});
|
||||
}
|
||||
public deleteByAssignmentAndGroupNumber(assignment: Assignment, groupNumber: number) {
|
||||
return this.deleteWhere({assignment: assignment, groupNumber: groupNumber});
|
||||
}
|
||||
}
|
34
backend/src/data/assignments/submission-repository.ts
Normal file
34
backend/src/data/assignments/submission-repository.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import {DwengoEntityRepository} from "../dwengo-entity-repository";
|
||||
import {Group} from "../../entities/assignments/group.entity";
|
||||
import {Submission} from "../../entities/assignments/submission.entity";
|
||||
import {LearningObjectIdentifier} from "../../entities/content/learning-object-identifier";
|
||||
import {Student} from "../../entities/users/student.entity";
|
||||
|
||||
export class SubmissionRepository extends DwengoEntityRepository<Submission> {
|
||||
public findSubmissionByLearningObjectAndSubmissionNumber(loId: LearningObjectIdentifier, submissionNumber: number): Promise<Submission | null> {
|
||||
return this.findOne({
|
||||
learningObjectHruid: loId.hruid,
|
||||
learningObjectLanguage: loId.language,
|
||||
learningObjectVersion: loId.version,
|
||||
submissionNumber: submissionNumber
|
||||
});
|
||||
}
|
||||
|
||||
public findMostRecentSubmissionForStudent(loId: LearningObjectIdentifier, submitter: Student): Promise<Submission | null> {
|
||||
return this.findOne({
|
||||
learningObjectHruid: loId.hruid,
|
||||
learningObjectLanguage: loId.language,
|
||||
learningObjectVersion: loId.version,
|
||||
submitter: submitter,
|
||||
}, {orderBy: {submissionNumber: "DESC"}})
|
||||
}
|
||||
|
||||
public findMostRecentSubmissionForGroup(loId: LearningObjectIdentifier, group: Group): Promise<Submission | null> {
|
||||
return this.findOne({
|
||||
learningObjectHruid: loId.hruid,
|
||||
learningObjectLanguage: loId.language,
|
||||
learningObjectVersion: loId.version,
|
||||
onBehalfOf: group,
|
||||
}, {orderBy: {submissionNumber: "DESC"}})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue