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