feat(frontend): gebruikersvriendelijkere foutmeldingen voor foutieve leerpaden

This commit is contained in:
Gerald Schmittinger 2025-05-14 23:10:31 +02:00
parent ac933df57b
commit 759282f1c6
7 changed files with 22 additions and 8 deletions

View file

@ -27,7 +27,7 @@
<div v-if="isError">
<v-empty-state
icon="mdi-alert-circle-outline"
:text="errorMessage"
:text="t(errorMessage)"
:title="t('error_title')"
></v-empty-state>
</div>

View file

@ -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<LearningPath[]> {
const dtos = await this.get<LearningPathDTO[]>("/", { theme });

View file

@ -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];
}

View file

@ -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."
}

View file

@ -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."
}

View file

@ -161,5 +161,7 @@
"learningPathCantModifyId": "Le HRUID ou la langue dun parcours ne peuvent pas être modifiés.",
"error": "Erreur",
"ownLearningContentTitle": "Contenu dapprentissage personnel",
"ownLearningContentDescription": "Créez et gérez vos propres objets et parcours dapprentissage. Réservé aux utilisateurs avancés."
"ownLearningContentDescription": "Créez et gérez vos propres objets et parcours dapprentissage. Réservé aux utilisateurs avancés.",
"learningPathNotFound": "Ce parcours d'apprentissage est introuvable.",
"emptyLearningPath": "Ce parcours d'apprentissage ne contient aucun objet d'apprentissage."
}

View file

@ -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."
}