Merge branch 'feat/endpoints-in-backend-om-eigen-leerpaden-en-leerobjecten-toe-te-voegen-aan-de-databank-#248' of https://github.com/SELab-2/Dwengo-1 into feat/endpoints-in-backend-om-eigen-leerpaden-en-leerobjecten-toe-te-voegen-aan-de-databank-#248
This commit is contained in:
		
						commit
						9206be60b5
					
				
					 2 changed files with 18 additions and 19 deletions
				
			
		|  | @ -45,25 +45,24 @@ export function mapToLearningPath(dto: LearningPath, adminsDto: TeacherDTO[]): L | ||||||
|         const fromNode = nodes.find( |         const fromNode = nodes.find( | ||||||
|             (it) => it.learningObjectHruid === nodeDto.learningobject_hruid && it.language === nodeDto.language && it.version === nodeDto.version |             (it) => it.learningObjectHruid === nodeDto.learningobject_hruid && it.language === nodeDto.language && it.version === nodeDto.version | ||||||
|         )!; |         )!; | ||||||
|         const transitions = nodeDto.transitions |         const transitions = nodeDto.transitions.map((transDto, i) => { | ||||||
|             .map((transDto, i) => { |             const toNode = nodes.find( | ||||||
|                 const toNode = nodes.find( |                 (it) => | ||||||
|                     (it) => |                     it.learningObjectHruid === transDto.next.hruid && it.language === transDto.next.language && it.version === transDto.next.version | ||||||
|                         it.learningObjectHruid === transDto.next.hruid && |             ); | ||||||
|                         it.language === transDto.next.language && |  | ||||||
|                         it.version === transDto.next.version |  | ||||||
|                 ); |  | ||||||
| 
 | 
 | ||||||
|                 if (toNode) { |             if (toNode) { | ||||||
|                     return repo.createTransition({ |                 return repo.createTransition({ | ||||||
|                         transitionNumber: i, |                     transitionNumber: i, | ||||||
|                         node: fromNode, |                     node: fromNode, | ||||||
|                         next: toNode, |                     next: toNode, | ||||||
|                         condition: transDto.condition ?? 'true', |                     condition: transDto.condition ?? 'true', | ||||||
|                     }); |                 }); | ||||||
|                 } |             } | ||||||
|                 throw new BadRequestException(`Invalid transition destination: ${JSON.stringify(transDto.next)}: This learning object does not exist in this learning path.`); |             throw new BadRequestException( | ||||||
|             }); |                 `Invalid transition destination: ${JSON.stringify(transDto.next)}: This learning object does not exist in this learning path.` | ||||||
|  |             ); | ||||||
|  |         }); | ||||||
| 
 | 
 | ||||||
|         fromNode.transitions = new Collection<LearningPathTransition>(fromNode, transitions); |         fromNode.transitions = new Collection<LearningPathTransition>(fromNode, transitions); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ export class LearningPathController extends BaseController { | ||||||
|             classId: forGroup?.classId, |             classId: forGroup?.classId, | ||||||
|         }); |         }); | ||||||
|         if (dtos.length === 0) { |         if (dtos.length === 0) { | ||||||
|             throw new NotFoundException('learningPathNotFound') |             throw new NotFoundException("learningPathNotFound"); | ||||||
|         } |         } | ||||||
|         return LearningPath.fromDTO(dtos[0]); |         return LearningPath.fromDTO(dtos[0]); | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger