72 lines
1.5 KiB
TypeScript
72 lines
1.5 KiB
TypeScript
import {
|
|
Embeddable,
|
|
Embedded,
|
|
Entity,
|
|
Enum,
|
|
ManyToMany,
|
|
OneToOne,
|
|
PrimaryKey,
|
|
Property,
|
|
} from '@mikro-orm/core';
|
|
import { Language } from './language.js';
|
|
import { Teacher } from '../users/teacher.entity.js';
|
|
|
|
@Entity()
|
|
export class LearningPath {
|
|
@PrimaryKey({ type: 'string' })
|
|
hruid!: string;
|
|
|
|
@Enum({ items: () => Language, primary: true })
|
|
language!: Language;
|
|
|
|
@ManyToMany({ entity: () => Teacher })
|
|
admins!: Teacher[];
|
|
|
|
@Property({ type: 'string' })
|
|
title!: string;
|
|
|
|
@Property({ type: 'text' })
|
|
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: 'number' })
|
|
version!: number;
|
|
|
|
@Property({ type: 'longtext' })
|
|
instruction!: string;
|
|
|
|
@Property({ type: 'bool' })
|
|
startNode!: boolean;
|
|
|
|
@Embedded({ entity: () => LearningPathTransition, array: true })
|
|
transitions!: LearningPathTransition[];
|
|
|
|
@Property({ length: 3 })
|
|
createdAt: Date = new Date();
|
|
|
|
@Property({ length: 3, onUpdate: () => new Date() })
|
|
updatedAt: Date = new Date();
|
|
}
|
|
|
|
@Embeddable()
|
|
export class LearningPathTransition {
|
|
@Property({ type: 'string' })
|
|
condition!: string;
|
|
|
|
@OneToOne({ entity: () => LearningPathNode })
|
|
next!: LearningPathNode;
|
|
}
|