Merge remote-tracking branch 'origin/dev' into feat/indieningen-kunnen-posten-en-bekijken-#194
# Conflicts: # frontend/src/queries/groups.ts # frontend/src/queries/submissions.ts
This commit is contained in:
		
						commit
						ce5c0ea629
					
				
					 14 changed files with 152 additions and 66 deletions
				
			
		|  | @ -1,6 +1,6 @@ | |||
| import { Request, Response } from 'express'; | ||||
| import { requireFields } from './error-helper'; | ||||
| import { createInvitation, deleteInvitation, getAllInvitations, getInvitation, updateInvitation } from '../services/teacher-invitations'; | ||||
| import { requireFields } from './error-helper.js'; | ||||
| import { createInvitation, deleteInvitation, getAllInvitations, getInvitation, updateInvitation } from '../services/teacher-invitations.js'; | ||||
| import { TeacherInvitationData } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| 
 | ||||
| export async function getAllInvitationsHandler(req: Request, res: Response): Promise<void> { | ||||
|  |  | |||
|  | @ -8,7 +8,7 @@ import { getGroupRepository } from '../data/repositories.js'; | |||
| import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment'; | ||||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { StudentDTO } from '@dwengo-1/common/interfaces/student'; | ||||
| import { mapToClassDTO } from './class'; | ||||
| import { mapToClassDTO } from './class.js'; | ||||
| 
 | ||||
| export function mapToGroup(groupDto: GroupDTO, clazz: Class): Group { | ||||
|     const assignmentDto = groupDto.assignment as AssignmentDTO; | ||||
|  |  | |||
|  | @ -2,9 +2,9 @@ import { Submission } from '../entities/assignments/submission.entity.js'; | |||
| import { mapToGroupDTOId } from './group.js'; | ||||
| import { mapToStudentDTO } from './student.js'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/submission'; | ||||
| import { getSubmissionRepository } from '../data/repositories'; | ||||
| import { Student } from '../entities/users/student.entity'; | ||||
| import { Group } from '../entities/assignments/group.entity'; | ||||
| import { getSubmissionRepository } from '../data/repositories.js'; | ||||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import { Group } from '../entities/assignments/group.entity.js'; | ||||
| 
 | ||||
| export function mapToSubmissionDTO(submission: Submission): SubmissionDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| import { TeacherInvitation } from '../entities/classes/teacher-invitation.entity.js'; | ||||
| import { mapToUserDTO } from './user.js'; | ||||
| import { TeacherInvitationDTO } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import { getTeacherInvitationRepository } from '../data/repositories'; | ||||
| import { Teacher } from '../entities/users/teacher.entity'; | ||||
| import { Class } from '../entities/classes/class.entity'; | ||||
| import { getTeacherInvitationRepository } from '../data/repositories.js'; | ||||
| import { Teacher } from '../entities/users/teacher.entity.js'; | ||||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export function mapToTeacherInvitationDTO(invitation: TeacherInvitation): TeacherInvitationDTO { | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ import { | |||
|     getAllInvitationsHandler, | ||||
|     getInvitationHandler, | ||||
|     updateInvitationHandler, | ||||
| } from '../controllers/teacher-invitations'; | ||||
| } from '../controllers/teacher-invitations.js'; | ||||
| 
 | ||||
| const router = express.Router({ mergeParams: true }); | ||||
| 
 | ||||
|  |  | |||
|  | @ -10,7 +10,7 @@ import { AnswerDTO, AnswerId } from '@dwengo-1/common/interfaces/answer'; | |||
| import { mapToAssignment } from '../interfaces/assignment.js'; | ||||
| import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment'; | ||||
| import { fetchStudent } from './students.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import { FALLBACK_VERSION_NUM } from '../config.js'; | ||||
| 
 | ||||
| export async function getQuestionsAboutLearningObjectInAssignment( | ||||
|  |  | |||
|  | @ -1,11 +1,11 @@ | |||
| import { fetchTeacher } from './teachers'; | ||||
| import { getTeacherInvitationRepository } from '../data/repositories'; | ||||
| import { mapToInvitation, mapToTeacherInvitationDTO } from '../interfaces/teacher-invitation'; | ||||
| import { addClassTeacher, fetchClass } from './classes'; | ||||
| import { fetchTeacher } from './teachers.js'; | ||||
| import { getTeacherInvitationRepository } from '../data/repositories.js'; | ||||
| import { mapToInvitation, mapToTeacherInvitationDTO } from '../interfaces/teacher-invitation.js'; | ||||
| import { addClassTeacher, fetchClass } from './classes.js'; | ||||
| import { TeacherInvitationData, TeacherInvitationDTO } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import { ConflictException } from '../exceptions/conflict-exception'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception'; | ||||
| import { TeacherInvitation } from '../entities/classes/teacher-invitation.entity'; | ||||
| import { ConflictException } from '../exceptions/conflict-exception.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import { TeacherInvitation } from '../entities/classes/teacher-invitation.entity.js'; | ||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export async function getAllInvitations(username: string, sent: boolean): Promise<TeacherInvitationDTO[]> { | ||||
|  |  | |||
|  | @ -21,7 +21,14 @@ const vueConfig = defineConfigWithVueTs( | |||
| 
 | ||||
|     { | ||||
|         name: "app/files-to-ignore", | ||||
|         ignores: ["**/dist/**", "**/dist-ssr/**", "**/coverage/**", "prettier.config.js"], | ||||
|         ignores: [ | ||||
|             "**/dist/**", | ||||
|             "**/dist-ssr/**", | ||||
|             "**/coverage/**", | ||||
|             "prettier.config.js", | ||||
|             "**/test-results/**", | ||||
|             "**/playwright-report/**", | ||||
|         ], | ||||
|     }, | ||||
| 
 | ||||
|     pluginVue.configs["flat/essential"], | ||||
|  |  | |||
|  | @ -80,13 +80,14 @@ | |||
|             > | ||||
|                 {{ t("classes") }} | ||||
|             </v-btn> | ||||
|             <v-btn | ||||
|                 class="menu_item" | ||||
|                 variant="text" | ||||
|                 to="/user/discussion" | ||||
|             > | ||||
|                 {{ t("discussions") }} | ||||
|             </v-btn> | ||||
|             <!-- TODO Re-enable this button when the discussion page is ready --> | ||||
|             <!--            <v-btn--> | ||||
|             <!--                class="menu_item"--> | ||||
|             <!--                variant="text"--> | ||||
|             <!--                to="/user/discussion"--> | ||||
|             <!--            >--> | ||||
|             <!--                {{ t("discussions") }}--> | ||||
|             <!--            </v-btn>--> | ||||
|             <v-menu open-on-hover> | ||||
|                 <template v-slot:activator="{ props }"> | ||||
|                     <v-btn | ||||
|  |  | |||
|  | @ -15,16 +15,35 @@ import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment"; | |||
| import type { QueryClient } from "@tanstack/react-query"; | ||||
| import { invalidateAllSubmissionKeys } from "./submissions"; | ||||
| 
 | ||||
| function assignmentsQueryKey(classid: string, full: boolean) { | ||||
| type AssignmentsQueryKey = ["assignments", string, boolean]; | ||||
| 
 | ||||
| function assignmentsQueryKey(classid: string, full: boolean): AssignmentsQueryKey { | ||||
|     return ["assignments", classid, full]; | ||||
| } | ||||
| function assignmentQueryKey(classid: string, assignmentNumber: number) { | ||||
| 
 | ||||
| type AssignmentQueryKey = ["assignment", string, number]; | ||||
| 
 | ||||
| function assignmentQueryKey(classid: string, assignmentNumber: number): AssignmentQueryKey { | ||||
|     return ["assignment", classid, assignmentNumber]; | ||||
| } | ||||
| function assignmentSubmissionsQueryKey(classid: string, assignmentNumber: number, full: boolean) { | ||||
| 
 | ||||
| type AssignmentSubmissionsQueryKey = ["assignment-submissions", string, number, boolean]; | ||||
| 
 | ||||
| function assignmentSubmissionsQueryKey( | ||||
|     classid: string, | ||||
|     assignmentNumber: number, | ||||
|     full: boolean, | ||||
| ): AssignmentSubmissionsQueryKey { | ||||
|     return ["assignment-submissions", classid, assignmentNumber, full]; | ||||
| } | ||||
| function assignmentQuestionsQueryKey(classid: string, assignmentNumber: number, full: boolean) { | ||||
| 
 | ||||
| type AssignmentQuestionsQueryKey = ["assignment-questions", string, number, boolean]; | ||||
| 
 | ||||
| function assignmentQuestionsQueryKey( | ||||
|     classid: string, | ||||
|     assignmentNumber: number, | ||||
|     full: boolean, | ||||
| ): AssignmentQuestionsQueryKey { | ||||
|     return ["assignment-questions", classid, assignmentNumber, full]; | ||||
| } | ||||
| 
 | ||||
|  | @ -32,13 +51,15 @@ export async function invalidateAllAssignmentKeys( | |||
|     queryClient: QueryClient, | ||||
|     classid?: string, | ||||
|     assignmentNumber?: number, | ||||
| ) { | ||||
| ): Promise<void> { | ||||
|     const keys = ["assignment", "assignment-submissions", "assignment-questions"]; | ||||
| 
 | ||||
|     for (const key of keys) { | ||||
|     await Promise.all( | ||||
|         keys.map(async (key) => { | ||||
|             const queryKey = [key, classid, assignmentNumber].filter((arg) => arg !== undefined); | ||||
|         await queryClient.invalidateQueries({ queryKey: queryKey }); | ||||
|     } | ||||
|             return queryClient.invalidateQueries({ queryKey: queryKey }); | ||||
|         }), | ||||
|     ); | ||||
| 
 | ||||
|     await queryClient.invalidateQueries({ queryKey: ["assignments", classid].filter((arg) => arg !== undefined) }); | ||||
| } | ||||
|  | @ -50,12 +71,20 @@ function checkEnabled( | |||
| ): boolean { | ||||
|     return Boolean(classid) && !isNaN(Number(groupNumber)) && !isNaN(Number(assignmentNumber)); | ||||
| } | ||||
| 
 | ||||
| interface Values { | ||||
|     cid: string | undefined; | ||||
|     an: number | undefined; | ||||
|     gn: number | undefined; | ||||
|     f: boolean; | ||||
| } | ||||
| 
 | ||||
| function toValues( | ||||
|     classid: MaybeRefOrGetter<string | undefined>, | ||||
|     assignmentNumber: MaybeRefOrGetter<number | undefined>, | ||||
|     groupNumber: MaybeRefOrGetter<number | undefined>, | ||||
|     full: MaybeRefOrGetter<boolean>, | ||||
| ) { | ||||
| ): Values { | ||||
|     return { cid: toValue(classid), an: toValue(assignmentNumber), gn: toValue(groupNumber), f: toValue(full) }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -17,32 +17,51 @@ import { invalidateAllSubmissionKeys } from "./submissions"; | |||
| const classController = new ClassController(); | ||||
| 
 | ||||
| /* Query cache keys */ | ||||
| function classesQueryKey(full: boolean) { | ||||
| type ClassesQueryKey = ["classes", boolean]; | ||||
| 
 | ||||
| function classesQueryKey(full: boolean): ClassesQueryKey { | ||||
|     return ["classes", full]; | ||||
| } | ||||
| function classQueryKey(classid: string) { | ||||
| 
 | ||||
| type ClassQueryKey = ["class", string]; | ||||
| 
 | ||||
| function classQueryKey(classid: string): ClassQueryKey { | ||||
|     return ["class", classid]; | ||||
| } | ||||
| function classStudentsKey(classid: string, full: boolean) { | ||||
| 
 | ||||
| type ClassStudentsKey = ["class-students", string, boolean]; | ||||
| 
 | ||||
| function classStudentsKey(classid: string, full: boolean): ClassStudentsKey { | ||||
|     return ["class-students", classid, full]; | ||||
| } | ||||
| function classTeachersKey(classid: string, full: boolean) { | ||||
| 
 | ||||
| type ClassTeachersKey = ["class-teachers", string, boolean]; | ||||
| 
 | ||||
| function classTeachersKey(classid: string, full: boolean): ClassTeachersKey { | ||||
|     return ["class-teachers", classid, full]; | ||||
| } | ||||
| function classTeacherInvitationsKey(classid: string, full: boolean) { | ||||
| 
 | ||||
| type ClassTeacherInvitationsKey = ["class-teacher-invitations", string, boolean]; | ||||
| 
 | ||||
| function classTeacherInvitationsKey(classid: string, full: boolean): ClassTeacherInvitationsKey { | ||||
|     return ["class-teacher-invitations", classid, full]; | ||||
| } | ||||
| function classAssignmentsKey(classid: string, full: boolean) { | ||||
| 
 | ||||
| type ClassAssignmentsKey = ["class-assignments", string, boolean]; | ||||
| 
 | ||||
| function classAssignmentsKey(classid: string, full: boolean): ClassAssignmentsKey { | ||||
|     return ["class-assignments", classid, full]; | ||||
| } | ||||
| 
 | ||||
| export async function invalidateAllClassKeys(queryClient: QueryClient, classid?: string) { | ||||
| export async function invalidateAllClassKeys(queryClient: QueryClient, classid?: string): Promise<void> { | ||||
|     const keys = ["class", "class-students", "class-teachers", "class-teacher-invitations", "class-assignments"]; | ||||
| 
 | ||||
|     for (const key of keys) { | ||||
|     await Promise.all( | ||||
|         keys.map(async (key) => { | ||||
|             const queryKey = [key, classid].filter((arg) => arg !== undefined); | ||||
|         await queryClient.invalidateQueries({ queryKey: queryKey }); | ||||
|     } | ||||
|             return queryClient.invalidateQueries({ queryKey: queryKey }); | ||||
|         }), | ||||
|     ); | ||||
| 
 | ||||
|     await queryClient.invalidateQueries({ queryKey: ["classes"] }); | ||||
| } | ||||
|  |  | |||
|  | @ -5,24 +5,45 @@ import type { GroupDTO } from "@dwengo-1/common/interfaces/group"; | |||
| import { | ||||
|     QueryClient, | ||||
|     useMutation, | ||||
|     type UseMutationReturnType, | ||||
|     useQuery, | ||||
|     useQueryClient, | ||||
|     type UseMutationReturnType, | ||||
|     type UseQueryReturnType, | ||||
| } from "@tanstack/vue-query"; | ||||
| import { computed, toValue, type MaybeRefOrGetter } from "vue"; | ||||
| import { invalidateAllSubmissionKeys } from "./submissions"; | ||||
| 
 | ||||
| export function groupsQueryKey(classid: string, assignmentNumber: number, full: boolean) { | ||||
| type GroupsQueryKey = ["groups", string, number, boolean]; | ||||
| 
 | ||||
| export function groupsQueryKey(classid: string, assignmentNumber: number, full: boolean): GroupsQueryKey { | ||||
|     return ["groups", classid, assignmentNumber, full]; | ||||
| } | ||||
| function groupQueryKey(classid: string, assignmentNumber: number, groupNumber: number) { | ||||
| 
 | ||||
| type GroupQueryKey = ["group", string, number, number]; | ||||
| 
 | ||||
| function groupQueryKey(classid: string, assignmentNumber: number, groupNumber: number): GroupQueryKey { | ||||
|     return ["group", classid, assignmentNumber, groupNumber]; | ||||
| } | ||||
| function groupSubmissionsQueryKey(classid: string, assignmentNumber: number, groupNumber: number, full: boolean) { | ||||
| 
 | ||||
| type GroupSubmissionsQueryKey = ["group-submissions", string, number, number, boolean]; | ||||
| 
 | ||||
| function groupSubmissionsQueryKey( | ||||
|     classid: string, | ||||
|     assignmentNumber: number, | ||||
|     groupNumber: number, | ||||
|     full: boolean, | ||||
| ): GroupSubmissionsQueryKey { | ||||
|     return ["group-submissions", classid, assignmentNumber, groupNumber, full]; | ||||
| } | ||||
| function groupQuestionsQueryKey(classid: string, assignmentNumber: number, groupNumber: number, full: boolean) { | ||||
| 
 | ||||
| type GroupQuestionsQueryKey = ["group-questions", string, number, number, boolean]; | ||||
| 
 | ||||
| function groupQuestionsQueryKey( | ||||
|     classid: string, | ||||
|     assignmentNumber: number, | ||||
|     groupNumber: number, | ||||
|     full: boolean, | ||||
| ): GroupQuestionsQueryKey { | ||||
|     return ["group-questions", classid, assignmentNumber, groupNumber, full]; | ||||
| } | ||||
| 
 | ||||
|  | @ -31,13 +52,14 @@ export async function invalidateAllGroupKeys( | |||
|     classid?: string, | ||||
|     assignmentNumber?: number, | ||||
|     groupNumber?: number, | ||||
| ) { | ||||
| ): Promise<void> { | ||||
|     const keys = ["group", "group-submissions", "group-questions"]; | ||||
| 
 | ||||
|     for (const key of keys) { | ||||
|     await Promise.all( | ||||
|         keys.map(async (key) => { | ||||
|             const queryKey = [key, classid, assignmentNumber, groupNumber].filter((arg) => arg !== undefined); | ||||
|         await queryClient.invalidateQueries({ queryKey: queryKey }); | ||||
|     } | ||||
|             return queryClient.invalidateQueries({ queryKey: queryKey }); | ||||
|         }), | ||||
|     ); | ||||
| 
 | ||||
|     await queryClient.invalidateQueries({ | ||||
|         queryKey: ["groups", classid, assignmentNumber].filter((arg) => arg !== undefined), | ||||
|  | @ -51,12 +73,20 @@ function checkEnabled( | |||
| ): boolean { | ||||
|     return Boolean(classid) && !isNaN(Number(groupNumber)) && !isNaN(Number(assignmentNumber)); | ||||
| } | ||||
| 
 | ||||
| interface Values { | ||||
|     cid: string | undefined; | ||||
|     an: number | undefined; | ||||
|     gn: number | undefined; | ||||
|     f: boolean; | ||||
| } | ||||
| 
 | ||||
| function toValues( | ||||
|     classid: MaybeRefOrGetter<string | undefined>, | ||||
|     assignmentNumber: MaybeRefOrGetter<number | undefined>, | ||||
|     groupNumber: MaybeRefOrGetter<number | undefined>, | ||||
|     full: MaybeRefOrGetter<boolean>, | ||||
| ) { | ||||
| ): Values { | ||||
|     return { cid: toValue(classid), an: toValue(assignmentNumber), gn: toValue(groupNumber), f: toValue(full) }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -36,7 +36,7 @@ export async function invalidateAllSubmissionKeys( | |||
|     assignmentNumber?: number, | ||||
|     groupNumber?: number, | ||||
|     submissionNumber?: number, | ||||
| ) { | ||||
| ): Promise<void> { | ||||
|     const keys = ["submission"]; | ||||
| 
 | ||||
|     for (const key of keys) { | ||||
|  |  | |||
|  | @ -7,7 +7,6 @@ import CreateClass from "@/views/classes/CreateClass.vue"; | |||
| import CreateAssignment from "@/views/assignments/CreateAssignment.vue"; | ||||
| import CreateDiscussion from "@/views/discussions/CreateDiscussion.vue"; | ||||
| import CallbackPage from "@/views/CallbackPage.vue"; | ||||
| import UserDiscussions from "@/views/discussions/UserDiscussions.vue"; | ||||
| import UserClasses from "@/views/classes/UserClasses.vue"; | ||||
| import UserAssignments from "@/views/classes/UserAssignments.vue"; | ||||
| import authState from "@/services/auth/auth-service.ts"; | ||||
|  | @ -57,11 +56,12 @@ const router = createRouter({ | |||
|                     name: "UserClasses", | ||||
|                     component: UserClasses, | ||||
|                 }, | ||||
|                 { | ||||
|                     path: "discussion", | ||||
|                     name: "UserDiscussions", | ||||
|                     component: UserDiscussions, | ||||
|                 }, | ||||
|                 // TODO Re-enable this route when the discussion page is ready
 | ||||
|                 // {
 | ||||
|                 //     Path: "discussion",
 | ||||
|                 //     Name: "UserDiscussions",
 | ||||
|                 //     Component: UserDiscussions,
 | ||||
|                 // },
 | ||||
|             ], | ||||
|         }, | ||||
| 
 | ||||
|  |  | |||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger