fix(backend): Foute entity-structuur van leerpaden verbeterd.
Ook testen geschreven voor LearningPathRepository en LearningObjectRepository.
This commit is contained in:
		
							parent
							
								
									4d999c78ba
								
							
						
					
					
						commit
						1417907933
					
				
					 24 changed files with 474 additions and 64 deletions
				
			
		
							
								
								
									
										3
									
								
								backend/tests/test-assets/learning-paths/learning-path-example.d.ts
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								backend/tests/test-assets/learning-paths/learning-path-example.d.ts
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | |||
| type LearningPathExample = { | ||||
|     createLearningPath: () => LearningPath | ||||
| }; | ||||
|  | @ -0,0 +1,24 @@ | |||
| import {Language} from "../../../src/entities/content/language"; | ||||
| import {LearningPathTransition} from "../../../src/entities/content/learning-path-transition.entity"; | ||||
| import {LearningPathNode} from "../../../src/entities/content/learning-path-node.entity"; | ||||
| 
 | ||||
| export function createLearningPathTransition(condition: string | null, to: LearningPathNode) { | ||||
|     let trans = new LearningPathTransition(); | ||||
|     trans.condition = condition || "true"; | ||||
|     trans.next = to; | ||||
|     return trans; | ||||
| } | ||||
| 
 | ||||
| export function createLearningPathNode( | ||||
|     learningObjectHruid: string, | ||||
|     version: number, | ||||
|     language: Language, | ||||
|     startNode: boolean | ||||
| ) { | ||||
|     let node = new LearningPathNode(); | ||||
|     node.learningObjectHruid = learningObjectHruid; | ||||
|     node.version = version; | ||||
|     node.language = language; | ||||
|     node.startNode = startNode; | ||||
|     return node; | ||||
| } | ||||
|  | @ -0,0 +1,29 @@ | |||
| import {LearningPath, LearningPathNode} from "../../../src/entities/content/learning-path.entity"; | ||||
| import {Language} from "../../../src/entities/content/language"; | ||||
| import {EnvVars, getEnvVar} from "../../../src/util/envvars"; | ||||
| import {createLearningPathNode, createLearningPathTransition} from "./learning-path-utils"; | ||||
| 
 | ||||
| function createNodes(): LearningPathNode[] { | ||||
|     let nodes = [ | ||||
|         createLearningPathNode("u_pn_werkingnotebooks", 3, Language.Dutch, true), | ||||
|         createLearningPathNode("pn_werkingnotebooks2", 3, Language.Dutch, false), | ||||
|         createLearningPathNode("pn_werkingnotebooks3", 3, Language.Dutch, false), | ||||
|     ]; | ||||
|     nodes[0].transitions.push(createLearningPathTransition("true", nodes[1])); | ||||
|     nodes[1].transitions.push(createLearningPathTransition("true", nodes[2])); | ||||
|     return nodes; | ||||
| } | ||||
| 
 | ||||
| const example: LearningPathExample = { | ||||
|     createLearningPath: () => { | ||||
|         const path = new LearningPath(); | ||||
|         path.language = Language.Dutch; | ||||
|         path.hruid = `${getEnvVar(EnvVars.UserContentPrefix)}pn_werking`; | ||||
|         path.title = "Werken met notebooks"; | ||||
|         path.description = "Een korte inleiding tot Python notebooks. Hoe ga je gemakkelijk en efficiënt met de notebooks aan de slag?"; | ||||
|         path.nodes = createNodes(); | ||||
|         return path; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| export default example; | ||||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger