From 3b0f562a7a402a8715fd7cd56d4481c795471ae3 Mon Sep 17 00:00:00 2001 From: Reto Aebersold Date: Fri, 15 Dec 2023 10:50:41 +0100 Subject: [PATCH] feat: mentor dashboard --- .../cockpit/cockpitPage/CockpitMentorPage.vue | 39 +++++++++--- .../pages/cockpit/cockpitPage/CockpitPage.vue | 22 ------- .../mentor/MentorDetailParentPage.vue | 7 +++ .../cockpitPage/mentor/MentorOverview.vue | 61 ++++++++++++++++++ .../cockpitPage/mentor/MentorParticipants.vue | 35 +++++++++++ .../mentor/MentorPraxisAssignment.vue | 3 + client/src/router/guards.ts | 29 +++++++-- client/src/router/index.ts | 62 ++++++++++++++++++- client/src/stores/cockpit.ts | 1 + .../commands/create_default_courses.py | 7 +++ .../content/praxis_assignment.py | 2 +- 11 files changed, 230 insertions(+), 38 deletions(-) delete mode 100644 client/src/pages/cockpit/cockpitPage/CockpitPage.vue create mode 100644 client/src/pages/cockpit/cockpitPage/mentor/MentorDetailParentPage.vue create mode 100644 client/src/pages/cockpit/cockpitPage/mentor/MentorOverview.vue create mode 100644 client/src/pages/cockpit/cockpitPage/mentor/MentorParticipants.vue create mode 100644 client/src/pages/cockpit/cockpitPage/mentor/MentorPraxisAssignment.vue diff --git a/client/src/pages/cockpit/cockpitPage/CockpitMentorPage.vue b/client/src/pages/cockpit/cockpitPage/CockpitMentorPage.vue index 084318d1..9dba6362 100644 --- a/client/src/pages/cockpit/cockpitPage/CockpitMentorPage.vue +++ b/client/src/pages/cockpit/cockpitPage/CockpitMentorPage.vue @@ -1,17 +1,38 @@ - - diff --git a/client/src/pages/cockpit/cockpitPage/CockpitPage.vue b/client/src/pages/cockpit/cockpitPage/CockpitPage.vue deleted file mode 100644 index 92a694ed..00000000 --- a/client/src/pages/cockpit/cockpitPage/CockpitPage.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/client/src/pages/cockpit/cockpitPage/mentor/MentorDetailParentPage.vue b/client/src/pages/cockpit/cockpitPage/mentor/MentorDetailParentPage.vue new file mode 100644 index 00000000..f62e2705 --- /dev/null +++ b/client/src/pages/cockpit/cockpitPage/mentor/MentorDetailParentPage.vue @@ -0,0 +1,7 @@ + + + diff --git a/client/src/pages/cockpit/cockpitPage/mentor/MentorOverview.vue b/client/src/pages/cockpit/cockpitPage/mentor/MentorOverview.vue new file mode 100644 index 00000000..1d727bdb --- /dev/null +++ b/client/src/pages/cockpit/cockpitPage/mentor/MentorOverview.vue @@ -0,0 +1,61 @@ + + + diff --git a/client/src/pages/cockpit/cockpitPage/mentor/MentorParticipants.vue b/client/src/pages/cockpit/cockpitPage/mentor/MentorParticipants.vue new file mode 100644 index 00000000..4b0b22a8 --- /dev/null +++ b/client/src/pages/cockpit/cockpitPage/mentor/MentorParticipants.vue @@ -0,0 +1,35 @@ + + + diff --git a/client/src/pages/cockpit/cockpitPage/mentor/MentorPraxisAssignment.vue b/client/src/pages/cockpit/cockpitPage/mentor/MentorPraxisAssignment.vue new file mode 100644 index 00000000..b2bc7546 --- /dev/null +++ b/client/src/pages/cockpit/cockpitPage/mentor/MentorPraxisAssignment.vue @@ -0,0 +1,3 @@ + + + diff --git a/client/src/router/guards.ts b/client/src/router/guards.ts index 9051bf9e..117372cb 100644 --- a/client/src/router/guards.ts +++ b/client/src/router/guards.ts @@ -62,10 +62,6 @@ export async function handleCurrentCourseSession(to: RouteLocationNormalized) { if (!courseSessionsStore.loaded) { await courseSessionsStore.loadCourseSessionsData(); } - - // Must be after loadCourseSessionsData & _currentCourseSlug is set! - const courseId = courseSessionsStore.currentCourseSession?.course.id || null; - await useCockpitStore().fetchCockpitType(courseId); } } @@ -102,3 +98,28 @@ export async function handleCourseSessionAsQueryParam(to: RouteLocationNormalize } } } + +export async function handleCockpit(to: RouteLocationNormalized) { + const courseSessionsStore = useCourseSessionsStore(); + const courseId = courseSessionsStore.currentCourseSession?.course.id || null; + const cockpitStore = useCockpitStore(); + await cockpitStore.fetchCockpitType(courseId); + + if (to.name === "cockpit") { + if (cockpitStore.hasExpertCockpitType) { + return { name: "expertCockpit", params: to.params }; + } else if (cockpitStore.hasMentorCockpitType) { + return { name: "mentorCockpitOverview", params: to.params }; + } + } + + const cockpitType = to.meta?.cockpitType; + + if (!cockpitType) { + return; + } + + if (cockpitType !== cockpitStore.cockpitType) { + return "/"; + } +} diff --git a/client/src/router/index.ts b/client/src/router/index.ts index c5c68be7..3cb66bb9 100644 --- a/client/src/router/index.ts +++ b/client/src/router/index.ts @@ -1,6 +1,7 @@ import DashboardPage from "@/pages/dashboard/DashboardPage.vue"; import LoginPage from "@/pages/LoginPage.vue"; import { + handleCockpit, handleCourseSessionAsQueryParam, handleCurrentCourseSession, redirectToLoginIfRequired, @@ -134,16 +135,71 @@ const router = createRouter({ }, { path: "/course/:courseSlug/cockpit", + name: "cockpit", children: [ { - path: "", - component: () => import("@/pages/cockpit/cockpitPage/CockpitPage.vue"), + path: "expert", + component: () => import("@/pages/cockpit/cockpitPage/CockpitExpertPage.vue"), props: true, + name: "expertCockpit", + meta: { + cockpitType: "expert", + }, + }, + { + path: "mentor", + component: () => import("@/pages/cockpit/cockpitPage/CockpitMentorPage.vue"), + name: "mentorCockpit", + meta: { + cockpitType: "mentor", + }, + children: [ + { + path: "", + component: () => + import("@/pages/cockpit/cockpitPage/mentor/MentorOverview.vue"), + name: "mentorCockpitOverview", + meta: { + cockpitType: "mentor", + }, + }, + { + path: "participants", + component: () => + import("@/pages/cockpit/cockpitPage/mentor/MentorParticipants.vue"), + name: "mentorCockpitParticipants", + meta: { + cockpitType: "mentor", + }, + }, + { + path: "details", + component: () => + import("@/pages/cockpit/cockpitPage/mentor/MentorDetailParentPage.vue"), + meta: { + cockpitType: "mentor", + }, + children: [ + { + path: "praxis-assignments", + component: () => + import( + "@/pages/cockpit/cockpitPage/mentor/MentorPraxisAssignment.vue" + ), + name: "mentorCockpitPraxisAssignments", + meta: { + cockpitType: "mentor", + }, + }, + ], + }, + ], }, { path: "profile/:userId", component: () => import("@/pages/cockpit/CockpitUserProfilePage.vue"), props: true, + name: "cockpitUserProfile", }, { path: "profile/:userId/:circleSlug", @@ -259,6 +315,8 @@ router.beforeEach(redirectToLoginIfRequired); router.beforeEach(handleCurrentCourseSession); router.beforeEach(handleCourseSessionAsQueryParam); +router.beforeEach(handleCockpit); + router.beforeEach(addToHistory); export default router; diff --git a/client/src/stores/cockpit.ts b/client/src/stores/cockpit.ts index b570783d..61d12033 100644 --- a/client/src/stores/cockpit.ts +++ b/client/src/stores/cockpit.ts @@ -32,5 +32,6 @@ export const useCockpitStore = defineStore("cockpit", () => { hasMentorCockpitType, hasNoCockpitType, isLoading, + cockpitType, }; }); diff --git a/server/vbv_lernwelt/course/management/commands/create_default_courses.py b/server/vbv_lernwelt/course/management/commands/create_default_courses.py index 43139de5..ac931c2d 100644 --- a/server/vbv_lernwelt/course/management/commands/create_default_courses.py +++ b/server/vbv_lernwelt/course/management/commands/create_default_courses.py @@ -215,6 +215,13 @@ def create_versicherungsvermittlerin_course( cs = CourseSession.objects.create(course_id=course_id, title=names[language]) + for assignment in Assignment.objects.all(): + if assignment.get_course().id == course_id: + CourseSessionAssignment.objects.get_or_create( + course_session=cs, + learning_content=assignment.find_attached_learning_content(), + ) + if language == "de": for user_data in default_users: CourseSessionUser.objects.create( diff --git a/server/vbv_lernwelt/learning_mentor/content/praxis_assignment.py b/server/vbv_lernwelt/learning_mentor/content/praxis_assignment.py index c0853dfd..0e8298a8 100644 --- a/server/vbv_lernwelt/learning_mentor/content/praxis_assignment.py +++ b/server/vbv_lernwelt/learning_mentor/content/praxis_assignment.py @@ -87,7 +87,7 @@ def get_praxis_assignments( for course_session_assignment in CourseSessionAssignment.objects.filter( course_session=course_session, - learning_content__content_assignment__assignment_type__in=[ + learning_content__assignment_type__in=[ AssignmentType.PRAXIS_ASSIGNMENT.value, ], ):