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
|
@ -18,7 +18,8 @@
|
||||||
"@mikro-orm/postgresql": "^6.4.6",
|
"@mikro-orm/postgresql": "^6.4.6",
|
||||||
"@mikro-orm/reflection": "^6.4.6",
|
"@mikro-orm/reflection": "^6.4.6",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
"express": "^5.0.1"
|
"express": "^5.0.1",
|
||||||
|
"uuid": "^11.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mikro-orm/cli": "^6.4.6",
|
"@mikro-orm/cli": "^6.4.6",
|
||||||
|
|
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 {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()
|
@Entity()
|
||||||
export class Student extends User {
|
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 {User} from "./user.entity";
|
||||||
|
import {Class} from "../classes/class.entity";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Teacher extends User {
|
export class Teacher extends User {
|
||||||
|
@ManyToMany(() => Class)
|
||||||
|
classes!: Collection<Class>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
|
||||||
|
|
||||||
@Entity({abstract: true})
|
@Entity({abstract: true})
|
||||||
export class User {
|
export abstract class User {
|
||||||
@PrimaryKey({type: "string"})
|
@PrimaryKey({type: "string"})
|
||||||
username!: string;
|
username!: string;
|
||||||
|
|
||||||
|
|
17
package-lock.json
generated
17
package-lock.json
generated
|
@ -7,6 +7,7 @@
|
||||||
"": {
|
"": {
|
||||||
"name": "dwengo-1-monorepo",
|
"name": "dwengo-1-monorepo",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
|
"license": "MIT",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"backend",
|
"backend",
|
||||||
"frontend"
|
"frontend"
|
||||||
|
@ -26,13 +27,13 @@
|
||||||
"backend": {
|
"backend": {
|
||||||
"name": "dwengo-1-backend",
|
"name": "dwengo-1-backend",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mikro-orm/core": "^6.4.6",
|
"@mikro-orm/core": "^6.4.6",
|
||||||
"@mikro-orm/postgresql": "^6.4.6",
|
"@mikro-orm/postgresql": "^6.4.6",
|
||||||
"@mikro-orm/reflection": "^6.4.6",
|
"@mikro-orm/reflection": "^6.4.6",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
"express": "^5.0.1"
|
"express": "^5.0.1",
|
||||||
|
"uuid": "^11.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mikro-orm/cli": "^6.4.6",
|
"@mikro-orm/cli": "^6.4.6",
|
||||||
|
@ -8021,6 +8022,18 @@
|
||||||
"node": ">= 0.4.0"
|
"node": ">= 0.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/uuid": {
|
||||||
|
"version": "11.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz",
|
||||||
|
"integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==",
|
||||||
|
"funding": [
|
||||||
|
"https://github.com/sponsors/broofa",
|
||||||
|
"https://github.com/sponsors/ctavan"
|
||||||
|
],
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/esm/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/v8-compile-cache-lib": {
|
"node_modules/v8-compile-cache-lib": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue