98 lines
1.8 KiB
TypeScript
98 lines
1.8 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';
|
|
import { LearningPathRepository } from '../../data/content/learning-path-repository.js';
|
|
|
|
@Entity({
|
|
repository: () => {
|
|
return LearningPathRepository;
|
|
},
|
|
})
|
|
export class LearningPath {
|
|
@PrimaryKey({ type: 'string' })
|
|
hruid!: string;
|
|
|
|
@Enum({
|
|
items: () => {
|
|
return Language;
|
|
},
|
|
primary: true,
|
|
})
|
|
language!: Language;
|
|
|
|
@ManyToMany({
|
|
entity: () => {
|
|
return Teacher;
|
|
},
|
|
})
|
|
admins!: Teacher[];
|
|
|
|
@Property({ type: 'string' })
|
|
title!: string;
|
|
|
|
@Property({ type: 'text' })
|
|
description!: string;
|
|
|
|
@Property({ type: 'blob' })
|
|
image!: string;
|
|
|
|
@Embedded({
|
|
entity: () => {
|
|
return LearningPathNode;
|
|
},
|
|
array: true,
|
|
})
|
|
nodes: LearningPathNode[] = [];
|
|
}
|
|
|
|
@Embeddable()
|
|
export class LearningPathNode {
|
|
@Property({ type: 'string' })
|
|
learningObjectHruid!: string;
|
|
|
|
@Enum({
|
|
items: () => {
|
|
return Language;
|
|
},
|
|
})
|
|
language!: Language;
|
|
|
|
@Property({ type: 'string' })
|
|
version!: string;
|
|
|
|
@Property({ type: 'longtext' })
|
|
instruction!: string;
|
|
|
|
@Property({ type: 'bool' })
|
|
startNode!: boolean;
|
|
|
|
@Embedded({
|
|
entity: () => {
|
|
return LearningPathTransition;
|
|
},
|
|
array: true,
|
|
})
|
|
transitions!: LearningPathTransition[];
|
|
}
|
|
|
|
@Embeddable()
|
|
export class LearningPathTransition {
|
|
@Property({ type: 'string' })
|
|
condition!: string;
|
|
|
|
@OneToOne({
|
|
entity: () => {
|
|
return LearningPathNode;
|
|
},
|
|
})
|
|
next!: LearningPathNode;
|
|
}
|