feat(backend): Controllers for learningObjects en learningPaths toegevoegd.

This commit is contained in:
Gerald Schmittinger 2025-03-31 16:23:38 +02:00
parent 2803a8be54
commit 5cfabb3518
4 changed files with 28 additions and 1 deletions

View file

@ -1,4 +1,6 @@
import { ThemeController } from "@/controllers/themes.ts";
import {LearningObjectController} from "@/controllers/learning-objects.ts";
import {LearningPathController} from "@/controllers/learning-paths.ts";
export function controllerGetter<T>(Factory: new () => T): () => T {
let instance: T | undefined;
@ -12,3 +14,5 @@ export function controllerGetter<T>(Factory: new () => T): () => T {
}
export const getThemeController = controllerGetter(ThemeController);
export const getLearningObjectController = controllerGetter(LearningObjectController);
export const getLearningPathController = controllerGetter(LearningPathController);

View file

@ -0,0 +1,23 @@
import {BaseController} from "@/controllers/base-controller.ts";
import {LearningPath} from "@/data-objects/learning-path.ts";
import type {LearningPathDTO} from "@/data-objects/learning-path.ts";
import type {Language} from "@/data-objects/language.ts";
export class LearningPathController extends BaseController {
constructor() {
super("learningPath");
}
async search(query: string) {
let dtos = await this.get<LearningPathDTO[]>("/", {search: query});
return dtos.map(dto => LearningPath.fromDTO(dto));
}
async getBy(hruid: string, language: Language, options?: {forGroup?: string, forStudent?: string}) {
let dtos = await this.get<LearningPathDTO[]>("/", {
hruid,
language,
forGroup: options?.forGroup,
forStudent: options?.forStudent
});
return dtos.map(dto => LearningPath.fromDTO(dto))
}
}

View file

@ -1,4 +1,4 @@
import type {Language} from "@/services/learning-content/language.ts";
import type {Language} from "@/data-objects/language.ts";
export interface EducationalGoal {
source: string;