diff --git a/client/src/services/learningPath.ts b/client/src/services/learningPath.ts index 6d393340..68af3a6b 100644 --- a/client/src/services/learningPath.ts +++ b/client/src/services/learningPath.ts @@ -1,6 +1,7 @@ import orderBy from "lodash/orderBy"; import { Circle } from "@/services/circle"; +import { useCourseSessionsStore } from "@/stores/courseSessions"; import { useLearningPathStore } from "@/stores/learningPath"; import type { Course, @@ -16,11 +17,13 @@ export interface ContinueData { has_no_progress: boolean; } -function getLastCompleted(courseId: number, completionData: CourseCompletion[]) { +function getLastCompleted(courseSlug: string, completionData: CourseCompletion[]) { + const courseSessionsStore = useCourseSessionsStore(); + const courseSession = courseSessionsStore.courseSessionForCourse(courseSlug); return orderBy(completionData, ["updated_at"], "desc").find((c: CourseCompletion) => { return ( c.completion_status === "success" && - c.course === courseId && + c.course_session === courseSession?.id && c.page_type === "learnpath.LearningContent" ); }); @@ -115,7 +118,7 @@ export class LearningPath implements WagtailLearningPath { this.nextLearningContent = undefined; const lastCompletedLearningContent = getLastCompleted( - this.course.id, + this.course.slug, completionData ); diff --git a/client/src/types.ts b/client/src/types.ts index 976daa6a..bb6c7ae2 100644 --- a/client/src/types.ts +++ b/client/src/types.ts @@ -184,7 +184,7 @@ export interface CourseCompletion { page_key: string; page_type: string; page_slug: string; - course: number; + course_session: number; completion_status: CourseCompletionStatus; additional_json_data: unknown; } diff --git a/client/src/utils/eventBus.ts b/client/src/utils/eventBus.ts index 25ff4fd9..32238197 100644 --- a/client/src/utils/eventBus.ts +++ b/client/src/utils/eventBus.ts @@ -1,6 +1,7 @@ import mitt from "mitt"; export type MittEvents = { + // FIXME: switchedCourseSession: number; };