From dc99835a9db40e3fef98fd17dd76f074ca57b520 Mon Sep 17 00:00:00 2001 From: Gerald Schmittinger Date: Tue, 1 Apr 2025 00:31:16 +0200 Subject: [PATCH] refactor(backend): Ondersteuning voor gepersonaliseerde leerpaden toegevoegd. --- frontend/src/queries/learning-paths.ts | 2 +- .../learning-paths/LearningObjectView.vue | 7 +- .../views/learning-paths/LearningPathPage.vue | 168 ++++++++++-------- 3 files changed, 99 insertions(+), 78 deletions(-) diff --git a/frontend/src/queries/learning-paths.ts b/frontend/src/queries/learning-paths.ts index 56699d7a..3ff44799 100644 --- a/frontend/src/queries/learning-paths.ts +++ b/frontend/src/queries/learning-paths.ts @@ -16,7 +16,7 @@ export function useGetLearningPathQuery( queryKey: [LEARNING_PATH_KEY, "get", hruid, language, options], queryFn: () => { const [hruidVal, languageVal, optionsVal] = [toValue(hruid), toValue(language), toValue(options)]; - return learningPathController.getBy(hruidVal, languageVal) + return learningPathController.getBy(hruidVal, languageVal, optionsVal) }, enabled: () => Boolean(toValue(hruid)) && Boolean(toValue(language)), }) diff --git a/frontend/src/views/learning-paths/LearningObjectView.vue b/frontend/src/views/learning-paths/LearningObjectView.vue index b03c5cb1..73413c00 100644 --- a/frontend/src/views/learning-paths/LearningObjectView.vue +++ b/frontend/src/views/learning-paths/LearningObjectView.vue @@ -18,10 +18,15 @@ const learningObjectHtmlQueryResult: UseQueryReturnType = useLe diff --git a/frontend/src/views/learning-paths/LearningPathPage.vue b/frontend/src/views/learning-paths/LearningPathPage.vue index 5a0fc4db..97867e0a 100644 --- a/frontend/src/views/learning-paths/LearningPathPage.vue +++ b/frontend/src/views/learning-paths/LearningPathPage.vue @@ -11,6 +11,7 @@ import {useGetLearningPathQuery} from "@/queries/learning-paths.ts"; import {useLearningObjectListForPathQuery} from "@/queries/learning-objects.ts"; import UsingQueryResult from "@/components/UsingQueryResult.vue"; + import authService from "@/services/auth/auth-service.ts"; const router = useRouter(); const route = useRoute(); @@ -18,14 +19,29 @@ const props = defineProps<{hruid: string, language: Language, learningObjectHruid?: string}>() - interface QueryParams { + interface Personalization { forStudent?: string, forGroup?: string } - const typedQuery = computed(() => route.query as QueryParams) + const personalization = computed(() => { + if (route.query.forStudent || route.query.forGroup) { + return { + forStudent: route.query.forStudent, + forGroup: route.query.forGroup + } as Personalization + } else { + return { + forStudent: authService.authState.user?.profile?.preferred_username + } as Personalization + } + }); - const learningPathQueryResult = useGetLearningPathQuery(props.hruid, props.language, typedQuery.value); + const learningPathQueryResult = useGetLearningPathQuery( + props.hruid, + props.language, + personalization + ); const learningObjectListQueryResult = useLearningObjectListForPathQuery(learningPathQueryResult.data); @@ -107,82 +123,82 @@