-
-
{{ t('views.projects.groupMembers') }}
-
-
- {{ student.first_name }} {{ student.last_name }}
-
-
+
+
+
{{ t('views.projects.groupMembers') }}
+
+
+ {{ student.first_name }} {{ student.last_name }}
+
+
+
-
\ No newline at end of file
+}
+
diff --git a/frontend/src/components/projects/ProjectCard.vue b/frontend/src/components/projects/ProjectCard.vue
index bb4a8fe2..27396010 100644
--- a/frontend/src/components/projects/ProjectCard.vue
+++ b/frontend/src/components/projects/ProjectCard.vue
@@ -1,10 +1,10 @@
-
-
- {{ project.name }} - {{project.course.name}}
-
-
-
-
- {{t('views.projects.deadline')}}: {{ formattedDeadline }}
-
-
-
- {{t('views.projects.submissionStatus')}}: {{ project.submissions.structure_checks_passed }}
-
-
-
-
-
-
-
-
+
+
+
+ {{ project.name }} - {{ project.course.name }}
+
+
+
+
+
+ {{ t('views.projects.deadline') }}: {{ formattedDeadline
+ }}
+
+
+
+ {{ t('views.projects.submissionStatus') }}:
+ {{ project.submissions.structureChecks_passed }}
+
+
+
+
+
+
+
+
\ No newline at end of file
+
diff --git a/frontend/src/composables/axios.ts b/frontend/src/composables/axios.ts
index 4a704eaf..0888e22c 100644
--- a/frontend/src/composables/axios.ts
+++ b/frontend/src/composables/axios.ts
@@ -1,20 +1,20 @@
-import axios from 'axios';
-import Cookie from 'js-cookie';
-import { i18n } from '@/composables/i18n';
-
-const { locale } = i18n.global;
-
-axios.defaults.xsrfHeaderName = "X-CSRFToken";
-axios.defaults.xsrfCookieName = "csrftoken";
-
-export const client = axios.create({
- headers: {
- 'Content-Type': 'application/json',
- 'Accept': 'application/json',
- 'X-CSRFToken': Cookie.get('csrftoken'),
- 'Accept-Language': locale.value
- },
- withCredentials: true,
- xsrfHeaderName: "X-CSRFToken",
- xsrfCookieName: "csrftoken"
-});
\ No newline at end of file
+import axios from 'axios'
+import Cookie from 'js-cookie'
+import { i18n } from '@/composables/i18n'
+
+const { locale } = i18n.global
+
+axios.defaults.xsrfHeaderName = 'X-CSRFToken'
+axios.defaults.xsrfCookieName = 'csrftoken'
+
+export const client = axios.create({
+ headers: {
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ 'X-CSRFToken': Cookie.get('csrftoken'),
+ 'Accept-Language': locale.value
+ },
+ withCredentials: true,
+ xsrfHeaderName: 'X-CSRFToken',
+ xsrfCookieName: 'csrftoken'
+})
diff --git a/frontend/src/composables/configuration.ts b/frontend/src/composables/configuration.ts
index 2e1f51a0..941ad6bc 100644
--- a/frontend/src/composables/configuration.ts
+++ b/frontend/src/composables/configuration.ts
@@ -1,11 +1,17 @@
-import {ref} from 'vue';
-import {endpoints} from '../config/endpoints.ts';
-import {environment} from '../config/environment.ts';
-
-export function useConfig() {
- const config = ref({
- environment, endpoints
- });
-
- return { config };
-}
\ No newline at end of file
+import { type Ref, ref } from 'vue'
+import { endpoints } from '../config/endpoints.ts'
+import { environment } from '../config/environment.ts'
+
+interface Config {
+ environment: any
+ endpoints: any
+}
+
+export function useConfig(): { config: Ref
} {
+ const config = ref({
+ environment,
+ endpoints
+ })
+
+ return { config }
+}
diff --git a/frontend/src/composables/i18n.ts b/frontend/src/composables/i18n.ts
index 27af1600..b852f6ec 100644
--- a/frontend/src/composables/i18n.ts
+++ b/frontend/src/composables/i18n.ts
@@ -1,14 +1,14 @@
-import 'moment/dist/locale/nl';
-import en from '@/assets/lang/en.json';
-import nl from '@/assets/lang/nl.json';
-import {createI18n} from 'vue-i18n';
-import {useLocalStorage} from '@vueuse/core';
-
-const localeStorage = useLocalStorage('locale', 'nl');
-
-export const i18n = createI18n({
- locale: localeStorage.value,
- fallbackLocale: 'en',
- legacy: false,
- messages: { en, nl }
-});
\ No newline at end of file
+import 'moment/dist/locale/nl'
+import en from '@/assets/lang/en.json'
+import nl from '@/assets/lang/nl.json'
+import { createI18n } from 'vue-i18n'
+import { useLocalStorage } from '@vueuse/core'
+
+const localeStorage = useLocalStorage('locale', 'nl')
+
+export const i18n = createI18n({
+ locale: localeStorage.value,
+ fallbackLocale: 'en',
+ legacy: false,
+ messages: { en, nl }
+})
diff --git a/frontend/src/composables/services/admins.service.ts b/frontend/src/composables/services/admins.service.ts
index 36226d25..d7097a93 100644
--- a/frontend/src/composables/services/admins.service.ts
+++ b/frontend/src/composables/services/admins.service.ts
@@ -1,36 +1,53 @@
-import {ref} from 'vue';
-import {endpoints} from '@/config/endpoints.ts';
-import { get, getList, create, delete_id } from '@/composables/services/helpers.ts';
-import {User} from '@/types/User.ts';
-
-export function useAdmin() {
- const admins = ref(null);
- const admin = ref(null);
-
- async function getAdminByID(id: string) {
- const endpoint = endpoints.admins.retrieve.replace('{id}', id);
- await get(endpoint, admin, User.fromJSON);
+import { type Ref, ref } from 'vue'
+import { endpoints } from '@/config/endpoints.ts'
+import {
+ get,
+ getList,
+ create,
+ deleteId
+} from '@/composables/services/helpers.ts'
+import { User } from '@/types/User.ts'
+
+interface AdminState {
+ admins: Ref
+ admin: Ref
+ getAdminByID: (id: string) => Promise
+ getAdmins: () => Promise
+ createAdmin: (adminData: User) => Promise
+ deleteAdmin: (id: string) => Promise
+}
+
+export function useAdmin(): AdminState {
+ const admins = ref(null)
+ const admin = ref(null)
+
+ async function getAdminByID(id: string): Promise {
+ const endpoint = endpoints.admins.retrieve.replace('{id}', id)
+ await get(endpoint, admin, User.fromJSON)
}
- async function getAdmins() {
- const endpoint = endpoints.admins.index;
- await getList(endpoint, admins, User.fromJSON);
+ async function getAdmins(): Promise {
+ const endpoint = endpoints.admins.index
+ await getList(endpoint, admins, User.fromJSON)
}
- async function createAdmin(admin_data: User) {
- const endpoint = endpoints.admins.index;
- await create(endpoint,
+ async function createAdmin(adminData: User): Promise {
+ const endpoint = endpoints.admins.index
+ await create(
+ endpoint,
{
- email:admin_data.email,
- first_name:admin_data.first_name,
- last_name: admin_data.last_name
+ email: adminData.email,
+ first_name: adminData.first_name,
+ last_name: adminData.last_name
},
- admin, User.fromJSON);
+ admin,
+ User.fromJSON
+ )
}
- async function deleteAdmin(id: string) {
- const endpoint = endpoints.admins.retrieve.replace('{id}', id);
- await delete_id(endpoint, admin, User.fromJSON);
+ async function deleteAdmin(id: string): Promise {
+ const endpoint = endpoints.admins.retrieve.replace('{id}', id)
+ await deleteId(endpoint, admin, User.fromJSON)
}
return {
@@ -41,5 +58,5 @@ export function useAdmin() {
createAdmin,
deleteAdmin
- };
-}
\ No newline at end of file
+ }
+}
diff --git a/frontend/src/composables/services/assistant.service.ts b/frontend/src/composables/services/assistant.service.ts
index f92e626d..02a8b1d3 100644
--- a/frontend/src/composables/services/assistant.service.ts
+++ b/frontend/src/composables/services/assistant.service.ts
@@ -1,53 +1,106 @@
-import {Assistant} from '@/types/Assistant.ts';
-import { Response } from '@/types/Response';
-import {ref} from 'vue';
-import {endpoints} from '@/config/endpoints.ts';
-import { get, getList, create, delete_id, delete_id_with_data } from '@/composables/services/helpers.ts';
+import { Assistant } from '@/types/Assistant.ts'
+import { Response } from '@/types/Response'
+import { type Ref, ref } from 'vue'
+import { endpoints } from '@/config/endpoints.ts'
+import {
+ get,
+ getList,
+ create,
+ deleteId,
+ deleteIdWithData
+} from '@/composables/services/helpers.ts'
-export function useAssistant() {
- const assistants = ref(null);
- const assistant = ref(null);
- const response = ref(null);
+interface AssistantState {
+ assistants: Ref
+ assistant: Ref
+ response: Ref
+ getAssistantByID: (id: string) => Promise
+ getAssistantByCourse: (courseId: string) => Promise
+ getAssistants: () => Promise
+ assistantJoinCourse: (
+ courseId: string,
+ assistantId: string
+ ) => Promise
+ assistantLeaveCourse: (
+ courseId: string,
+ assistantId: string
+ ) => Promise
+ createAssistant: (assistantData: Assistant) => Promise
+ deleteAssistant: (id: string) => Promise
+}
- async function getAssistantByID(id: string) {
- const endpoint = endpoints.assistants.retrieve.replace('{id}', id);
- await get(endpoint, assistant, Assistant.fromJSON);
+export function useAssistant(): AssistantState {
+ const assistants = ref(null)
+ const assistant = ref(null)
+ const response = ref(null)
+
+ async function getAssistantByID(id: string): Promise {
+ const endpoint = endpoints.assistants.retrieve.replace('{id}', id)
+ await get(endpoint, assistant, Assistant.fromJSON)
}
- async function getAssistantByCourse(course_id: string) {
- const endpoint = endpoints.assistants.byCourse.replace('{course_id}', course_id);
- await get(endpoint, assistant, Assistant.fromJSON);
+ async function getAssistantByCourse(courseId: string): Promise {
+ const endpoint = endpoints.assistants.byCourse.replace(
+ '{courseId}',
+ courseId
+ )
+ await get(endpoint, assistant, Assistant.fromJSON)
}
- async function getAssistants() {
- const endpoint = endpoints.assistants.index;
- await getList(endpoint, assistants, Assistant.fromJSON);
+ async function getAssistants(): Promise {
+ const endpoint = endpoints.assistants.index
+ await getList(endpoint, assistants, Assistant.fromJSON)
}
- async function assistantJoinCourse(course_id: string, assistant_id: string) {
- const endpoint = endpoints.assistants.byCourse.replace('{course_id}', course_id);
- await create(endpoint, {assistant_id: assistant_id}, response, Response.fromJSON);
+ async function assistantJoinCourse(
+ courseId: string,
+ assistantId: string
+ ): Promise {
+ const endpoint = endpoints.assistants.byCourse.replace(
+ '{courseId}',
+ courseId
+ )
+ await create(
+ endpoint,
+ { assistantId },
+ response,
+ Response.fromJSON
+ )
}
- async function assistantLeaveCourse(course_id: string, assistant_id: string) {
- const endpoint = endpoints.assistants.byCourse.replace('{course_id}', course_id);
- await delete_id_with_data(endpoint, {assistant_id: assistant_id}, response, Response.fromJSON);
+ async function assistantLeaveCourse(
+ courseId: string,
+ assistantId: string
+ ): Promise {
+ const endpoint = endpoints.assistants.byCourse.replace(
+ '{courseId}',
+ courseId
+ )
+ await deleteIdWithData(
+ endpoint,
+ { assistantId },
+ response,
+ Response.fromJSON
+ )
}
- async function createAssistant(assistant_data: Assistant) {
- const endpoint = endpoints.assistants.index;
- await create(endpoint,
+ async function createAssistant(assistantData: Assistant): Promise {
+ const endpoint = endpoints.assistants.index
+ await create(
+ endpoint,
{
- email:assistant_data.email,
- first_name:assistant_data.first_name,
- last_name: assistant_data.last_name
+ email: assistantData.email,
+ first_name: assistantData.first_name,
+ last_name: assistantData.last_name
},
- assistant, Assistant.fromJSON);
+ assistant,
+ Assistant.fromJSON
+ )
}
- async function deleteAssistant(id: string) {
- const endpoint = endpoints.admins.retrieve.replace('{id}', id);
- await delete_id(endpoint, assistant, Assistant.fromJSON);
+ async function deleteAssistant(id: string): Promise {
+ const endpoint = endpoints.admins.retrieve.replace('{id}', id)
+ await deleteId(endpoint, assistant, Assistant.fromJSON)
}
return {
@@ -64,5 +117,5 @@ export function useAssistant() {
assistantJoinCourse,
assistantLeaveCourse
- };
-}
\ No newline at end of file
+ }
+}
diff --git a/frontend/src/composables/services/courses.service.ts b/frontend/src/composables/services/courses.service.ts
index 157fea9b..162dcb6d 100644
--- a/frontend/src/composables/services/courses.service.ts
+++ b/frontend/src/composables/services/courses.service.ts
@@ -1,70 +1,108 @@
-import {Course} from '@/types/Course.ts';
-import {ref} from 'vue';
-import {endpoints} from '@/config/endpoints.ts';
-import { get, getList, create, delete_id } from '@/composables/services/helpers.ts';
-
-export function useCourses() {
- const courses = ref(null);
- const course = ref(null);
-
- async function getCourseByID(id: string) {
- const endpoint = endpoints.courses.retrieve.replace('{id}', id);
- await get(endpoint, course, Course.fromJSON);
- }
-
- async function getCourses() {
- const endpoint = endpoints.courses.index;
- await getList(endpoint, courses, Course.fromJSON);
- }
-
- async function getCoursesByStudent(student_id: string) {
- const endpoint = endpoints.courses.byStudent.replace('{student_id}', student_id);
- await getList(endpoint, courses, Course.fromJSON);
- }
-
- async function getCoursesByTeacher(teacher_id: string) {
- const endpoint = endpoints.courses.byTeacher.replace('{teacher_id}', teacher_id);
- await getList(endpoint, courses, Course.fromJSON);
- }
-
- async function getCourseByAssistant(assistant_id: string) {
- const endpoint = endpoints.courses.byAssistant.replace('{assistant_id}', assistant_id);
- await getList(endpoint, courses, Course.fromJSON);
- }
-
- async function createCourse(course_data: Course) {
- const endpoint = endpoints.courses.index;
- await create(endpoint,
- {
- name: course_data.name,
- description: course_data.description,
- academic_startyear: course_data.academic_startyear
- },
- course, Course.fromJSON);
- }
-
- async function cloneCourse(course_id: string, clone_assistants: boolean) {
- const endpoint = endpoints.courses.clone.replace('{course_id}', course_id);
- await create(endpoint, {clone_assistants: clone_assistants.toString() }, course, Course.fromJSON);
- }
-
- async function deleteCourse(id: string) {
- const endpoint = endpoints.courses.retrieve.replace('{id}', id);
- await delete_id(endpoint, course, Course.fromJSON);
- }
-
- return {
- courses,
- course,
-
- getCourseByID,
- getCourses,
- getCoursesByStudent,
- getCoursesByTeacher,
- getCourseByAssistant,
-
- createCourse,
- cloneCourse,
- deleteCourse
- };
-}
\ No newline at end of file
+import { Course } from '@/types/Course.ts'
+import { type Ref, ref } from 'vue'
+import { endpoints } from '@/config/endpoints.ts'
+import {
+ get,
+ getList,
+ create,
+ deleteId
+} from '@/composables/services/helpers.ts'
+
+interface CoursesState {
+ courses: Ref
+ course: Ref
+ getCourseByID: (id: string) => Promise
+ getCourses: () => Promise
+ getCoursesByStudent: (studentId: string) => Promise
+ getCoursesByTeacher: (teacherId: string) => Promise
+ getCourseByAssistant: (assistantId: string) => Promise
+ createCourse: (courseData: Course) => Promise
+ cloneCourse: (courseId: string, cloneAssistants: boolean) => Promise
+ deleteCourse: (id: string) => Promise
+}
+
+export function useCourses(): CoursesState {
+ const courses = ref(null)
+ const course = ref(null)
+
+ async function getCourseByID(id: string): Promise {
+ const endpoint = endpoints.courses.retrieve.replace('{id}', id)
+ await get(endpoint, course, Course.fromJSON)
+ }
+
+ async function getCourses(): Promise {
+ const endpoint = endpoints.courses.index
+ await getList(endpoint, courses, Course.fromJSON)
+ }
+
+ async function getCoursesByStudent(studentId: string): Promise {
+ const endpoint = endpoints.courses.byStudent.replace(
+ '{studentId}',
+ studentId
+ )
+ await getList(endpoint, courses, Course.fromJSON)
+ }
+
+ async function getCoursesByTeacher(teacherId: string): Promise {
+ const endpoint = endpoints.courses.byTeacher.replace(
+ '{teacherId}',
+ teacherId
+ )
+ await getList(endpoint, courses, Course.fromJSON)
+ }
+
+ async function getCourseByAssistant(assistantId: string): Promise {
+ const endpoint = endpoints.courses.byAssistant.replace(
+ '{assistantId}',
+ assistantId
+ )
+ await getList(endpoint, courses, Course.fromJSON)
+ }
+
+ async function createCourse(courseData: Course): Promise {
+ const endpoint = endpoints.courses.index
+ await create(
+ endpoint,
+ {
+ name: courseData.name,
+ description: courseData.description,
+ academic_startyear: courseData.academic_startyear
+ },
+ course,
+ Course.fromJSON
+ )
+ }
+
+ async function cloneCourse(
+ courseId: string,
+ cloneAssistants: boolean
+ ): Promise {
+ const endpoint = endpoints.courses.clone.replace('{courseId}', courseId)
+ await create(
+ endpoint,
+ { cloneAssistants: cloneAssistants.toString() },
+ course,
+ Course.fromJSON
+ )
+ }
+
+ async function deleteCourse(id: string): Promise {
+ const endpoint = endpoints.courses.retrieve.replace('{id}', id)
+ await deleteId(endpoint, course, Course.fromJSON)
+ }
+
+ return {
+ courses,
+ course,
+
+ getCourseByID,
+ getCourses,
+ getCoursesByStudent,
+ getCoursesByTeacher,
+ getCourseByAssistant,
+
+ createCourse,
+ cloneCourse,
+ deleteCourse
+ }
+}
diff --git a/frontend/src/composables/services/faculties.service.ts b/frontend/src/composables/services/faculties.service.ts
index 50eb432e..c8a7caff 100644
--- a/frontend/src/composables/services/faculties.service.ts
+++ b/frontend/src/composables/services/faculties.service.ts
@@ -1,30 +1,49 @@
-import {Faculty} from '@/types/Faculty.ts';
-import {ref} from 'vue';
-import {endpoints} from '@/config/endpoints.ts';
-import { get, getList, create, delete_id } from '@/composables/services/helpers.ts';
-
-export function useFaculty() {
- const faculties = ref(null);
- const faculty = ref(null);
-
- async function getFacultyByID(name: string) {
- const endpoint = endpoints.faculties.retrieve.replace('{name}', name);
- await get(endpoint, faculty, Faculty.fromJSON);
+import { Faculty } from '@/types/Faculty.ts'
+import { type Ref, ref } from 'vue'
+import { endpoints } from '@/config/endpoints.ts'
+import {
+ get,
+ getList,
+ create,
+ deleteId
+} from '@/composables/services/helpers.ts'
+
+interface FacultyState {
+ faculties: Ref
+ faculty: Ref
+ getFacultyByID: (name: string) => Promise
+ getFacultys: () => Promise
+ createFaculty: (facultyData: Faculty) => Promise
+ deleteFaculty: (id: string) => Promise
+}
+
+export function useFaculty(): FacultyState {
+ const faculties = ref(null)
+ const faculty = ref(null)
+
+ async function getFacultyByID(name: string): Promise {
+ const endpoint = endpoints.faculties.retrieve.replace('{name}', name)
+ await get(endpoint, faculty, Faculty.fromJSON)
}
- async function getFacultys() {
- const endpoint = endpoints.faculties.index;
- await getList(endpoint, faculties, Faculty.fromJSON);
+ async function getFacultys(): Promise {
+ const endpoint = endpoints.faculties.index
+ await getList(endpoint, faculties, Faculty.fromJSON)
}
- async function createFaculty(faculty_data: Faculty) {
- const endpoint = endpoints.faculties.index;
- await create(endpoint, {name: faculty_data.name}, faculty, Faculty.fromJSON);
+ async function createFaculty(facultyData: Faculty): Promise {
+ const endpoint = endpoints.faculties.index
+ await create(
+ endpoint,
+ { name: facultyData.name },
+ faculty,
+ Faculty.fromJSON
+ )
}
- async function deleteFaculty(id: string) {
- const endpoint = endpoints.faculties.retrieve.replace('{id}', id);
- await delete_id(endpoint, faculty, Faculty.fromJSON);
+ async function deleteFaculty(id: string): Promise {
+ const endpoint = endpoints.faculties.retrieve.replace('{id}', id)
+ await deleteId(endpoint, faculty, Faculty.fromJSON)
}
return {
@@ -35,5 +54,5 @@ export function useFaculty() {
createFaculty,
deleteFaculty
- };
-}
\ No newline at end of file
+ }
+}
diff --git a/frontend/src/composables/services/groups.service.ts b/frontend/src/composables/services/groups.service.ts
index 1d0e7153..661d1b6c 100644
--- a/frontend/src/composables/services/groups.service.ts
+++ b/frontend/src/composables/services/groups.service.ts
@@ -1,39 +1,69 @@
-import {Group} from '@/types/Group.ts';
-import {ref} from 'vue';
-import {endpoints} from '@/config/endpoints.ts';
-import { get, getList, create, delete_id } from '@/composables/services/helpers.ts';
-
-export function useGroup() {
- const groups = ref(null);
- const group = ref(null);
-
- async function getGroupByID(id: string) {
- const endpoint = endpoints.groups.retrieve.replace('{id}', id);
- await get(endpoint, group, Group.fromJSON);
+import { Group } from '@/types/Group.ts'
+import { type Ref, ref } from 'vue'
+import { endpoints } from '@/config/endpoints.ts'
+import {
+ get,
+ getList,
+ create,
+ deleteId
+} from '@/composables/services/helpers.ts'
+
+interface GroupState {
+ groups: Ref
+ group: Ref
+ getGroupByID: (id: string) => Promise
+ getGroupsByProject: (projectId: string) => Promise
+ getGroupsByStudent: (studentId: string) => Promise
+ createGroup: (groupData: Group, projectId: string) => Promise
+ deleteGroup: (id: string) => Promise
+}
+
+export function useGroup(): GroupState {
+ const groups = ref(null)
+ const group = ref(null)
+
+ async function getGroupByID(id: string): Promise {
+ const endpoint = endpoints.groups.retrieve.replace('{id}', id)
+ await get(endpoint, group, Group.fromJSON)
}
- async function getGroupsByProject(project_id: string) {
- const endpoint = endpoints.groups.byProject.replace('{project_id}', project_id);
- await getList(endpoint, groups, Group.fromJSON);
+ async function getGroupsByProject(projectId: string): Promise {
+ const endpoint = endpoints.groups.byProject.replace(
+ '{projectId}',
+ projectId
+ )
+ await getList(endpoint, groups, Group.fromJSON)
}
- async function getGroupsByStudent(student_id: string) {
- const endpoint = endpoints.groups.byStudent.replace('{student_id}', student_id);
- await getList(endpoint, groups, Group.fromJSON);
+ async function getGroupsByStudent(studentId: string): Promise {
+ const endpoint = endpoints.groups.byStudent.replace(
+ '{studentId}',
+ studentId
+ )
+ await getList(endpoint, groups, Group.fromJSON)
}
- async function createGroup(group_data: Group, project_id: string) {
- const endpoint = endpoints.groups.byProject.replace('{project_id}', project_id);
- await create(endpoint,
+ async function createGroup(
+ groupData: Group,
+ projectId: string
+ ): Promise {
+ const endpoint = endpoints.groups.byProject.replace(
+ '{projectId}',
+ projectId
+ )
+ await create(
+ endpoint,
{
- score: group_data.score
+ score: groupData.score
},
- group, Group.fromJSON);
+ group,
+ Group.fromJSON
+ )
}
- async function deleteGroup(id: string) {
- const endpoint = endpoints.groups.retrieve.replace('{id}', id);
- await delete_id(endpoint, group, Group.fromJSON);
+ async function deleteGroup(id: string): Promise {
+ const endpoint = endpoints.groups.retrieve.replace('{id}', id)
+ await deleteId(endpoint, group, Group.fromJSON)
}
return {
@@ -45,5 +75,5 @@ export function useGroup() {
createGroup,
deleteGroup
- };
-}
\ No newline at end of file
+ }
+}
diff --git a/frontend/src/composables/services/helpers.ts b/frontend/src/composables/services/helpers.ts
index 44670e44..4303f33c 100644
--- a/frontend/src/composables/services/helpers.ts
+++ b/frontend/src/composables/services/helpers.ts
@@ -1,99 +1,167 @@
-import { AxiosError, AxiosResponse } from 'axios';
+import { type AxiosError, type AxiosResponse } from 'axios'
import { client } from '@/composables/axios.ts'
-import { Ref } from 'vue';
-import { useMessagesStore } from '@/store/messages.store.ts';
-import { i18n } from '../i18n';
+import { type Ref } from 'vue'
+import { useMessagesStore } from '@/store/messages.store.ts'
+import { i18n } from '../i18n'
-const lifeTime = 3000;
+const lifeTime = 3000
-export async function get(endpoint: string, ref: Ref, fromJson: (data: any) => T): Promise {
- await client.get(endpoint).then((response: AxiosResponse) => {
- ref.value = fromJson(response.data);
- //add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
- }).catch((error: AxiosError) => {
- processError(error);
- console.error(error); // Log the error for debugging
- });
+export async function get(
+ endpoint: string,
+ ref: Ref,
+ fromJson: (data: any) => T
+): Promise {
+ await client
+ .get(endpoint)
+ .then((response: AxiosResponse) => {
+ ref.value = fromJson(response.data)
+ // add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
+ })
+ .catch((error: AxiosError) => {
+ processError(error)
+ console.error(error) // Log the error for debugging
+ })
}
-export async function create(endpoint: string, data:any, ref: Ref, fromJson: (data: any) => T): Promise {
- await client.post(endpoint, data).then((response: AxiosResponse) => {
- ref.value = fromJson(response.data);
- //add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
- }).catch((error: AxiosError) => {
- processError(error);
- console.error(error); // Log the error for debugging
- });
+export async function create(
+ endpoint: string,
+ data: any,
+ ref: Ref,
+ fromJson: (data: any) => T
+): Promise {
+ await client
+ .post(endpoint, data)
+ .then((response: AxiosResponse) => {
+ ref.value = fromJson(response.data)
+ // add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
+ })
+ .catch((error: AxiosError) => {
+ processError(error)
+ console.error(error) // Log the error for debugging
+ })
}
-export async function delete_id(endpoint: string, ref: Ref, fromJson: (data: any) => T): Promise {
- await client.delete(endpoint).then((response: AxiosResponse) => {
- ref.value = fromJson(response.data);
- //add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
- }).catch((error: AxiosError) => {
- processError(error);
- console.error(error); // Log the error for debugging
- });
+export async function deleteId(
+ endpoint: string,
+ ref: Ref,
+ fromJson: (data: any) => T
+): Promise {
+ await client
+ .delete(endpoint)
+ .then((response: AxiosResponse) => {
+ ref.value = fromJson(response.data)
+ // add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
+ })
+ .catch((error: AxiosError) => {
+ processError(error)
+ console.error(error) // Log the error for debugging
+ })
}
-export async function delete_id_with_data(endpoint: string, data: any, ref: Ref, fromJson: (data: any) => T): Promise {
- await client.delete(endpoint,{ data }).then((response: AxiosResponse) => {
- ref.value = fromJson(response.data);
- //add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
- }).catch((error: AxiosError) => {
- processError(error);
- console.error(error); // Log the error for debugging
- });
+export async function deleteIdWithData(
+ endpoint: string,
+ data: any,
+ ref: Ref,
+ fromJson: (data: any) => T
+): Promise {
+ await client
+ .delete(endpoint, { data })
+ .then((response: AxiosResponse) => {
+ ref.value = fromJson(response.data)
+ // add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
+ })
+ .catch((error: AxiosError) => {
+ processError(error)
+ console.error(error) // Log the error for debugging
+ })
}
-
-export async function getList(endpoint: string, ref: Ref, fromJson: (data: any) => T): Promise {
- await client.get(endpoint).then(response => {
- ref.value = response.data.map((data: T) => fromJson(data));
- //add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
- }
- ).catch((error: AxiosError) => {
- processError(error);
- console.error(error); // Log the error for debugging
- });
+export async function getList(
+ endpoint: string,
+ ref: Ref,
+ fromJson: (data: any) => T
+): Promise {
+ await client
+ .get(endpoint)
+ .then((response) => {
+ ref.value = response.data.map((data: T) => fromJson(data))
+ // add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
+ })
+ .catch((error: AxiosError) => {
+ processError(error)
+ console.error(error) // Log the error for debugging
+ })
}
-export async function getListMerged(endpoints: string[], ref: Ref, fromJson: (data: any) => T): Promise {
+export async function getListMerged(
+ endpoints: string[],
+ ref: Ref,
+ fromJson: (data: any) => T
+): Promise {
// Create an array to accumulate all response data
- const allData: T[] = [];
+ const allData: T[] = []
- for (const endpoint of endpoints){
- await client.get(endpoint).then(response => {
- const responseData: T[] = response.data.map((data: T) => fromJson(data));
- allData.push(...responseData); // Merge into the allData array
- // add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
- }
- ).catch((error: AxiosError) => {
- processError(error);
- console.error(error); // Log the error for debugging
- });
+ for (const endpoint of endpoints) {
+ await client
+ .get(endpoint)
+ .then((response) => {
+ const responseData: T[] = response.data.map((data: T) =>
+ fromJson(data)
+ )
+ allData.push(...responseData) // Merge into the allData array
+ // add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime});
+ })
+ .catch((error: AxiosError) => {
+ processError(error)
+ console.error(error) // Log the error for debugging
+ })
}
- ref.value = allData;
+ ref.value = allData
}
-export function processError(error: AxiosError){
- const { t } = i18n.global;
- const { add } = useMessagesStore();
+export function processError(error: AxiosError): void {
+ const { t } = i18n.global
+ const { add } = useMessagesStore()
- if (error.response) {
+ if (error.response !== undefined && error.response !== null) {
// The request was made and the server responded with a status code
if (error.response.status === 404) {
- add({ severity: 'error', summary: t('composables.helpers.errors.notFound'), detail: t('composables.helpers.errors.notFoundDetail'), life: lifeTime });
+ add({
+ severity: 'error',
+ summary: t('composables.helpers.errors.notFound'),
+ detail: t('composables.helpers.errors.notFoundDetail'),
+ life: lifeTime
+ })
} else if (error.response.status === 401) {
- add({ severity: 'error', summary: t('composables.helpers.errors.unauthorized'), detail: t('composables.helpers.errors.unauthorizedDetail'), life: lifeTime });
+ add({
+ severity: 'error',
+ summary: t('composables.helpers.errors.unauthorized'),
+ detail: t('composables.helpers.errors.unauthorizedDetail'),
+ life: lifeTime
+ })
} else {
- add({ severity: 'error', summary: t('composables.helpers.errors.server'), detail: t('composables.helpers.errors.serverDetail'), life: lifeTime });
+ add({
+ severity: 'error',
+ summary: t('composables.helpers.errors.server'),
+ detail: t('composables.helpers.errors.serverDetail'),
+ life: lifeTime
+ })
}
- } else if (error.request) {
+ } else if (error.request !== undefined && error.request !== null) {
// The request was made but no response was received
- add({ severity: 'error', summary: t('composables.helpers.errors.network'), detail: t('composables.helpers.errors.networkDetail'), life: lifeTime });
+ add({
+ severity: 'error',
+ summary: t('composables.helpers.errors.network'),
+ detail: t('composables.helpers.errors.networkDetail'),
+ life: lifeTime
+ })
} else {
// Something happened in setting up the request that triggered an error
- add({ severity: 'error', summary: t('composables.helpers.errors.request'), detail: t('composables.helpers.errors.requestDetail'), life: lifeTime });
+ add({
+ severity: 'error',
+ summary: t('composables.helpers.errors.request'),
+ detail: t('composables.helpers.errors.requestDetail'),
+ life: lifeTime
+ })
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/composables/services/project.service.ts b/frontend/src/composables/services/project.service.ts
index 6271185f..62297b5d 100644
--- a/frontend/src/composables/services/project.service.ts
+++ b/frontend/src/composables/services/project.service.ts
@@ -1,81 +1,143 @@
-import {Project} from '@/types/Projects.ts';
-import { Course } from '@/types/Course';
-import {ref} from 'vue';
-import {endpoints} from '@/config/endpoints.ts';
-import axios from 'axios';
-import { get, getList, getListMerged, create, delete_id, processError } from '@/composables/services/helpers.ts';
-
-
-export function useProject() {
- const projects = ref(null);
- const project = ref(null);
-
- async function getProjectByID(id: string) {
- const endpoint = endpoints.projects.retrieve.replace('{id}', id);
- await get(endpoint, project, Project.fromJSON);
+import { Project } from '@/types/Projects.ts'
+import { Course } from '@/types/Course'
+import { type Ref, ref } from 'vue'
+import { endpoints } from '@/config/endpoints.ts'
+import axios from 'axios'
+import {
+ get,
+ getList,
+ getListMerged,
+ create,
+ deleteId,
+ processError
+} from '@/composables/services/helpers.ts'
+
+interface ProjectState {
+ projects: Ref
+ project: Ref
+ getProjectByID: (id: string) => Promise
+ getProjectsByCourse: (courseId: string) => Promise
+ getProjectsByStudent: (studentId: string) => Promise
+ getProjectsByCourseAndDeadline: (
+ courseId: string,
+ deadlineDate: Date
+ ) => Promise
+ createProject: (projectData: Project, courseId: string) => Promise
+ deleteProject: (id: string) => Promise
+}
+
+export function useProject(): ProjectState {
+ const projects = ref(null)
+ const project = ref(null)
+
+ async function getProjectByID(id: string): Promise {
+ const endpoint = endpoints.projects.retrieve.replace('{id}', id)
+ await get(endpoint, project, Project.fromJSON)
}
- async function getProjectsByCourse(course_id: string) {
- const endpoint = endpoints.projects.byCourse.replace('{course_id}', course_id);
- await getList(endpoint, projects, Project.fromJSON);
+ async function getProjectsByCourse(courseId: string): Promise {
+ const endpoint = endpoints.projects.byCourse.replace(
+ '{courseId}',
+ courseId
+ )
+ await getList(endpoint, projects, Project.fromJSON)
}
- async function getProjectsByStudent(student_id: string) {
- const endpoint = endpoints.courses.byStudent.replace('{student_id}', student_id);
- const courses = ref(null);
- await getList(endpoint, courses, Course.fromJSON);
-
- const endpList = [];
- for (const course of courses.value?courses.value:[]){
- endpList.push(endpoints.projects.byCourse.replace('{course_id}', course.id.toString()));
+ async function getProjectsByStudent(studentId: string): Promise {
+ const endpoint = endpoints.courses.byStudent.replace(
+ '{studentId}',
+ studentId
+ )
+ const courses = ref(null)
+ await getList(endpoint, courses, Course.fromJSON)
+
+ const endpList = []
+ let coursesValue: Course[] | null = courses.value
+ if (coursesValue === null) {
+ coursesValue = []
+ }
+ for (const course of coursesValue) {
+ endpList.push(
+ endpoints.projects.byCourse.replace(
+ '{courseId}',
+ course.id.toString()
+ )
+ )
}
-
- await getListMerged(endpList, projects, Project.fromJSON);
- }
-
- async function getProjectsByCourseAndDeadline(course_id: string, deadlineDate: Date ) {
-
- const endpoint = endpoints.projects.byCourse.replace('{course_id}', course_id);
-
- await axios.get(endpoint).then(response => {
- const allProjects = response.data.map((projectData: Project) => Project.fromJSON(projectData));
-
- // Filter projects based on the deadline date
- const projectsWithMatchingDeadline = allProjects.filter((project: Project) => {
- const projectDeadlineDate = project.deadline;
- return projectDeadlineDate.toDateString() === deadlineDate.toDateString();
- });
- // Update the projects ref with the filtered projects
- projects.value = projectsWithMatchingDeadline;
- }).catch(error => {
- processError(error);
- console.log(error.data);
- });
+ await getListMerged(endpList, projects, Project.fromJSON)
}
+ async function getProjectsByCourseAndDeadline(
+ courseId: string,
+ deadlineDate: Date
+ ): Promise {
+ const endpoint = endpoints.projects.byCourse.replace(
+ '{courseId}',
+ courseId
+ )
+
+ await axios
+ .get(endpoint)
+ .then((response) => {
+ const allProjects = response.data.map((projectData: Project) =>
+ Project.fromJSON(projectData)
+ )
+
+ // Filter projects based on the deadline date
+ const projectsWithMatchingDeadline = allProjects.filter(
+ (project: Project) => {
+ const projectDeadlineDate = project.deadline
+ return (
+ projectDeadlineDate.toDateString() ===
+ deadlineDate.toDateString()
+ )
+ }
+ )
+
+ // Update the projects ref with the filtered projects
+ projects.value = projectsWithMatchingDeadline
+ })
+ .catch((error) => {
+ if (axios.isAxiosError(error)) {
+ processError(error)
+ console.log(error.response?.data)
+ } else {
+ console.error('An unexpected error ocurred: ', error)
+ }
+ })
+ }
- async function createProject(project_data: Project, course_id: string) {
- const endpoint = endpoints.projects.byCourse.replace('{course_id}', course_id);
- await create(endpoint,
+ async function createProject(
+ projectData: Project,
+ courseId: string
+ ): Promise {
+ const endpoint = endpoints.projects.byCourse.replace(
+ '{courseId}',
+ courseId
+ )
+ await create(
+ endpoint,
{
- name: project_data.name,
- description: project_data.description,
- visible: project_data.visible,
- archived: project_data.archived,
- locked_groups: project_data.locked_groups,
- start_data: project_data.start_date,
- deadline: project_data.deadline,
- max_score: project_data.max_score,
- score_visible: project_data.score_visible,
- group_size: project_data.group_size
+ name: projectData.name,
+ description: projectData.description,
+ visible: projectData.visible,
+ archived: projectData.archived,
+ locked_groups: projectData.locked_groups,
+ start_data: projectData.start_date,
+ deadline: projectData.deadline,
+ max_score: projectData.max_score,
+ score_visible: projectData.score_visible,
+ group_size: projectData.group_size
},
- project, Project.fromJSON);
+ project,
+ Project.fromJSON
+ )
}
- async function deleteProject(id: string) {
- const endpoint = endpoints.projects.retrieve.replace('{id}', id);
- await delete_id(endpoint, project, Project.fromJSON);
+ async function deleteProject(id: string): Promise {
+ const endpoint = endpoints.projects.retrieve.replace('{id}', id)
+ await deleteId(endpoint, project, Project.fromJSON)
}
return {
@@ -88,5 +150,5 @@ export function useProject() {
createProject,
deleteProject
- };
-}
\ No newline at end of file
+ }
+}
diff --git a/frontend/src/composables/services/structure_check.service.ts b/frontend/src/composables/services/structure_check.service.ts
index efe3b62e..a0c4c3a2 100644
--- a/frontend/src/composables/services/structure_check.service.ts
+++ b/frontend/src/composables/services/structure_check.service.ts
@@ -1,43 +1,86 @@
-import {StructureCheck} from '@/types/StructureCheck.ts';
-import {ref} from 'vue';
-import {endpoints} from '@/config/endpoints.ts';
-import { get, getList, create, delete_id } from '@/composables/services/helpers.ts';
-
-export function useStructureCheck() {
- const structure_checks = ref(null);
- const structure_check = ref(null);
-
- async function getStructureCheckByID(id: string) {
- const endpoint = endpoints.structure_checks.retrieve.replace('{id}', id);
- await get(endpoint, structure_check, StructureCheck.fromJSON);
+import { StructureCheck } from '@/types/StructureCheck.ts'
+import { type Ref, ref } from 'vue'
+import { endpoints } from '@/config/endpoints.ts'
+import {
+ get,
+ getList,
+ create,
+ deleteId
+} from '@/composables/services/helpers.ts'
+
+interface StructureCheckState {
+ structureChecks: Ref
+ structureCheck: Ref
+ getStructureCheckByID: (id: string) => Promise
+ getStructureCheckByProject: (projectId: string) => Promise
+ createStructureCheck: (
+ structureCheckData: StructureCheck,
+ projectId: string
+ ) => Promise
+ deleteStructureCheck: (id: string) => Promise
+}
+
+export function useStructureCheck(): StructureCheckState {
+ const structureChecks = ref(null)
+ const structureCheck = ref(null)
+
+ async function getStructureCheckByID(id: string): Promise {
+ const endpoint = endpoints.structureChecks.retrieve.replace('{id}', id)
+ await get(
+ endpoint,
+ structureCheck,
+ StructureCheck.fromJSON
+ )
}
- async function getStructureCheckByProject(project_id: string) {
- const endpoint = endpoints.structure_checks.byProject.replace('{project_id}', project_id);
- await getList(endpoint, structure_checks, StructureCheck.fromJSON);
+ async function getStructureCheckByProject(
+ projectId: string
+ ): Promise {
+ const endpoint = endpoints.structureChecks.byProject.replace(
+ '{projectId}',
+ projectId
+ )
+ await getList(
+ endpoint,
+ structureChecks,
+ StructureCheck.fromJSON
+ )
}
- async function createStructureCheck(structure_check_data: StructureCheck, project_id: string) {
- const endpoint = endpoints.structure_checks.byProject.replace('{project_id}', project_id);
- await create(endpoint,
+ async function createStructureCheck(
+ structureCheckData: StructureCheck,
+ projectId: string
+ ): Promise {
+ const endpoint = endpoints.structureChecks.byProject.replace(
+ '{projectId}',
+ projectId
+ )
+ await create(
+ endpoint,
{
- name: structure_check_data.name
+ name: structureCheckData.name
},
- structure_check, StructureCheck.fromJSON);
+ structureCheck,
+ StructureCheck.fromJSON
+ )
}
- async function deleteStructureCheck(id: string) {
- const endpoint = endpoints.structure_checks.retrieve.replace('{id}', id);
- await delete_id(endpoint, structure_check, StructureCheck.fromJSON);
+ async function deleteStructureCheck(id: string): Promise {
+ const endpoint = endpoints.structureChecks.retrieve.replace('{id}', id)
+ await deleteId(
+ endpoint,
+ structureCheck,
+ StructureCheck.fromJSON
+ )
}
return {
- structure_checks,
- structure_check,
+ structureChecks,
+ structureCheck,
getStructureCheckByID,
getStructureCheckByProject,
createStructureCheck,
deleteStructureCheck
- };
-}
\ No newline at end of file
+ }
+}
diff --git a/frontend/src/composables/services/students.service.ts b/frontend/src/composables/services/students.service.ts
index 11b50faa..9b2e2110 100644
--- a/frontend/src/composables/services/students.service.ts
+++ b/frontend/src/composables/services/students.service.ts
@@ -1,68 +1,143 @@
-import {Student} from '@/types/Student';
-import { Response } from '@/types/Response';
-import {ref} from 'vue';
-import {endpoints} from '@/config/endpoints.ts';
-import { get, getList, create, delete_id, delete_id_with_data } from '@/composables/services/helpers.ts';
-
-export function useStudents() {
- const students = ref(null);
- const student = ref(null);
- const response = ref(null);
-
- async function getStudentByID(id: string) {
- const endpoint = endpoints.students.retrieve.replace('{id}', id);
- await get(endpoint, student, Student.fromJSON);
+import { Student } from '@/types/Student'
+import { Response } from '@/types/Response'
+import { type Ref, ref } from 'vue'
+import { endpoints } from '@/config/endpoints.ts'
+import {
+ get,
+ getList,
+ create,
+ deleteId,
+ deleteIdWithData
+} from '@/composables/services/helpers.ts'
+
+interface StudentsState {
+ students: Ref
+ student: Ref
+ response: Ref
+ getStudentByID: (id: string) => Promise
+ getStudents: () => Promise
+ getStudentsByCourse: (courseId: string) => Promise
+ getStudentsByGroup: (groupId: string) => Promise
+ createStudent: (studentData: Student) => Promise
+ deleteStudent: (id: string) => Promise
+ studentJoinCourse: (courseId: string, studentId: string) => Promise
+ studentLeaveCourse: (courseId: string, studentId: string) => Promise