Work in progress
This commit is contained in:
parent
cc2ae195c0
commit
34efe68842
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ const { id: currentUserId } = useUserStore();
|
|||
|
||||
const { competenceCertificates } = useAllCompetenceCertificates(
|
||||
props.userId ?? currentUserId,
|
||||
props.courseSlug
|
||||
props.courseSlug,
|
||||
true
|
||||
);
|
||||
|
||||
const assignments = computed(() => {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Reference in New Issue