fix: maak questions zichtbaar enkel voor groep
This commit is contained in:
		
							parent
							
								
									f6c2f71edb
								
							
						
					
					
						commit
						f85abea6f3
					
				
					 3 changed files with 55 additions and 21 deletions
				
			
		|  | @ -18,6 +18,10 @@ export class QuestionController extends BaseController { | |||
|         this.loId = loId; | ||||
|     } | ||||
| 
 | ||||
|     async getAllGroup(classId: string, assignmentId: string, forStudent: string, full = true): Promise<QuestionsResponse> { | ||||
|         return this.get<QuestionsResponse>("/", { lang: this.loId.language, full, classId, assignmentId, forStudent }); | ||||
|     } | ||||
| 
 | ||||
|     async getAll(full = true): Promise<QuestionsResponse> { | ||||
|         return this.get<QuestionsResponse>("/", { lang: this.loId.language, full }); | ||||
|     } | ||||
|  |  | |||
|  | @ -17,6 +17,16 @@ export function questionsQueryKey( | |||
|     return ["questions", loId.hruid, loId.version!, loId.language, full]; | ||||
| } | ||||
| 
 | ||||
| export function questionsGroupQueryKey( | ||||
|     loId: LearningObjectIdentifierDTO, | ||||
|     classId: string, | ||||
|     assignmentId: string, | ||||
|     student: string, | ||||
|     full: boolean, | ||||
| ): [string, string, number, string, boolean] { | ||||
|     return ["questions", loId.hruid, loId.version!, loId.language, full, classId, assignmentId, student]; | ||||
| } | ||||
| 
 | ||||
| export function questionQueryKey(questionId: QuestionId): [string, string, number, string, number] { | ||||
|     const loId = questionId.learningObjectIdentifier; | ||||
|     return ["question", loId.hruid, loId.version!, loId.language, questionId.sequenceNumber]; | ||||
|  | @ -33,6 +43,20 @@ export function useQuestionsQuery( | |||
|     }); | ||||
| } | ||||
| 
 | ||||
| export function useQuestionsGroupQuery( | ||||
|     loId: MaybeRefOrGetter<LearningObjectIdentifierDTO>, | ||||
|     classId: MaybeRefOrGetter<string>, | ||||
|     assignmentId: MaybeRefOrGetter<string>, | ||||
|     student: MaybeRefOrGetter<string>, | ||||
|     full: MaybeRefOrGetter<boolean> = true, | ||||
| ): UseQueryReturnType<QuestionsResponse, Error> { | ||||
|     return useQuery({ | ||||
|         queryKey: computed(() => questionsGroupQueryKey(toValue(loId), toValue(full), toValue(classId), toValue(assignmentId), toValue(student))), | ||||
|         queryFn: async () => new QuestionController(toValue(loId)).getAllGroup( toValue(classId), toValue(assignmentId), toValue(student),toValue(full)), | ||||
|         enabled: () => Boolean(toValue(loId)), | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| export function useQuestionQuery( | ||||
|     questionId: MaybeRefOrGetter<QuestionId>, | ||||
| ): UseQueryReturnType<QuestionResponse, Error> { | ||||
|  |  | |||
|  | @ -13,13 +13,11 @@ | |||
|     import authService from "@/services/auth/auth-service.ts"; | ||||
|     import { LearningPathNode } from "@/data-objects/learning-paths/learning-path-node.ts"; | ||||
|     import LearningPathGroupSelector from "@/views/learning-paths/LearningPathGroupSelector.vue"; | ||||
|     import { useCreateQuestionMutation, useQuestionsQuery } from "@/queries/questions"; | ||||
|     import {useQuestionsGroupQuery, useQuestionsQuery} from "@/queries/questions"; | ||||
|     import type { QuestionsResponse } from "@/controllers/questions"; | ||||
|     import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content"; | ||||
|     import QandA from "@/components/QandA.vue"; | ||||
|     import type { QuestionDTO } from "@dwengo-1/common/interfaces/question"; | ||||
|     import { useStudentAssignmentsQuery, useStudentGroupsQuery } from "@/queries/students"; | ||||
|     import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment"; | ||||
|     import QuestionNotification from "@/components/QuestionNotification.vue"; | ||||
|     import QuestionBox from "@/components/QuestionBox.vue"; | ||||
|     import { AccountType } from "@dwengo-1/common/util/account-types"; | ||||
|  | @ -78,16 +76,32 @@ | |||
|         return currentIndex < nodesList.value?.length ? nodesList.value?.[currentIndex - 1] : undefined; | ||||
|     }); | ||||
| 
 | ||||
|     const getQuestionsQuery = useQuestionsQuery( | ||||
|         computed( | ||||
|             () => | ||||
|                 ({ | ||||
|                     language: currentNode.value?.language, | ||||
|                     hruid: currentNode.value?.learningobjectHruid, | ||||
|                     version: currentNode.value?.version, | ||||
|                 }) as LearningObjectIdentifierDTO, | ||||
|         ), | ||||
|     ); | ||||
| 
 | ||||
| 
 | ||||
|     let getQuestionsQuery; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     if (authService.authState.activeRole === AccountType.Student) { | ||||
|         getQuestionsQuery = useQuestionsGroupQuery( | ||||
|             computed(() => ({ | ||||
|                 language: currentNode.value?.language, | ||||
|                 hruid: currentNode.value?.learningobjectHruid, | ||||
|                 version: currentNode.value?.version, | ||||
|             }) as LearningObjectIdentifierDTO), | ||||
|             computed(() => query.value.classId ?? ""), | ||||
|             computed(() => query.value.assignmentNo ?? ""), | ||||
|             computed(() => authService.authState.user?.profile.preferred_username ?? "") | ||||
|         ); | ||||
|     } else { | ||||
|         getQuestionsQuery = useQuestionsQuery( | ||||
|             computed(() => ({ | ||||
|                 language: currentNode.value?.language, | ||||
|                 hruid: currentNode.value?.learningobjectHruid, | ||||
|                 version: currentNode.value?.version, | ||||
|             }) as LearningObjectIdentifierDTO) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     const navigationDrawerShown = ref(true); | ||||
| 
 | ||||
|  | @ -147,18 +161,10 @@ | |||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     const studentAssignmentsQueryResult = useStudentAssignmentsQuery( | ||||
|         authService.authState.user?.profile.preferred_username, | ||||
|     ); | ||||
| 
 | ||||
|     const loID: LearningObjectIdentifierDTO = { | ||||
|         hruid: props.learningObjectHruid as string, | ||||
|         language: props.language, | ||||
|     }; | ||||
|     const createQuestionMutation = useCreateQuestionMutation(loID); | ||||
|     const groupsQueryResult = useStudentGroupsQuery(authService.authState.user?.profile.preferred_username); | ||||
| 
 | ||||
|     const questionInput = ref(""); | ||||
| 
 | ||||
|     const discussionLink = computed( | ||||
|         () => | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl