feat(backend): Assignment-, Group- en SubmissionRepository aangemaakt

This commit is contained in:
Gerald Schmittinger 2025-02-26 00:00:18 +01:00
parent bd93e5fae3
commit 2837618fd5
8 changed files with 75 additions and 4 deletions

View file

@ -0,0 +1,28 @@
import {Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property} from "@mikro-orm/core";
import {Class} from "../classes/class.entity";
import {Group} from "./group.entity"
import {Language} from "../content/language";
@Entity()
export class Assignment {
@ManyToOne({entity: () => Class, primary: true})
within!: Class;
@PrimaryKey({type: "number"})
id!: number;
@Property({type: "string"})
title!: string;
@Property({type: "text"})
description!: string;
@Property({type: "string"})
learningPathHruid!: string;
@Enum({items: () => Language})
learningPathLanguage!: Language;
@OneToMany({entity: () => Group, mappedBy: "assignment"})
groups!: Group[];
}

View file

@ -0,0 +1,15 @@
import {Entity, ManyToMany, ManyToOne, PrimaryKey} from "@mikro-orm/core";
import {Assignment} from "./assignment.entity";
import {Student} from "../users/student.entity";
@Entity()
export class Group {
@ManyToOne({entity: () => Assignment, primary: true})
assignment!: Assignment;
@PrimaryKey({type: "integer"})
groupNumber!: number;
@ManyToMany({entity: () => Student})
members!: Student[];
}

View file

@ -0,0 +1,31 @@
import {Student} from "../users/student.entity";
import {Group} from "./group.entity";
import {Entity, Enum, ManyToOne, PrimaryKey, Property} from "@mikro-orm/core";
import {Language} from "../content/language";
@Entity()
export class Submission {
@PrimaryKey({type: "string"})
learningObjectHruid!: string;
@Enum({items: () => Language, primary: true})
learningObjectLanguage!: Language;
@PrimaryKey({type: "string"})
learningObjectVersion: string = "1";
@PrimaryKey({type: "integer"})
submissionNumber!: number;
@ManyToOne({entity: () => Student})
submitter!: Student;
@Property({type: "datetime"})
submissionTime!: Date;
@ManyToOne({entity: () => Group, nullable: true})
onBehalfOf?: Group;
@Property({type: "json"})
content!: string;
}