From 34efe688426d51d2b534bd350a40966df365e5ca Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Tue, 3 Dec 2024 17:45:42 +0100 Subject: [PATCH] Work in progress --- client/src/composables.ts | 22 ++++++++++++++----- .../CompetenceCertificateListPage.vue | 3 ++- client/src/pages/competence/utils.ts | 10 ++++++++- client/src/router/index.ts | 16 ++++++++++++++ client/src/router/names.ts | 4 ++++ .../graphql.config.yml => graphql.config.yml | 0 6 files changed, 48 insertions(+), 7 deletions(-) rename server/graphql.config.yml => graphql.config.yml (100%) diff --git a/client/src/composables.ts b/client/src/composables.ts index 32102146..f68c4690 100644 --- a/client/src/composables.ts +++ b/client/src/composables.ts @@ -722,13 +722,25 @@ export function useVVByLink() { return { href }; } -export function useAllCompetenceCertificates(userId: string, courseSlug: string) { +export function useAllCompetenceCertificates( + userId: string, + courseSlug: string, + currentCourseSessionOnly: boolean = false +) { const courseSessionsStore = useCourseSessionsStore(); - const certificateQueries = courseSessionsStore.allCourseSessions.map( - (courseSession) => { + let certificateQueries; + if (currentCourseSessionOnly) { + const courseSession = useCurrentCourseSession(); + certificateQueries = [ + useCertificateQuery([userId], courseSlug, courseSession.value).certificatesQuery, + ]; + } else { + // wtf + certificateQueries = courseSessionsStore.allCourseSessions.map((courseSession) => { + // todo: use a single query, instead of one for every courseSession return useCertificateQuery([userId], courseSlug, courseSession).certificatesQuery; - } - ); + }); + } const competenceCertificatesPerCs = computed(() => certificateQueries.map((query) => { diff --git a/client/src/pages/competence/CompetenceCertificateListPage.vue b/client/src/pages/competence/CompetenceCertificateListPage.vue index bae5a789..5cf55baf 100644 --- a/client/src/pages/competence/CompetenceCertificateListPage.vue +++ b/client/src/pages/competence/CompetenceCertificateListPage.vue @@ -22,7 +22,8 @@ const { id: currentUserId } = useUserStore(); const { competenceCertificates } = useAllCompetenceCertificates( props.userId ?? currentUserId, - props.courseSlug + props.courseSlug, + true ); const assignments = computed(() => { diff --git a/client/src/pages/competence/utils.ts b/client/src/pages/competence/utils.ts index 96ba7171..3330884c 100644 --- a/client/src/pages/competence/utils.ts +++ b/client/src/pages/competence/utils.ts @@ -23,14 +23,21 @@ export function assignmentsUserPoints(assignments: CompetenceCertificateAssignme ).toFixed(1); } +/** + * Calculates the grade by summing up all the weighted percentage of points of each assignment. + * + * @param assignments - list of assignments + * @param roundedToHalfGrade - should the grade be rounded? + */ export function calcCompetenceCertificateGrade( assignments: CompetenceCertificateAssignment[], - roundedToHalfGrade = true + roundedToHalfGrade: boolean = true ) { const evaluatedAssignments = assignments.filter( (a) => a.completions?.[0]?.completion_status === "EVALUATION_SUBMITTED" ); + // sum((points_x / max_points) * weight_x) const adjustedResults = evaluatedAssignments.map((a) => { return ( ((a.completions?.[0]?.evaluation_points_final ?? 0) / a.max_points) * @@ -38,6 +45,7 @@ export function calcCompetenceCertificateGrade( ); }); + // count only assignments with weight const adjustedAssignmentCount = _.sum( evaluatedAssignments.map((a) => a.competence_certificate_weight) ); diff --git a/client/src/router/index.ts b/client/src/router/index.ts index 3f556a71..7e5496ca 100644 --- a/client/src/router/index.ts +++ b/client/src/router/index.ts @@ -15,6 +15,7 @@ import { onboardingRedirect } from "@/router/onboarding"; import { createRouter, createWebHistory } from "vue-router"; import { ATTENDANCE_ROUTE, + CERTIFICATE_OVERVIEW_ROUTE, CERTIFICATES_ROUTE, COCKPIT_ROUTE, COMPETENCE_ROUTE, @@ -89,6 +90,12 @@ const router = createRouter({ component: () => import("@/pages/dashboard/DashboardCostPage.vue"), props: true, }, + { + path: "/dashboard/certificates/:courseSlug", + component: () => + import("@/pages/competence/CompetenceCertificateOverviewPage.vue"), + props: true, + }, { path: "/course/:courseSlug", props: true, @@ -117,6 +124,7 @@ const router = createRouter({ }, ], }, + { path: "competence", component: () => import("@/pages/competence/CompetenceParentPage.vue"), @@ -189,6 +197,14 @@ const router = createRouter({ }, ], }, + + { + path: "certificates", + name: CERTIFICATE_OVERVIEW_ROUTE, + props: true, + component: () => + import("@/pages/competence/CompetenceCertificateOverviewPage.vue"), + }, { path: "profile/:userId", component: () => import("@/pages/userProfile/UserProfilePage.vue"), diff --git a/client/src/router/names.ts b/client/src/router/names.ts index 9cf94b14..8f6da18b 100644 --- a/client/src/router/names.ts +++ b/client/src/router/names.ts @@ -7,3 +7,7 @@ export const COCKPIT_ROUTE = "cockpit-home"; export const ATTENDANCE_ROUTE = "attendance"; export const DOCUMENTS_ROUTE = "documents"; export const PERSONAL_PROFILE_ROUTE = "personalProfile"; +export const MENTORS_PARTICIPANTS_ROUTE = "mentorsAndParticipants"; +export const MENTOR_OVERVIEW_ROUTE = "learningMentorOverview"; +export const LEARN_ROUTE = "learn"; +export const CERTIFICATE_OVERVIEW_ROUTE = "certificateOverview"; diff --git a/server/graphql.config.yml b/graphql.config.yml similarity index 100% rename from server/graphql.config.yml rename to graphql.config.yml