Jump to cockpit for trainers and superusers
This commit is contained in:
parent
7112a0e638
commit
db35a037eb
|
|
@ -106,7 +106,7 @@ onMounted(() => {
|
|||
v-if="
|
||||
inCourse() &&
|
||||
courseSessionsStore.currentCourseSession &&
|
||||
courseSessionsStore.hasCockpit
|
||||
courseSessionsStore.currentCourseSessionHasCockpit
|
||||
"
|
||||
:to="`${courseSessionsStore.currentCourseSession.course_url}/cockpit`"
|
||||
class="nav-item"
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
import LearningPathDiagramSmall from "@/components/learningPath/LearningPathDiagramSmall.vue";
|
||||
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import type { CourseSession } from "@/types";
|
||||
import log from "loglevel";
|
||||
import { onMounted } from "vue";
|
||||
import { computed, onMounted } from "vue";
|
||||
|
||||
log.debug("DashboardPage created");
|
||||
|
||||
|
|
@ -19,6 +20,15 @@ function employer() {
|
|||
onMounted(async () => {
|
||||
log.debug("DashboardPage mounted");
|
||||
});
|
||||
|
||||
const getNextStepLink = (courseSession: CourseSession) => {
|
||||
return computed(() => {
|
||||
if (courseSessionsStore.hasCockpit(courseSession)) {
|
||||
return courseSession.cockpit_url;
|
||||
}
|
||||
return courseSession.learning_path_url;
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -50,7 +60,7 @@ onMounted(async () => {
|
|||
<div>
|
||||
<router-link
|
||||
class="btn-blue"
|
||||
:to="courseSession.learning_path_url"
|
||||
:to="getNextStepLink(courseSession)"
|
||||
:data-cy="`continue-course-${courseSession.course.id}`"
|
||||
>
|
||||
{{ $t("general.nextStep") }}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const loginRequired = (to: RouteLocationNormalized) => {
|
|||
|
||||
export const expertRequired: NavigationGuard = (to: RouteLocationNormalized) => {
|
||||
const courseSessionsStore = useCourseSessionsStore();
|
||||
if (courseSessionsStore.hasCockpit) {
|
||||
if (courseSessionsStore.currentCourseSessionHasCockpit) {
|
||||
return true;
|
||||
} else {
|
||||
const courseSlug = to.params.courseSlug as string;
|
||||
|
|
|
|||
|
|
@ -124,13 +124,9 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
|||
return allCourseSessionsForCourse(_currentCourseSlug.value);
|
||||
});
|
||||
|
||||
const hasCockpit = computed(() => {
|
||||
const currentCourseSessionHasCockpit = computed(() => {
|
||||
if (currentCourseSession.value) {
|
||||
const userStore = useUserStore();
|
||||
return (
|
||||
userStore.course_session_experts.includes(currentCourseSession.value.id) ||
|
||||
userStore.is_superuser
|
||||
);
|
||||
return hasCockpit(currentCourseSession.value);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -182,6 +178,14 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
|||
);
|
||||
});
|
||||
|
||||
function hasCockpit(couseSession: CourseSession) {
|
||||
const userStore = useUserStore();
|
||||
return (
|
||||
userStore.course_session_experts.includes(couseSession.id) ||
|
||||
userStore.is_superuser
|
||||
);
|
||||
}
|
||||
|
||||
function addDocument(document: CircleDocument) {
|
||||
currentCourseSession.value?.documents.push(document);
|
||||
}
|
||||
|
|
@ -232,6 +236,7 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
|||
courseSessionForCourse,
|
||||
switchCourseSession,
|
||||
hasCockpit,
|
||||
currentCourseSessionHasCockpit,
|
||||
canUploadCircleDocuments,
|
||||
circleDocuments,
|
||||
circleExperts,
|
||||
|
|
|
|||
|
|
@ -415,6 +415,7 @@ export interface CourseSession {
|
|||
start_date: string;
|
||||
end_date: string;
|
||||
learning_path_url: string;
|
||||
cockpit_url: string;
|
||||
competence_url: string;
|
||||
course_url: string;
|
||||
media_library_url: string;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,10 @@ class Course(models.Model):
|
|||
return self.coursepage.get_children().exact_type(LearningPath).first().specific
|
||||
|
||||
def get_learning_path_url(self):
|
||||
return self.get_learning_path().get_frontend_url()
|
||||
return self.get_learning_path().get_learning_path_url()
|
||||
|
||||
def get_cockpit_url(self):
|
||||
return self.get_learning_path().get_cockpit_url()
|
||||
|
||||
def get_competence_url(self):
|
||||
from vbv_lernwelt.competence.models import CompetenceProfilePage
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ class CourseSessionSerializer(serializers.ModelSerializer):
|
|||
course = serializers.SerializerMethodField()
|
||||
course_url = serializers.SerializerMethodField()
|
||||
learning_path_url = serializers.SerializerMethodField()
|
||||
cockpit_url = serializers.SerializerMethodField()
|
||||
competence_url = serializers.SerializerMethodField()
|
||||
media_library_url = serializers.SerializerMethodField()
|
||||
documents = serializers.SerializerMethodField()
|
||||
|
|
@ -59,6 +60,9 @@ class CourseSessionSerializer(serializers.ModelSerializer):
|
|||
def get_learning_path_url(self, obj):
|
||||
return obj.course.get_learning_path_url()
|
||||
|
||||
def get_cockpit_url(self, obj):
|
||||
return obj.course.get_cockpit_url()
|
||||
|
||||
def get_media_library_url(self, obj):
|
||||
return obj.course.get_media_library_url()
|
||||
|
||||
|
|
@ -85,6 +89,7 @@ class CourseSessionSerializer(serializers.ModelSerializer):
|
|||
"attendance_days",
|
||||
"assignment_details_list",
|
||||
"learning_path_url",
|
||||
"cockpit_url",
|
||||
"competence_url",
|
||||
"media_library_url",
|
||||
"course_url",
|
||||
|
|
|
|||
|
|
@ -30,9 +30,12 @@ class LearningPath(CourseBasePage):
|
|||
def __str__(self):
|
||||
return f"{self.title}"
|
||||
|
||||
def get_frontend_url(self):
|
||||
def get_learning_path_url(self):
|
||||
return f"/course/{self.slug.replace('-lp', '')}/learn"
|
||||
|
||||
def get_cockpit_url(self):
|
||||
return f"/course/{self.slug.replace('-lp', '')}/cockpit"
|
||||
|
||||
|
||||
class Topic(CourseBasePage):
|
||||
serialize_field_names = ["is_visible"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue