Merged in feature/VBV-757-clone-course-data-for-completion (pull request #404)

Feature/VBV-757 clone course data for completion

Approved-by: Christian Cueni
This commit is contained in:
Daniel Egger 2024-10-08 14:49:21 +00:00 committed by Christian Cueni
commit 5bf9ec0176
2 changed files with 9 additions and 4 deletions

View File

@ -47,6 +47,7 @@ import type {
import { useQuery } from "@urql/vue"; import { useQuery } from "@urql/vue";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { t } from "i18next"; import { t } from "i18next";
import { cloneDeep } from "lodash";
import orderBy from "lodash/orderBy"; import orderBy from "lodash/orderBy";
import log from "loglevel"; import log from "loglevel";
import type { ComputedRef, Ref } from "vue"; import type { ComputedRef, Ref } from "vue";
@ -192,10 +193,12 @@ export function useCourseData(courseSlug: string) {
log.error(result.error); log.error(result.error);
} }
course.value = result.data?.course as unknown as Course; // VBV-757: clone data from `COURSE_QUERY` here, so that each user in
actionCompetences.value = result.data?.course // `useCourseDataWithCompletion` has its own completion instance in the course
?.action_competences as ActionCompetence[]; const courseData = cloneDeep(result.data?.course) as unknown as Course;
learningPath.value = result.data?.course?.learning_path as LearningPathType; course.value = courseData;
actionCompetences.value = courseData.action_competences as ActionCompetence[];
learningPath.value = courseData.learning_path as LearningPathType;
// attach circle information to learning contents // attach circle information to learning contents
if (learningPath.value) { if (learningPath.value) {

View File

@ -204,6 +204,8 @@ export interface Course {
slug: string; slug: string;
profiles: string[]; profiles: string[];
configuration: CourseConfiguration; configuration: CourseConfiguration;
learning_path?: LearningPathType;
action_competences?: ActionCompetence[];
} }
export interface CourseCategory { export interface CourseCategory {