From c7bdde9c8b12cae17174b5ac5e20f16436196bc8 Mon Sep 17 00:00:00 2001 From: tyboro2002 Date: Mon, 25 Mar 2024 23:04:57 +0100 Subject: [PATCH] chore: did some cleanup --- frontend/src/composables/services/assistant.service.ts | 4 ++-- frontend/src/composables/services/courses.service.ts | 4 ++-- frontend/src/composables/services/helpers.ts | 1 + frontend/src/composables/services/students.service.ts | 6 ++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/composables/services/assistant.service.ts b/frontend/src/composables/services/assistant.service.ts index 7779bbc3..c2c46a48 100644 --- a/frontend/src/composables/services/assistant.service.ts +++ b/frontend/src/composables/services/assistant.service.ts @@ -26,9 +26,9 @@ export function useAssistant() { getList(endpoint, assistants, Assistant.fromJSON, toast); } - async function assistantJoinCourse(course_id: string, teacher_id: string) { + async function assistantJoinCourse(course_id: string, assistant_id: string) { const endpoint = endpoints.assistants.byCourse.replace('{course_id}', course_id); - create(endpoint, {teacher_id: teacher_id}, response, Response.fromJSON, toast); + create(endpoint, {assistant_id: assistant_id}, response, Response.fromJSON, toast); } async function createAssistant(assistant_data: any) { diff --git a/frontend/src/composables/services/courses.service.ts b/frontend/src/composables/services/courses.service.ts index ef363cd5..2cc8bfaf 100644 --- a/frontend/src/composables/services/courses.service.ts +++ b/frontend/src/composables/services/courses.service.ts @@ -24,9 +24,9 @@ export function useCourses() { create(endpoint, course_data, course, Course.fromJSON, toast); } - async function cloneCourse(data: any, course_id: string) { + async function cloneCourse(course_id: string, clone_assistants: boolean) { const endpoint = endpoints.courses.clone.replace('{course_id}', course_id); - create(endpoint, data, course, Course.fromJSON, toast); + create(endpoint, {clone_assistants: clone_assistants.toString() }, course, Course.fromJSON, toast); } async function deleteCourse(id: string) { diff --git a/frontend/src/composables/services/helpers.ts b/frontend/src/composables/services/helpers.ts index ac96dbea..8d6e8a5c 100644 --- a/frontend/src/composables/services/helpers.ts +++ b/frontend/src/composables/services/helpers.ts @@ -40,6 +40,7 @@ export async function delete_id(endpoint: string, ref: Ref, fromJson: }); } + export async function getList(endpoint: string, ref: Ref, fromJson: (data: any) => T, toast:any): Promise { await axios.get(endpoint).then(response => { ref.value = response.data.map((data: T) => fromJson(data)); diff --git a/frontend/src/composables/services/students.service.ts b/frontend/src/composables/services/students.service.ts index 6204bc06..7dc60f8e 100644 --- a/frontend/src/composables/services/students.service.ts +++ b/frontend/src/composables/services/students.service.ts @@ -36,6 +36,11 @@ export function useStudents() { create(endpoint, {student_id: student_id}, response, Response.fromJSON, toast); } + async function studentLeaveCourse(course_id: string, student_id: string) { + const endpoint = endpoints.students.byCourse.replace('{course_id}', course_id); + delete_id(endpoint, {student_id: student_id}, response, Response.fromJSON, toast); + } + async function studentJoinGroup(group_id: string, student_id: string) { const endpoint = endpoints.students.byGroup.replace('{group_id}', group_id); create(endpoint, {student_id: student_id}, response, Response.fromJSON, toast); @@ -66,6 +71,7 @@ export function useStudents() { deleteStudent, studentJoinCourse, + studentLeaveCourse, studentJoinGroup }; } \ No newline at end of file