feat(backend): Question + Answer entities toegevoegd; kleine verbeteringen.

This commit is contained in:
Gerald Schmittinger 2025-02-23 16:48:06 +01:00
parent cdfe48d8c5
commit 2657e49ad6
6 changed files with 79 additions and 19 deletions

View file

@ -1,7 +1,7 @@
import {Entity, ManyToOne, OneToMany, PrimaryKey, Property} from "@mikro-orm/core";
import {Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property} from "@mikro-orm/core";
import {Class} from "../classes/class.entity";
import {LearningPath} from "../content/learning-path.entity";
import {Group} from "./group.entity"
import {Language} from "../content/language";
@Entity()
export class Assignment {
@ -17,8 +17,11 @@ export class Assignment {
@Property({type: "text"})
description!: string;
@ManyToOne({entity: () => LearningPath})
task!: LearningPath;
@Property({type: "string"})
learningPathHruid!: string;
@Enum({items: () => Language})
learningPathLanguage!: Language;
@OneToMany({entity: () => Group, mappedBy: "assignment"})
groups!: Group[];

View file

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

View file

@ -1,9 +1,10 @@
import {Embeddable, Embedded, Entity, Enum, OneToMany, PrimaryKey, Property} from "@mikro-orm/core";
import {Embeddable, Embedded, Entity, Enum, ManyToMany, OneToMany, PrimaryKey, Property} from "@mikro-orm/core";
import {Language} from "./language";
import {Attachment} from "./attachment.entity";
import {Teacher} from "../users/teacher.entity";
@Entity()
export class LearningObject {
export class LearningObject<R> {
@PrimaryKey({type: "string"})
hruid!: string;
@ -13,8 +14,8 @@ export class LearningObject {
@PrimaryKey({type: "string"})
version: number = "1";
@PrimaryKey({type: "string"})
author!: string;
@ManyToMany({entity: () => Teacher})
admins!: Teacher[];
@Property({type: "string"})
title!: string;
@ -52,6 +53,9 @@ export class LearningObject {
@Property({type: "integer"})
estimatedTime!: number;
@Embedded({entity: () => ReturnValue})
returnValue: ReturnValue<R>;
@Property({type: "bool"})
available: boolean = true;
@ -75,12 +79,12 @@ export class EducationalGoal {
}
@Embeddable()
export class ReturnValue {
export class ReturnValue<R> {
@Property({type: "string"})
callbackUrl: string;
@Property({type: "json"})
callbackSchema: Object;
callbackSchema: R;
}
export enum ContentType {

View file

@ -1,5 +1,6 @@
import {Embeddable, Embedded, Entity, Enum, OneToOne, PrimaryKey, Property} from "@mikro-orm/core";
import {Embeddable, Embedded, Entity, Enum, ManyToMany, OneToOne, PrimaryKey, Property} from "@mikro-orm/core";
import {Language} from "./language";
import {Teacher} from "../users/teacher.entity";
@Entity()
export class LearningPath {
@ -9,6 +10,9 @@ export class LearningPath {
@Enum({items: () => Language, primary: true})
language!: Language;
@ManyToMany({entity: () => Teacher})
admins!: Teacher[];
@Property({type: "string"})
title!: string;

View file

@ -0,0 +1,19 @@
import {Entity, ManyToOne, PrimaryKey, Property} from "@mikro-orm/core";
import {Question} from "./question.entity";
import {Teacher} from "../users/teacher.entity";
@Entity()
export class Answer {
@ManyToOne({entity: () => Teacher, primary: true})
author!: Teacher;
@ManyToOne({entity: () => Question, primary: true})
toQuestion!: Question;
@PrimaryKey({type: "datetime"})
timestamp: Date;
@Property({type: "text"})
content: string;
}

View file

@ -0,0 +1,24 @@
import {Entity, Enum, ManyToOne, PrimaryKey, Property} from "@mikro-orm/core";
import {Language} from "../content/language";
import {Student} from "../users/student.entity";
@Entity()
export class Question {
@ManyToOne({entity: () => Student, primary: true})
author!: Student;
@PrimaryKey({type: "string"})
learningObjectHruid!: string;
@Enum({items: () => Language, primary: true})
learningObjectLanguage!: Language;
@PrimaryKey({type: "string"})
learningObjectVersion!: number = "1";
@PrimaryKey({type: "datetime"})
timestamp!: Date;
@Property({type: "text"})
content!: string;
}