Refactor courseSessionStore names
This commit is contained in:
parent
1d88117d99
commit
a7cc07cc80
|
|
@ -196,7 +196,7 @@ const nextStep = () => {
|
||||||
|
|
||||||
const sendFeedback = () => {
|
const sendFeedback = () => {
|
||||||
log.info("sending feedback");
|
log.info("sending feedback");
|
||||||
const courseSession = courseSessionsStore.courseSessionForRoute;
|
const courseSession = courseSessionsStore.currentCourseSession;
|
||||||
if (!courseSession || !courseSession.id) {
|
if (!courseSession || !courseSession.id) {
|
||||||
log.error("no course session set");
|
log.error("no course session set");
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ function popoverClick(event: Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedCourseSessionTitle = computed(() => {
|
const selectedCourseSessionTitle = computed(() => {
|
||||||
return courseSessionsStore.courseSessionForRoute?.title;
|
return courseSessionsStore.currentCourseSession?.title;
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
@ -83,8 +83,8 @@ onMounted(() => {
|
||||||
<MobileMenu
|
<MobileMenu
|
||||||
v-if="userStore.loggedIn"
|
v-if="userStore.loggedIn"
|
||||||
:show="state.showMobileNavigationMenu"
|
:show="state.showMobileNavigationMenu"
|
||||||
:course-session="courseSessionsStore.courseSessionForRoute"
|
:course-session="courseSessionsStore.currentCourseSession"
|
||||||
:media-url="courseSessionsStore.courseSessionForRoute?.media_library_url"
|
:media-url="courseSessionsStore.currentCourseSession?.media_library_url"
|
||||||
:user="userStore"
|
:user="userStore"
|
||||||
@closemodal="state.showMobileNavigationMenu = false"
|
@closemodal="state.showMobileNavigationMenu = false"
|
||||||
@logout="userStore.handleLogout()"
|
@logout="userStore.handleLogout()"
|
||||||
|
|
@ -97,7 +97,7 @@ onMounted(() => {
|
||||||
@closemodal="state.showMobileProfileMenu = false"
|
@closemodal="state.showMobileProfileMenu = false"
|
||||||
>
|
>
|
||||||
<AccountMenuContent
|
<AccountMenuContent
|
||||||
:course-sessions="courseSessionsStore.courseSessionsForRoute"
|
:course-sessions="courseSessionsStore.currentCourseSessions"
|
||||||
:user="userStore"
|
:user="userStore"
|
||||||
@logout="logout"
|
@logout="logout"
|
||||||
/>
|
/>
|
||||||
|
|
@ -139,10 +139,10 @@ onMounted(() => {
|
||||||
<router-link
|
<router-link
|
||||||
v-if="
|
v-if="
|
||||||
inCourse() &&
|
inCourse() &&
|
||||||
courseSessionsStore.courseSessionForRoute &&
|
courseSessionsStore.currentCourseSession &&
|
||||||
courseSessionsStore.hasCockpit
|
courseSessionsStore.hasCockpit
|
||||||
"
|
"
|
||||||
:to="`${courseSessionsStore.courseSessionForRoute.course_url}/cockpit`"
|
:to="`${courseSessionsStore.currentCourseSession.course_url}/cockpit`"
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
:class="{ 'nav-item--active': inCockpit() }"
|
:class="{ 'nav-item--active': inCockpit() }"
|
||||||
>
|
>
|
||||||
|
|
@ -150,8 +150,8 @@ onMounted(() => {
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
v-if="inCourse() && courseSessionsStore.courseSessionForRoute"
|
v-if="inCourse() && courseSessionsStore.currentCourseSession"
|
||||||
:to="courseSessionsStore.courseSessionForRoute.learning_path_url"
|
:to="courseSessionsStore.currentCourseSession.learning_path_url"
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
:class="{ 'nav-item--active': inLearningPath() }"
|
:class="{ 'nav-item--active': inLearningPath() }"
|
||||||
>
|
>
|
||||||
|
|
@ -159,8 +159,8 @@ onMounted(() => {
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
v-if="inCourse() && courseSessionsStore.courseSessionForRoute"
|
v-if="inCourse() && courseSessionsStore.currentCourseSession"
|
||||||
:to="courseSessionsStore.courseSessionForRoute.competence_url"
|
:to="courseSessionsStore.currentCourseSession.competence_url"
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
:class="{ 'nav-item--active': inCompetenceProfile() }"
|
:class="{ 'nav-item--active': inCompetenceProfile() }"
|
||||||
>
|
>
|
||||||
|
|
@ -218,7 +218,7 @@ onMounted(() => {
|
||||||
>
|
>
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<AccountMenuContent
|
<AccountMenuContent
|
||||||
:course-sessions="courseSessionsStore.courseSessionsForRoute"
|
:course-sessions="courseSessionsStore.currentCourseSessions"
|
||||||
:user="userStore"
|
:user="userStore"
|
||||||
@logout="logout"
|
@logout="logout"
|
||||||
@select-course-session="selectCourseSession"
|
@select-course-session="selectCourseSession"
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,15 @@ onMounted(async () => {
|
||||||
<h1 data-cy="welcome-message">
|
<h1 data-cy="welcome-message">
|
||||||
{{ $t("dashboard.welcome", { name: userStore.first_name }) }}
|
{{ $t("dashboard.welcome", { name: userStore.first_name }) }}
|
||||||
</h1>
|
</h1>
|
||||||
<div v-if="courseSessionsStore.courseSessions.length > 0" class="mb-14">
|
<div
|
||||||
|
v-if="courseSessionsStore.uniqueCourseSessionsByCourse.length > 0"
|
||||||
|
class="mb-14"
|
||||||
|
>
|
||||||
<h2 class="mb-3 mt-12">Kurse</h2>
|
<h2 class="mb-3 mt-12">Kurse</h2>
|
||||||
|
|
||||||
<div class="grid auto-rows-fr grid-cols-1 gap-4 md:grid-cols-2">
|
<div class="grid auto-rows-fr grid-cols-1 gap-4 md:grid-cols-2">
|
||||||
<div
|
<div
|
||||||
v-for="courseSession in courseSessionsStore.userCourses"
|
v-for="courseSession in courseSessionsStore.uniqueCourseSessionsByCourse"
|
||||||
:key="courseSession.id"
|
:key="courseSession.id"
|
||||||
>
|
>
|
||||||
<div class="bg-white p-6 md:h-full">
|
<div class="bg-white p-6 md:h-full">
|
||||||
|
|
|
||||||
|
|
@ -132,8 +132,8 @@ function setActiveClasses(translationKey: string) {
|
||||||
learningPathStore.learningPathForUser(props.courseSlug, userStore.id)
|
learningPathStore.learningPathForUser(props.courseSlug, userStore.id)
|
||||||
?.circles || []
|
?.circles || []
|
||||||
"
|
"
|
||||||
:course-id="courseSessionStore.courseSessionForRoute?.course.id || 0"
|
:course-id="courseSessionStore.currentCourseSession?.course.id || 0"
|
||||||
:url="courseSessionStore.courseSessionForRoute?.course_url || ''"
|
:url="courseSessionStore.currentCourseSession?.course_url || ''"
|
||||||
></FeedbackSummary>
|
></FeedbackSummary>
|
||||||
<div>
|
<div>
|
||||||
<!-- progress -->
|
<!-- progress -->
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ const feedbackData = reactive<FeedbackData>({ amount: 0, questions: {} });
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
log.debug("FeedbackPage mounted");
|
log.debug("FeedbackPage mounted");
|
||||||
const data = await itGet(
|
const data = await itGet(
|
||||||
`/api/core/feedback/${courseSessionStore.courseSessionForRoute?.course.id}/${props.circleId}`
|
`/api/core/feedback/${courseSessionStore.currentCourseSession?.course.id}/${props.circleId}`
|
||||||
);
|
);
|
||||||
Object.assign(feedbackData, data);
|
Object.assign(feedbackData, data);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -112,12 +112,12 @@ async function uploadDocument(data: DocumentUploadData) {
|
||||||
isUploading.value = true;
|
isUploading.value = true;
|
||||||
showUploadErrorMessage.value = false;
|
showUploadErrorMessage.value = false;
|
||||||
try {
|
try {
|
||||||
if (!courseSessionsStore.courseSessionForRoute) {
|
if (!courseSessionsStore.currentCourseSession) {
|
||||||
throw new Error("No course session found");
|
throw new Error("No course session found");
|
||||||
}
|
}
|
||||||
const newDocument = await uploadCircleDocument(
|
const newDocument = await uploadCircleDocument(
|
||||||
data,
|
data,
|
||||||
courseSessionsStore.courseSessionForRoute.id
|
courseSessionsStore.currentCourseSession.id
|
||||||
);
|
);
|
||||||
const courseSessionStore = useCourseSessionsStore();
|
const courseSessionStore = useCourseSessionsStore();
|
||||||
courseSessionStore.addDocument(newDocument);
|
courseSessionStore.addDocument(newDocument);
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ function handleBack() {
|
||||||
<div class="mt-6 lg:mt-12">
|
<div class="mt-6 lg:mt-12">
|
||||||
{{ $t("selfEvaluation.progressText") }}
|
{{ $t("selfEvaluation.progressText") }}
|
||||||
<router-link
|
<router-link
|
||||||
:to="courseSession.courseSessionForRoute?.competence_url || '/'"
|
:to="courseSession.currentCourseSession?.competence_url || '/'"
|
||||||
class="text-primary-500 underline"
|
class="text-primary-500 underline"
|
||||||
>
|
>
|
||||||
{{ $t("selfEvaluation.progressLink") }}
|
{{ $t("selfEvaluation.progressLink") }}
|
||||||
|
|
|
||||||
|
|
@ -167,9 +167,7 @@ export const useCompetenceStore = defineStore({
|
||||||
const completionStore = useCompletionStore();
|
const completionStore = useCompletionStore();
|
||||||
|
|
||||||
const courseSessionsStore = useCourseSessionsStore();
|
const courseSessionsStore = useCourseSessionsStore();
|
||||||
const courseSession = courseSessionsStore.courseSessionForCourse(
|
const courseSession = courseSessionsStore.currentCourseSession;
|
||||||
competenceProfilePage.course.slug
|
|
||||||
);
|
|
||||||
if (courseSession) {
|
if (courseSession) {
|
||||||
const completionData = await completionStore.loadCompletionData(
|
const completionData = await completionStore.loadCompletionData(
|
||||||
courseSession.id,
|
courseSession.id,
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,9 @@ export const useCompletionStore = defineStore({
|
||||||
) {
|
) {
|
||||||
if (!courseSessionId) {
|
if (!courseSessionId) {
|
||||||
const courseSessionsStore = useCourseSessionsStore();
|
const courseSessionsStore = useCourseSessionsStore();
|
||||||
const courseSlug = courseSessionsStore.currentCourseSlug;
|
const courseSession = courseSessionsStore.currentCourseSession;
|
||||||
if (courseSlug) {
|
if (courseSession) {
|
||||||
const courseSessionsStore = useCourseSessionsStore();
|
courseSessionId = courseSession.id;
|
||||||
const courseSession = courseSessionsStore.courseSessionForCourse(courseSlug);
|
|
||||||
if (courseSession) {
|
|
||||||
courseSessionId = courseSession.id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
const currentCourseSlug = ref("");
|
const currentCourseSlug = ref("");
|
||||||
|
|
||||||
// these will become getters
|
// these will become getters
|
||||||
const userCourses = computed(() =>
|
const uniqueCourseSessionsByCourse = computed(() =>
|
||||||
// TODO: refactor after implementing of Klassenkonzept
|
// TODO: refactor after implementing of Klassenkonzept
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
uniqBy(courseSessions.value, "course.id")
|
uniqBy(courseSessions.value, "course.id")
|
||||||
|
|
@ -125,19 +125,19 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const courseSessionForRoute = computed(() => {
|
const currentCourseSession = computed(() => {
|
||||||
return courseSessionForCourse(currentCourseSlug.value);
|
return courseSessionForCourse(currentCourseSlug.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const courseSessionsForRoute = computed(() => {
|
const currentCourseSessions = computed(() => {
|
||||||
return courseSessionsForCourse(currentCourseSlug.value);
|
return courseSessionsForCourse(currentCourseSlug.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const hasCockpit = computed(() => {
|
const hasCockpit = computed(() => {
|
||||||
if (courseSessionForRoute.value) {
|
if (currentCourseSession.value) {
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
return (
|
return (
|
||||||
userStore.course_session_experts.includes(courseSessionForRoute.value.id) ||
|
userStore.course_session_experts.includes(currentCourseSession.value.id) ||
|
||||||
userStore.is_superuser
|
userStore.is_superuser
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -149,8 +149,8 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
const circleStore = useCircleStore();
|
const circleStore = useCircleStore();
|
||||||
const circleTranslationKey = circleStore.circle?.translation_key;
|
const circleTranslationKey = circleStore.circle?.translation_key;
|
||||||
|
|
||||||
if (courseSessionForRoute.value && circleTranslationKey) {
|
if (currentCourseSession.value && circleTranslationKey) {
|
||||||
return courseSessionForRoute.value.users.filter((u) => {
|
return currentCourseSession.value.users.filter((u) => {
|
||||||
if (u.role === "EXPERT") {
|
if (u.role === "EXPERT") {
|
||||||
return (u as ExpertSessionUser).circles
|
return (u as ExpertSessionUser).circles
|
||||||
.map((c) => c.translation_key)
|
.map((c) => c.translation_key)
|
||||||
|
|
@ -175,11 +175,11 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
return circleStore.circle?.learningSequences
|
return circleStore.circle?.learningSequences
|
||||||
.map((ls) => ({ id: ls.id, title: ls.title, documents: [] }))
|
.map((ls) => ({ id: ls.id, title: ls.title, documents: [] }))
|
||||||
.map((ls: { id: number; title: string; documents: CircleDocument[] }) => {
|
.map((ls: { id: number; title: string; documents: CircleDocument[] }) => {
|
||||||
if (courseSessionForRoute.value === undefined) {
|
if (currentCourseSession.value === undefined) {
|
||||||
return ls;
|
return ls;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const document of courseSessionForRoute.value.documents) {
|
for (const document of currentCourseSession.value.documents) {
|
||||||
if (document.learning_sequence === ls.id) {
|
if (document.learning_sequence === ls.id) {
|
||||||
ls.documents.push(document);
|
ls.documents.push(document);
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +190,7 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function addDocument(document: CircleDocument) {
|
function addDocument(document: CircleDocument) {
|
||||||
courseSessionForRoute.value?.documents.push(document);
|
currentCourseSession.value?.documents.push(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startUpload() {
|
async function startUpload() {
|
||||||
|
|
@ -204,20 +204,20 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
async function removeDocument(documentId: number) {
|
async function removeDocument(documentId: number) {
|
||||||
await deleteCircleDocument(documentId);
|
await deleteCircleDocument(documentId);
|
||||||
|
|
||||||
if (courseSessionForRoute.value === undefined) {
|
if (currentCourseSession.value === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
courseSessionForRoute.value.documents =
|
currentCourseSession.value.documents = currentCourseSession.value?.documents.filter(
|
||||||
courseSessionForRoute.value?.documents.filter((d) => d.id !== documentId);
|
(d) => d.id !== documentId
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function findAttendanceDay(
|
function findAttendanceDay(
|
||||||
contentId: number
|
contentId: number
|
||||||
): CourseSessionAttendanceDay | undefined {
|
): CourseSessionAttendanceDay | undefined {
|
||||||
const currentCourseSession = courseSessionForRoute.value;
|
if (currentCourseSession.value) {
|
||||||
if (currentCourseSession) {
|
return currentCourseSession.value.attendance_days.find(
|
||||||
return currentCourseSession.attendance_days.find(
|
|
||||||
(attendanceDay) => attendanceDay.learningContentId === contentId
|
(attendanceDay) => attendanceDay.learningContentId === contentId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -225,12 +225,10 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentCourseSlug,
|
currentCourseSlug,
|
||||||
courseSessions,
|
uniqueCourseSessionsByCourse,
|
||||||
userCourses,
|
currentCourseSession,
|
||||||
courseSessionForRoute,
|
currentCourseSessions,
|
||||||
courseSessionForCourse,
|
courseSessionForCourse,
|
||||||
courseSessionsForRoute,
|
|
||||||
courseSessionsForCourse,
|
|
||||||
switchCourseSession,
|
switchCourseSession,
|
||||||
hasCockpit,
|
hasCockpit,
|
||||||
canUploadCircleDocuments,
|
canUploadCircleDocuments,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue