feat(backend): Controllers for learningObjects en learningPaths toegevoegd.
This commit is contained in:
		
							parent
							
								
									2803a8be54
								
							
						
					
					
						commit
						5cfabb3518
					
				
					 4 changed files with 28 additions and 1 deletions
				
			
		|  | @ -1,4 +1,6 @@ | ||||||
| import { ThemeController } from "@/controllers/themes.ts"; | import { ThemeController } from "@/controllers/themes.ts"; | ||||||
|  | import {LearningObjectController} from "@/controllers/learning-objects.ts"; | ||||||
|  | import {LearningPathController} from "@/controllers/learning-paths.ts"; | ||||||
| 
 | 
 | ||||||
| export function controllerGetter<T>(Factory: new () => T): () => T { | export function controllerGetter<T>(Factory: new () => T): () => T { | ||||||
|     let instance: T | undefined; |     let instance: T | undefined; | ||||||
|  | @ -12,3 +14,5 @@ export function controllerGetter<T>(Factory: new () => T): () => T { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export const getThemeController = controllerGetter(ThemeController); | export const getThemeController = controllerGetter(ThemeController); | ||||||
|  | export const getLearningObjectController = controllerGetter(LearningObjectController); | ||||||
|  | export const getLearningPathController = controllerGetter(LearningPathController); | ||||||
|  |  | ||||||
							
								
								
									
										23
									
								
								frontend/src/controllers/learning-paths.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								frontend/src/controllers/learning-paths.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | ||||||
|  | import {BaseController} from "@/controllers/base-controller.ts"; | ||||||
|  | import {LearningPath} from "@/data-objects/learning-path.ts"; | ||||||
|  | import type {LearningPathDTO} from "@/data-objects/learning-path.ts"; | ||||||
|  | import type {Language} from "@/data-objects/language.ts"; | ||||||
|  | 
 | ||||||
|  | export class LearningPathController extends BaseController { | ||||||
|  |     constructor() { | ||||||
|  |         super("learningPath"); | ||||||
|  |     } | ||||||
|  |     async search(query: string) { | ||||||
|  |         let dtos = await this.get<LearningPathDTO[]>("/", {search: query}); | ||||||
|  |         return dtos.map(dto => LearningPath.fromDTO(dto)); | ||||||
|  |     } | ||||||
|  |     async getBy(hruid: string, language: Language, options?: {forGroup?: string, forStudent?: string}) { | ||||||
|  |         let dtos = await this.get<LearningPathDTO[]>("/", { | ||||||
|  |             hruid, | ||||||
|  |             language, | ||||||
|  |             forGroup: options?.forGroup, | ||||||
|  |             forStudent: options?.forStudent | ||||||
|  |         }); | ||||||
|  |         return dtos.map(dto => LearningPath.fromDTO(dto)) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| import type {Language} from "@/services/learning-content/language.ts"; | import type {Language} from "@/data-objects/language.ts"; | ||||||
| 
 | 
 | ||||||
| export interface EducationalGoal { | export interface EducationalGoal { | ||||||
|     source: string; |     source: string; | ||||||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger