From 759282f1c6d1c153e0d510afec34c134a9f19c29 Mon Sep 17 00:00:00 2001 From: Gerald Schmittinger Date: Wed, 14 May 2025 23:10:31 +0200 Subject: [PATCH] feat(frontend): gebruikersvriendelijkere foutmeldingen voor foutieve leerpaden --- frontend/src/components/UsingQueryResult.vue | 2 +- frontend/src/controllers/learning-paths.ts | 7 +++++-- frontend/src/data-objects/learning-paths/learning-path.ts | 5 ++++- frontend/src/i18n/locale/de.json | 4 +++- frontend/src/i18n/locale/en.json | 4 +++- frontend/src/i18n/locale/fr.json | 4 +++- frontend/src/i18n/locale/nl.json | 4 +++- 7 files changed, 22 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/UsingQueryResult.vue b/frontend/src/components/UsingQueryResult.vue index 27271184..045ff62a 100644 --- a/frontend/src/components/UsingQueryResult.vue +++ b/frontend/src/components/UsingQueryResult.vue @@ -27,7 +27,7 @@
diff --git a/frontend/src/controllers/learning-paths.ts b/frontend/src/controllers/learning-paths.ts index 4a8a1824..bf0d3354 100644 --- a/frontend/src/controllers/learning-paths.ts +++ b/frontend/src/controllers/learning-paths.ts @@ -1,7 +1,7 @@ import { BaseController } from "@/controllers/base-controller.ts"; import type { Language } from "@/data-objects/language.ts"; import { LearningPath } from "@/data-objects/learning-paths/learning-path"; -import { single } from "@/utils/response-assertions.ts"; +import { NotFoundException } from "@/exception/not-found-exception"; import type { LearningPath as LearningPathDTO } from "@dwengo-1/common/interfaces/learning-content"; export class LearningPathController extends BaseController { @@ -24,7 +24,10 @@ export class LearningPathController extends BaseController { assignmentNo: forGroup?.assignmentNo, classId: forGroup?.classId, }); - return LearningPath.fromDTO(single(dtos)); + if (dtos.length === 0) { + throw new NotFoundException('learningPathNotFound') + } + return LearningPath.fromDTO(dtos[0]); } async getAllByTheme(theme: string): Promise { const dtos = await this.get("/", { theme }); diff --git a/frontend/src/data-objects/learning-paths/learning-path.ts b/frontend/src/data-objects/learning-paths/learning-path.ts index 6346fa09..880aad85 100644 --- a/frontend/src/data-objects/learning-paths/learning-path.ts +++ b/frontend/src/data-objects/learning-paths/learning-path.ts @@ -93,7 +93,10 @@ export class LearningPath { const startNodeDtos = dto.nodes.filter((it) => it.start_node === true); if (startNodeDtos.length < 1) { // The learning path has no starting node -> use the first node. - return dto.nodes[0]; + if (dto.nodes.length > 0) { + return dto.nodes[0]; + } + throw new Error("emptyLearningPath"); } // The learning path has 1 or more starting nodes -> use the first start node. return startNodeDtos[0]; } diff --git a/frontend/src/i18n/locale/de.json b/frontend/src/i18n/locale/de.json index b2c03520..b00938db 100644 --- a/frontend/src/i18n/locale/de.json +++ b/frontend/src/i18n/locale/de.json @@ -160,5 +160,7 @@ "learningPathCantModifyId": "Der HRUID oder die Sprache eines Lernpfads kann nicht geändert werden.", "error": "Fehler", "ownLearningContentTitle": "Eigene Lerninhalte", - "ownLearningContentDescription": "Erstellen und verwalten Sie eigene Lernobjekte und Lernpfade. Nur für fortgeschrittene Nutzer." + "ownLearningContentDescription": "Erstellen und verwalten Sie eigene Lernobjekte und Lernpfade. Nur für fortgeschrittene Nutzer.", + "learningPathNotFound": "Dieser Lernpfad konnte nicht gefunden werden.", + "emptyLearningPath": "Dieser Lernpfad enthält keine Lernobjekte." } diff --git a/frontend/src/i18n/locale/en.json b/frontend/src/i18n/locale/en.json index 5ed93799..76082487 100644 --- a/frontend/src/i18n/locale/en.json +++ b/frontend/src/i18n/locale/en.json @@ -160,5 +160,7 @@ "learningPathCantModifyId": "The HRUID or language of a learning path cannot be modified.", "error": "Error", "ownLearningContentTitle": "Own learning content", - "ownLearningContentDescription": "Create and administrate your own learning objects and learning paths. For advanced users only." + "ownLearningContentDescription": "Create and administrate your own learning objects and learning paths. For advanced users only.", + "learningPathNotFound": "This learning path could not be found.", + "emptyLearningPath": "This learning path does not contain any learning objects." } diff --git a/frontend/src/i18n/locale/fr.json b/frontend/src/i18n/locale/fr.json index fd4840fc..e2e2a094 100644 --- a/frontend/src/i18n/locale/fr.json +++ b/frontend/src/i18n/locale/fr.json @@ -161,5 +161,7 @@ "learningPathCantModifyId": "Le HRUID ou la langue d’un parcours ne peuvent pas être modifiés.", "error": "Erreur", "ownLearningContentTitle": "Contenu d’apprentissage personnel", - "ownLearningContentDescription": "Créez et gérez vos propres objets et parcours d’apprentissage. Réservé aux utilisateurs avancés." + "ownLearningContentDescription": "Créez et gérez vos propres objets et parcours d’apprentissage. Réservé aux utilisateurs avancés.", + "learningPathNotFound": "Ce parcours d'apprentissage est introuvable.", + "emptyLearningPath": "Ce parcours d'apprentissage ne contient aucun objet d'apprentissage." } diff --git a/frontend/src/i18n/locale/nl.json b/frontend/src/i18n/locale/nl.json index b12bbf77..3bfacea7 100644 --- a/frontend/src/i18n/locale/nl.json +++ b/frontend/src/i18n/locale/nl.json @@ -160,5 +160,7 @@ "learningPathCantModifyId": "De HRUID of taal van een leerpad kan niet worden gewijzigd.", "error": "Fout", "ownLearningContentTitle": "Eigen leerinhoud", - "ownLearningContentDescription": "Maak en beheer je eigen leerobjecten en leerpads. Alleen voor gevorderde gebruikers." + "ownLearningContentDescription": "Maak en beheer je eigen leerobjecten en leerpads. Alleen voor gevorderde gebruikers.", + "learningPathNotFound": "Dit leerpad kon niet gevonden worden.", + "emptyLearningPath": "Dit leerpad bevat geen leerobjecten." }