diff --git a/backend/src/services/learning-paths/learning-path-service.ts b/backend/src/services/learning-paths/learning-path-service.ts index e51d84fa..e273c98a 100644 --- a/backend/src/services/learning-paths/learning-path-service.ts +++ b/backend/src/services/learning-paths/learning-path-service.ts @@ -45,25 +45,24 @@ export function mapToLearningPath(dto: LearningPath, adminsDto: TeacherDTO[]): L const fromNode = nodes.find( (it) => it.learningObjectHruid === nodeDto.learningobject_hruid && it.language === nodeDto.language && it.version === nodeDto.version )!; - const transitions = nodeDto.transitions - .map((transDto, i) => { - const toNode = nodes.find( - (it) => - it.learningObjectHruid === transDto.next.hruid && - it.language === transDto.next.language && - it.version === transDto.next.version - ); + const transitions = nodeDto.transitions.map((transDto, i) => { + const toNode = nodes.find( + (it) => + it.learningObjectHruid === transDto.next.hruid && it.language === transDto.next.language && it.version === transDto.next.version + ); - if (toNode) { - return repo.createTransition({ - transitionNumber: i, - node: fromNode, - next: toNode, - condition: transDto.condition ?? 'true', - }); - } - throw new BadRequestException(`Invalid transition destination: ${JSON.stringify(transDto.next)}: This learning object does not exist in this learning path.`); - }); + if (toNode) { + return repo.createTransition({ + transitionNumber: i, + node: fromNode, + next: toNode, + condition: transDto.condition ?? 'true', + }); + } + throw new BadRequestException( + `Invalid transition destination: ${JSON.stringify(transDto.next)}: This learning object does not exist in this learning path.` + ); + }); fromNode.transitions = new Collection(fromNode, transitions); }); diff --git a/frontend/src/controllers/learning-paths.ts b/frontend/src/controllers/learning-paths.ts index bf0d3354..d7771c22 100644 --- a/frontend/src/controllers/learning-paths.ts +++ b/frontend/src/controllers/learning-paths.ts @@ -25,7 +25,7 @@ export class LearningPathController extends BaseController { classId: forGroup?.classId, }); if (dtos.length === 0) { - throw new NotFoundException('learningPathNotFound') + throw new NotFoundException("learningPathNotFound"); } return LearningPath.fromDTO(dtos[0]); }