feat(backend): Question + Answer entities toegevoegd; kleine verbeteringen.
This commit is contained in:
parent
cdfe48d8c5
commit
2657e49ad6
6 changed files with 79 additions and 19 deletions
|
@ -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 {Class} from "../classes/class.entity";
|
||||||
import {LearningPath} from "../content/learning-path.entity";
|
|
||||||
import {Group} from "./group.entity"
|
import {Group} from "./group.entity"
|
||||||
|
import {Language} from "../content/language";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Assignment {
|
export class Assignment {
|
||||||
|
@ -17,8 +17,11 @@ export class Assignment {
|
||||||
@Property({type: "text"})
|
@Property({type: "text"})
|
||||||
description!: string;
|
description!: string;
|
||||||
|
|
||||||
@ManyToOne({entity: () => LearningPath})
|
@Property({type: "string"})
|
||||||
task!: LearningPath;
|
learningPathHruid!: string;
|
||||||
|
|
||||||
|
@Enum({items: () => Language})
|
||||||
|
learningPathLanguage!: Language;
|
||||||
|
|
||||||
@OneToMany({entity: () => Group, mappedBy: "assignment"})
|
@OneToMany({entity: () => Group, mappedBy: "assignment"})
|
||||||
groups!: Group[];
|
groups!: Group[];
|
||||||
|
|
|
@ -1,22 +1,28 @@
|
||||||
import {Student} from "../users/student.entity";
|
import {Student} from "../users/student.entity";
|
||||||
import {Group} from "./group.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";
|
import {Language} from "../content/language";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Submission {
|
export class Submission<T> {
|
||||||
@ManyToOne({entity: () => Student, primary: true})
|
@ManyToOne({entity: () => Student, primary: true})
|
||||||
submitter!: Student;
|
submitter!: Student;
|
||||||
|
|
||||||
@ManyToOne({entity: () => Group, primary: true})
|
|
||||||
onBehalfOf!: Group;
|
|
||||||
|
|
||||||
@PrimaryKey({type: "string"})
|
@PrimaryKey({type: "string"})
|
||||||
hruid!: string;
|
learningObjectHruid!: string;
|
||||||
|
|
||||||
@Enum({items: () => Language, primary: true})
|
@Enum({items: () => Language, primary: true})
|
||||||
language!: Language;
|
learningObjectLanguage!: Language;
|
||||||
|
|
||||||
@PrimaryKey({type: "string"})
|
@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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {Language} from "./language";
|
||||||
import {Attachment} from "./attachment.entity";
|
import {Attachment} from "./attachment.entity";
|
||||||
|
import {Teacher} from "../users/teacher.entity";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class LearningObject {
|
export class LearningObject<R> {
|
||||||
@PrimaryKey({type: "string"})
|
@PrimaryKey({type: "string"})
|
||||||
hruid!: string;
|
hruid!: string;
|
||||||
|
|
||||||
|
@ -13,8 +14,8 @@ export class LearningObject {
|
||||||
@PrimaryKey({type: "string"})
|
@PrimaryKey({type: "string"})
|
||||||
version: number = "1";
|
version: number = "1";
|
||||||
|
|
||||||
@PrimaryKey({type: "string"})
|
@ManyToMany({entity: () => Teacher})
|
||||||
author!: string;
|
admins!: Teacher[];
|
||||||
|
|
||||||
@Property({type: "string"})
|
@Property({type: "string"})
|
||||||
title!: string;
|
title!: string;
|
||||||
|
@ -52,6 +53,9 @@ export class LearningObject {
|
||||||
@Property({type: "integer"})
|
@Property({type: "integer"})
|
||||||
estimatedTime!: number;
|
estimatedTime!: number;
|
||||||
|
|
||||||
|
@Embedded({entity: () => ReturnValue})
|
||||||
|
returnValue: ReturnValue<R>;
|
||||||
|
|
||||||
@Property({type: "bool"})
|
@Property({type: "bool"})
|
||||||
available: boolean = true;
|
available: boolean = true;
|
||||||
|
|
||||||
|
@ -75,12 +79,12 @@ export class EducationalGoal {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Embeddable()
|
@Embeddable()
|
||||||
export class ReturnValue {
|
export class ReturnValue<R> {
|
||||||
@Property({type: "string"})
|
@Property({type: "string"})
|
||||||
callbackUrl: string;
|
callbackUrl: string;
|
||||||
|
|
||||||
@Property({type: "json"})
|
@Property({type: "json"})
|
||||||
callbackSchema: Object;
|
callbackSchema: R;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ContentType {
|
export enum ContentType {
|
||||||
|
|
|
@ -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 {Language} from "./language";
|
||||||
|
import {Teacher} from "../users/teacher.entity";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class LearningPath {
|
export class LearningPath {
|
||||||
|
@ -9,6 +10,9 @@ export class LearningPath {
|
||||||
@Enum({items: () => Language, primary: true})
|
@Enum({items: () => Language, primary: true})
|
||||||
language!: Language;
|
language!: Language;
|
||||||
|
|
||||||
|
@ManyToMany({entity: () => Teacher})
|
||||||
|
admins!: Teacher[];
|
||||||
|
|
||||||
@Property({type: "string"})
|
@Property({type: "string"})
|
||||||
title!: string;
|
title!: string;
|
||||||
|
|
||||||
|
|
19
backend/src/entities/questions/answer.entity.ts
Normal file
19
backend/src/entities/questions/answer.entity.ts
Normal 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;
|
||||||
|
}
|
24
backend/src/entities/questions/question.entity.ts
Normal file
24
backend/src/entities/questions/question.entity.ts
Normal 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;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue