feat(backend): Entities toegevoegd
Entites Class, Class Join Request, Class Invitation, Assignment, Group en entities om de Dwengo-leerinhoud te modelleren, toegevoegd.
This commit is contained in:
		
							parent
							
								
									62a278a6e0
								
							
						
					
					
						commit
						d5101737ef
					
				
					 14 changed files with 289 additions and 7 deletions
				
			
		
							
								
								
									
										25
									
								
								backend/src/entities/assigments/assignment.entity.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								backend/src/entities/assigments/assignment.entity.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | |||
| import {Entity, 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" | ||||
| 
 | ||||
| @Entity() | ||||
| export class Assignment { | ||||
|     @ManyToOne({entity: () => Class, primary: true}) | ||||
|     within!: Class; | ||||
| 
 | ||||
|     @PrimaryKey({type: "number"}) | ||||
|     id!: number; | ||||
| 
 | ||||
|     @Property({type: "string"}) | ||||
|     title!: string; | ||||
| 
 | ||||
|     @Property({type: "longtext"}) | ||||
|     description!: string; | ||||
| 
 | ||||
|     @ManyToOne({entity: () => LearningPath}) | ||||
|     task!: LearningPath; | ||||
| 
 | ||||
|     @OneToMany({entity: () => Group}) | ||||
|     groups!: Group[]; | ||||
| } | ||||
							
								
								
									
										15
									
								
								backend/src/entities/assigments/group.entity.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								backend/src/entities/assigments/group.entity.ts
									
										
									
									
									
										Normal 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[]; | ||||
| } | ||||
							
								
								
									
										18
									
								
								backend/src/entities/classes/class-invitation.entity.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								backend/src/entities/classes/class-invitation.entity.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | |||
| import {Entity, ManyToOne} from "@mikro-orm/core"; | ||||
| import {Teacher} from "../users/teacher.entity"; | ||||
| import {Class} from "./class.entity"; | ||||
| 
 | ||||
| /** | ||||
|  * Invitation of a teacher into a class (in order to teach it). | ||||
|  */ | ||||
| @Entity() | ||||
| export class TeacherInvitation { | ||||
|     @ManyToOne({entity: () => Teacher, primary: true}) | ||||
|     sender!: Teacher; | ||||
| 
 | ||||
|     @ManyToOne({entity: () => Teacher, primary: true}) | ||||
|     receiver!: Teacher; | ||||
| 
 | ||||
|     @ManyToOne({entity: () => Class, primary: true}) | ||||
|     class!: Class; | ||||
| } | ||||
							
								
								
									
										21
									
								
								backend/src/entities/classes/class-join-request.entity.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								backend/src/entities/classes/class-join-request.entity.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | |||
| import {Entity, Enum, ManyToOne} from "@mikro-orm/core"; | ||||
| import {Student} from "../users/student.entity"; | ||||
| import {Class} from "./class.entity"; | ||||
| 
 | ||||
| @Entity() | ||||
| export class ClassJoinRequest { | ||||
|     @ManyToOne({entity: () => Student, primary: true}) | ||||
|     requester!: Student; | ||||
| 
 | ||||
|     @ManyToOne({entity: () => Class, primary: true}) | ||||
|     class!: Class; | ||||
| 
 | ||||
|     @Enum(() => ClassJoinRequestStatus) | ||||
|     status!: ClassJoinRequestStatus; | ||||
| } | ||||
| 
 | ||||
| export enum ClassJoinRequestStatus { | ||||
|     Open = "open", | ||||
|     Accepted = "accepted", | ||||
|     Declined = "declined" | ||||
| } | ||||
							
								
								
									
										19
									
								
								backend/src/entities/classes/class.entity.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								backend/src/entities/classes/class.entity.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| import {Collection, Entity, ManyToMany, PrimaryKey, Property} from "@mikro-orm/core"; | ||||
| import { v4 } from 'uuid'; | ||||
| import {Teacher} from "../users/teacher.entity"; | ||||
| import {Student} from "../users/student.entity"; | ||||
| 
 | ||||
| @Entity() | ||||
| export class Class { | ||||
|     @PrimaryKey() | ||||
|     classId = v4(); | ||||
| 
 | ||||
|     @Property({type: "string"}) | ||||
|     displayName!: string; | ||||
| 
 | ||||
|     @ManyToMany(() => Teacher) | ||||
|     teachers!: Collection<Teacher>; | ||||
| 
 | ||||
|     @ManyToMany(() => Student) | ||||
|     students!: Collection<Student>; | ||||
| } | ||||
							
								
								
									
										16
									
								
								backend/src/entities/content/attachment.entity.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								backend/src/entities/content/attachment.entity.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | |||
| import {ManyToOne, PrimaryKey, Property} from "@mikro-orm/core"; | ||||
| import {LearningObject} from "./learning-object.entity"; | ||||
| 
 | ||||
| export class Attachment { | ||||
|     @ManyToOne({entity: () => LearningObject, primary: true}) | ||||
|     learningObject!: LearningObject; | ||||
| 
 | ||||
|     @PrimaryKey({type: "integer"}) | ||||
|     no!: number; | ||||
| 
 | ||||
|     @Property({type: "string"}) | ||||
|     mimeType!: string; | ||||
| 
 | ||||
|     @Property({type: "blob"}) | ||||
|     content!: Buffer; | ||||
| } | ||||
							
								
								
									
										6
									
								
								backend/src/entities/content/language.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								backend/src/entities/content/language.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | |||
| export enum Language { | ||||
|     Dutch = "nl", | ||||
|     French = "fr", | ||||
|     English = "en", | ||||
|     Germany = "de" | ||||
| } | ||||
							
								
								
									
										93
									
								
								backend/src/entities/content/learning-object.entity.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								backend/src/entities/content/learning-object.entity.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,93 @@ | |||
| import {Embeddable, Embedded, Entity, Enum, OneToMany, PrimaryKey, Property} from "@mikro-orm/core"; | ||||
| import {Language} from "./language"; | ||||
| import {Attachment} from "./attachment.entity"; | ||||
| 
 | ||||
| @Entity() | ||||
| export class LearningObject { | ||||
|     @PrimaryKey({type: "string"}) | ||||
|     hruid!: string; | ||||
| 
 | ||||
|     @Enum({items: () => Language, primary: true}) | ||||
|     language!: Language; | ||||
| 
 | ||||
|     @PrimaryKey({type: "string"}) | ||||
|     version: number = "1"; | ||||
| 
 | ||||
|     @PrimaryKey({type: "string"}) | ||||
|     author!: string; | ||||
| 
 | ||||
|     @Property({type: "string"}) | ||||
|     title!: string; | ||||
| 
 | ||||
|     @Property({type: "longtext"}) | ||||
|     description!: string; | ||||
| 
 | ||||
|     @Property({type: "string"}) | ||||
|     contentType!: string; | ||||
| 
 | ||||
|     @Property({type: "array"}) | ||||
|     keywords: string[] = []; | ||||
| 
 | ||||
|     @Property({type: "array", nullable: true}) | ||||
|     targetAges?: number[]; | ||||
| 
 | ||||
|     @Property({type: "bool"}) | ||||
|     teacherExclusive: boolean = false; | ||||
| 
 | ||||
|     @Property({type: "array"}) | ||||
|     skosConcepts!: string[]; | ||||
| 
 | ||||
|     @Embedded({entity: () => EducationalGoal, array: true}) | ||||
|     educationalGoals: EducationalGoal[] = []; | ||||
| 
 | ||||
|     @Property({type: "string"}) | ||||
|     copyright: string = "" | ||||
| 
 | ||||
|     @Property({type: "string"}) | ||||
|     license: string = "" | ||||
| 
 | ||||
|     @Property({type: "smallint", nullable: true}) | ||||
|     difficulty?: number; | ||||
| 
 | ||||
|     @Property({type: "integer"}) | ||||
|     estimatedTime!: number; | ||||
| 
 | ||||
|     @Property({type: "bool"}) | ||||
|     available: boolean = true; | ||||
| 
 | ||||
|     @Property({type: "string", nullable: true}) | ||||
|     contentLocation?: string; | ||||
| 
 | ||||
|     @OneToMany({entity: Attachment}) | ||||
|     attachments: Attachment[] = []; | ||||
| 
 | ||||
|     @Property({type: "blob"}) | ||||
|     content: Buffer; | ||||
| } | ||||
| 
 | ||||
| @Embeddable() | ||||
| export class EducationalGoal { | ||||
|     @Property({type: "string"}) | ||||
|     source: string; | ||||
| 
 | ||||
|     @Property({type: "string"}) | ||||
|     id: string; | ||||
| } | ||||
| 
 | ||||
| @Embeddable() | ||||
| export class ReturnValue { | ||||
|     @Property({type: "string"}) | ||||
|     callbackUrl: string; | ||||
| 
 | ||||
|     @Property({type: "json"}) | ||||
|     callbackSchema: Object; | ||||
| } | ||||
| 
 | ||||
| export enum ContentType { | ||||
|     Markdown = "text/markdown", | ||||
|     Image = "image/image", | ||||
|     Mpeg = "audio/mpeg", | ||||
|     Pdf = "application/pdf", | ||||
|     Extern = "extern", | ||||
|     Blockly = "Blockly" | ||||
| } | ||||
							
								
								
									
										50
									
								
								backend/src/entities/content/learning-path.entity.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								backend/src/entities/content/learning-path.entity.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,50 @@ | |||
| import {Embeddable, Embedded, Entity, Enum, OneToOne, Property} from "@mikro-orm/core"; | ||||
| import {Language} from "./language"; | ||||
| 
 | ||||
| @Entity() | ||||
| export class LearningPath { | ||||
|     @Enum({items: () => Language}) | ||||
|     language!: Language; | ||||
| 
 | ||||
|     @Property({type: "string"}) | ||||
|     title!: string; | ||||
| 
 | ||||
|     @Property({type: "longtext"}) | ||||
|     description!: string; | ||||
| 
 | ||||
|     @Property({type: "blob"}) | ||||
|     image!: string; | ||||
| 
 | ||||
|     @Embedded({entity: () => LearningPathNode, array: true}) | ||||
|     nodes: LearningPathNode[]; | ||||
| } | ||||
| 
 | ||||
| @Embeddable() | ||||
| export class LearningPathNode { | ||||
|     @Property({type: "string"}) | ||||
|     learningObjectHruid!: string; | ||||
| 
 | ||||
|     @Enum({items: () => Language}) | ||||
|     language!: Language; | ||||
| 
 | ||||
|     @Property({type: "string"}) | ||||
|     version!: string; | ||||
| 
 | ||||
|     @Property({type: "longtext"}) | ||||
|     instruction!: string; | ||||
| 
 | ||||
|     @Property({type: "bool"}) | ||||
|     startNode!: boolean; | ||||
| 
 | ||||
|     @Embedded({entity: () => LearningPathTransition, array: true}) | ||||
|     transitions!: LearningPathTransition[]; | ||||
| } | ||||
| 
 | ||||
| @Embeddable() | ||||
| export class LearningPathTransition { | ||||
|     @Property({type: "string"}) | ||||
|     condition!: string; | ||||
| 
 | ||||
|     @OneToOne({entity: () => LearningPathNode}) | ||||
|     next!: LearningPathNode; | ||||
| } | ||||
|  | @ -1,6 +1,9 @@ | |||
| import {User} from "./user.entity"; | ||||
| import { Entity } from '@mikro-orm/core'; | ||||
| import {Collection, Entity, ManyToMany} from '@mikro-orm/core'; | ||||
| import {Class} from "../classes/class.entity"; | ||||
| 
 | ||||
| @Entity() | ||||
| export class Student extends User { | ||||
|     @ManyToMany(() => Class) | ||||
|     classes!: Collection<Class>; | ||||
| } | ||||
|  |  | |||
|  | @ -1,7 +1,9 @@ | |||
| import { Entity } from '@mikro-orm/core'; | ||||
| import {Collection, Entity, ManyToMany} from '@mikro-orm/core'; | ||||
| import {User} from "./user.entity"; | ||||
| import {Class} from "../classes/class.entity"; | ||||
| 
 | ||||
| @Entity() | ||||
| export class Teacher extends User { | ||||
| 
 | ||||
|     @ManyToMany(() => Class) | ||||
|     classes!: Collection<Class>; | ||||
| } | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { Entity, PrimaryKey, Property } from '@mikro-orm/core'; | ||||
| 
 | ||||
| @Entity({abstract: true}) | ||||
| export class User { | ||||
| export abstract class User { | ||||
|     @PrimaryKey({type: "string"}) | ||||
|     username!: string; | ||||
| 
 | ||||
|  |  | |||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger