From 65144b8cb3b2324b345be3281ed43761a3807fa0 Mon Sep 17 00:00:00 2001 From: laurejablonski Date: Sat, 5 Apr 2025 17:00:29 +0200 Subject: [PATCH 1/4] refactor: gebruik aparte vue files voor klassen van studenten en leerkrachten --- frontend/src/views/classes/StudentClasses.vue | 313 +++++++++++ frontend/src/views/classes/TeacherClasses.vue | 396 ++++++++++++++ frontend/src/views/classes/UserClasses.vue | 512 +----------------- 3 files changed, 715 insertions(+), 506 deletions(-) create mode 100644 frontend/src/views/classes/StudentClasses.vue create mode 100644 frontend/src/views/classes/TeacherClasses.vue diff --git a/frontend/src/views/classes/StudentClasses.vue b/frontend/src/views/classes/StudentClasses.vue new file mode 100644 index 00000000..018f1644 --- /dev/null +++ b/frontend/src/views/classes/StudentClasses.vue @@ -0,0 +1,313 @@ + + + diff --git a/frontend/src/views/classes/TeacherClasses.vue b/frontend/src/views/classes/TeacherClasses.vue new file mode 100644 index 00000000..d27bf40a --- /dev/null +++ b/frontend/src/views/classes/TeacherClasses.vue @@ -0,0 +1,396 @@ + + + diff --git a/frontend/src/views/classes/UserClasses.vue b/frontend/src/views/classes/UserClasses.vue index 2a4403c1..2e2f8a46 100644 --- a/frontend/src/views/classes/UserClasses.vue +++ b/frontend/src/views/classes/UserClasses.vue @@ -1,517 +1,17 @@ + - + From b25901cbb71e335c9555b9e5cbd56b8f6a093d9c Mon Sep 17 00:00:00 2001 From: laurejablonski Date: Sat, 5 Apr 2025 17:06:15 +0200 Subject: [PATCH 2/4] style: lint --- frontend/src/views/classes/StudentClasses.vue | 40 ++++++++-------- frontend/src/views/classes/TeacherClasses.vue | 46 +++++++++---------- frontend/src/views/classes/UserClasses.vue | 2 +- 3 files changed, 41 insertions(+), 47 deletions(-) diff --git a/frontend/src/views/classes/StudentClasses.vue b/frontend/src/views/classes/StudentClasses.vue index 018f1644..688c9132 100644 --- a/frontend/src/views/classes/StudentClasses.vue +++ b/frontend/src/views/classes/StudentClasses.vue @@ -3,7 +3,6 @@ import authState from "@/services/auth/auth-service.ts"; import { computed, onMounted, ref, type ComputedRef } from "vue"; import { validate, version } from "uuid"; - import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; import { useCreateJoinRequestMutation, useStudentClassesQuery } from "@/queries/students"; import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; @@ -12,56 +11,56 @@ const { t } = useI18n(); const studentController: StudentController = new StudentController(); - // username of logged in student + // Username of logged in student const username = ref(undefined); - // find the username of the logged in user so it can be used to fetch other information - // when loading the page + // Find the username of the logged in user so it can be used to fetch other information + // When loading the page onMounted(async () => { const userObject = await authState.loadUser(); username.value = userObject?.profile?.preferred_username ?? undefined; }); - // fetch all classes of the logged in student + // Fetch all classes of the logged in student const { data: classesResponse, isLoading, error } = useStudentClassesQuery(username); - // empty list when classes are not yet loaded, else the list of classes of the user + // Empty list when classes are not yet loaded, else the list of classes of the user const classes: ComputedRef = computed(() => { - // the classes are not yet fetched + // The classes are not yet fetched if (!classesResponse.value) { return []; } - // the user has no classes + // The user has no classes if (classesResponse.value.classes.length === 0) { return []; } if (typeof classesResponse.value.classes[0] === "string") { - // should not occur because value of *full* is true - // must be caught because typescript can't know the type - // i chose to return an empty list if this occurs - // it is also possible to fetch all classes from the id's returned + // Should not occur because value of *full* is true + // Must be caught because typescript can't know the type + // I chose to return an empty list if this occurs + // It is also possible to fetch all classes from the id's returned return []; } return classesResponse.value.classes as ClassDTO[]; }); - // students of selected class are shown when logged in student presses on the member count + // Students of selected class are shown when logged in student presses on the member count const selectedClass = ref(null); const students = ref([]); // Boolean that handles visibility for dialogs - // clicking on membercount will show a dialog with all members + // Clicking on membercount will show a dialog with all members const dialog = ref(false); // Function to display all members of a class in a dialog - async function openDialog(c: ClassDTO) { + async function openDialog(c: ClassDTO) : Promise { selectedClass.value = c; // Clear previous value students.value = []; dialog.value = true; - // fetch students from their usernames to display their full names + // Fetch students from their usernames to display their full names const studentDTOs: (StudentDTO | null)[] = await Promise.all( c.students.map(async (uid) => { try { @@ -73,11 +72,11 @@ }), ); - // only show students that are not fetched ass *null* + // Only show students that are not fetched ass *null* students.value = studentDTOs.filter(Boolean) as StudentDTO[]; } - // hold the code a student gives in to join a class + // Hold the code a student gives in to join a class const code = ref(""); // The code a student sends in to join a class needs to be formatted as v4 to be valid @@ -89,15 +88,14 @@ }, ]; - // used to send the actual class join request + // Used to send the actual class join request const { mutate, isError } = useCreateJoinRequestMutation(); // Function called when a student submits a code to join a class function submitCode() { // Check if the code is valid if (code.value !== undefined && validate(code.value) && version(code.value) === 4) { - // TODO: uncomment when fixed - // mutate( { username : username.value! , classId : code.value }); + mutate( { username : username.value! , classId : code.value }); console.log("Code submitted:", code.value); } diff --git a/frontend/src/views/classes/TeacherClasses.vue b/frontend/src/views/classes/TeacherClasses.vue index d27bf40a..86df1634 100644 --- a/frontend/src/views/classes/TeacherClasses.vue +++ b/frontend/src/views/classes/TeacherClasses.vue @@ -2,12 +2,8 @@ import { useI18n } from "vue-i18n"; import authState from "@/services/auth/auth-service.ts"; import { computed, onMounted, ref, type ComputedRef } from "vue"; - import { validate, version } from "uuid"; import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; - import { useCreateJoinRequestMutation, useStudentClassesQuery } from "@/queries/students"; - import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; - import { StudentController } from "@/controllers/students"; const { t } = useI18n(); @@ -19,11 +15,11 @@ receiver: TeacherDTO; } - // username of logged in teacher + // Username of logged in teacher const username = ref(undefined); - // find the username of the logged in user so it can be used to fetch other information - // when loading the page + // Find the username of the logged in user so it can be used to fetch other information + // When loading the page onMounted(async () => { const userObject = await authState.loadUser(); username.value = userObject?.profile?.preferred_username ?? undefined; @@ -32,40 +28,40 @@ // TODO: fetch all classes of the logged in teacher const isLoading = ref(false); const error = ref(null); - // const { data: classesResponse, isLoading, error } = useStudentClassesQuery(username); + // Const { data: classesResponse, isLoading, error } = useStudentClassesQuery(username); - // empty list when classes are not yet loaded, else the list of classes of the user - const classes: ComputedRef = computed(() => { - return []; + // Empty list when classes are not yet loaded, else the list of classes of the user + const classes: ComputedRef = computed(() => + [] // TODO // // the classes are not yet fetched - // if (!classesResponse.value) { - // return []; + // If (!classesResponse.value) { + // Return []; // } // // the user has no classes - // if (classesResponse.value.classes.length === 0) { - // return []; + // If (classesResponse.value.classes.length === 0) { + // Return []; // } - // if (typeof classesResponse.value.classes[0] === "string") { + // If (typeof classesResponse.value.classes[0] === "string") { // // should not occur because value of *full* is true // // must be caught because typescript can't know the type // // i chose to return an empty list if this occurs // // it is also possible to fetch all classes from the id's returned - // return []; + // Return []; // } - // return classesResponse.value.classes as ClassDTO[]; - }); + // Return classesResponse.value.classes as ClassDTO[]; + ); // Boolean that handles visibility for dialogs - // creating a class will generate a popup with the generated code + // Creating a class will generate a popup with the generated code const dialog = ref(false); - // duntion to display the dialog showing generated code for created class - function openDialog() { + // Duntion to display the dialog showing generated code for created class + function openDialog() : void { //TODO } - // code generated when new class was created + // Code generated when new class was created const code = ref(""); // TODO: implement correctly @@ -83,7 +79,7 @@ console.log("request denied"); } - // teacher should be able to set a displayname when making a class + // Teacher should be able to set a displayname when making a class const className = ref(""); // The name can only contain dash, underscore letters and numbers @@ -112,7 +108,7 @@ } } - // show the teacher, copying of the code was a successs + // Show the teacher, copying of the code was a successs const copied = ref(false); // Copy the generated code to the clipboard diff --git a/frontend/src/views/classes/UserClasses.vue b/frontend/src/views/classes/UserClasses.vue index 2e2f8a46..566bd02a 100644 --- a/frontend/src/views/classes/UserClasses.vue +++ b/frontend/src/views/classes/UserClasses.vue @@ -3,7 +3,7 @@ import TeacherClasses from "./TeacherClasses.vue"; import StudentClasses from "./StudentClasses.vue"; - // determine if role is student or teacher to render correct view + // Determine if role is student or teacher to render correct view const role: string = authState.authState.activeRole!; From 6244093584479ebaa79591433dc911260c0be203 Mon Sep 17 00:00:00 2001 From: laurejablonski Date: Sat, 5 Apr 2025 17:25:03 +0200 Subject: [PATCH 3/4] fix: juiste input wordt doorgegeven --- frontend/src/controllers/students.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/controllers/students.ts b/frontend/src/controllers/students.ts index f74f02da..82fb2831 100644 --- a/frontend/src/controllers/students.ts +++ b/frontend/src/controllers/students.ts @@ -70,7 +70,7 @@ export class StudentController extends BaseController { } async createJoinRequest(username: string, classId: string): Promise { - return this.post(`/${username}/joinRequests}`, classId); + return this.post(`/${username}/joinRequests}`, { classId }); } async deleteJoinRequest(username: string, classId: string): Promise { From 7e6b225a9f90d1b04944256003f4f09e9540b4e3 Mon Sep 17 00:00:00 2001 From: laurejablonski Date: Sat, 5 Apr 2025 17:25:15 +0200 Subject: [PATCH 4/4] fix: juiste import --- frontend/src/queries/students.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/queries/students.ts b/frontend/src/queries/students.ts index 822083d9..d5edad7a 100644 --- a/frontend/src/queries/students.ts +++ b/frontend/src/queries/students.ts @@ -19,7 +19,7 @@ import type { AssignmentsResponse } from "@/controllers/assignments.ts"; import type { GroupsResponse } from "@/controllers/groups.ts"; import type { SubmissionsResponse } from "@/controllers/submissions.ts"; import type { QuestionsResponse } from "@/controllers/questions.ts"; -import type { StudentDTO } from "@dwengo-1/interfaces/student"; +import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; const studentController = new StudentController();