feat(frontend): Navigatie voor leerpad geïmplementeerd.

This commit is contained in:
Gerald Schmittinger 2025-03-23 19:20:56 +01:00
parent 3c3fddb7d0
commit 07340de2e3
13 changed files with 216 additions and 54 deletions

View file

@ -1,5 +1,5 @@
import type {Language} from "@/services/learning-content/language.ts";
import type {RemoteResource} from "@/services/api-client/remote-resource.ts";
import {RemoteResource} from "@/services/api-client/remote-resource.ts";
import type {LearningObject} from "@/services/learning-content/learning-object.ts";
import {getLearningObjectMetadata} from "@/services/learning-content/learning-object-service.ts";
@ -98,6 +98,21 @@ export class LearningPath {
) {
}
public get nodesAsList(): LearningPathNode[] {
let list: LearningPathNode[] = [];
let currentNode = this.startNode;
while (currentNode) {
list.push(currentNode);
currentNode = currentNode.transitions.filter(it => it.default)[0]?.next
|| currentNode.transitions[0]?.next;
}
return list;
}
public get learningObjectsAsList(): RemoteResource<LearningObject[]> {
return RemoteResource.join(this.nodesAsList.map(node => node.learningObject));
}
static fromDTO(dto: LearningPathDTO): LearningPath {
let startNodeDto = dto.nodes.filter(it => it.start_node);
if (startNodeDto.length !== 1) {