diff --git a/apps/dashboard/src/lib/components/Org/Pathway/api.ts b/apps/dashboard/src/lib/components/Org/Pathway/api.ts
index f43fcf4a2..a5ebe2261 100644
--- a/apps/dashboard/src/lib/components/Org/Pathway/api.ts
+++ b/apps/dashboard/src/lib/components/Org/Pathway/api.ts
@@ -61,6 +61,7 @@ export async function fetchPathways(profileId: string | undefined, orgId: string
}
// Step 2: Fetch courses for each pathway
+ console.log();
const pathwayIds = allPathways.map((pathway: any) => pathway.id);
const { data: allCourses, error: courseError } = await supabase
@@ -103,6 +104,7 @@ export async function fetchPathways(profileId: string | undefined, orgId: string
// Step 3: Attach courses to their respective pathways and rename pathway_course to courses
const pathwaysWithCourses = allPathways.map((pathway: any) => {
const courses = allCourses.filter((course: any) => course.pathway_id === pathway.id);
+ console.log('pathwaywthcourse', courses);
return {
...pathway,
pathway_course: courses // Rename pathway_course to courses
diff --git a/apps/dashboard/src/lib/components/Pathways/components/Certificate/StudentCertificate/Index.svelte b/apps/dashboard/src/lib/components/Pathways/components/Certificate/StudentCertificate/Index.svelte
index ae51dd4f6..54f58fb8f 100644
--- a/apps/dashboard/src/lib/components/Pathways/components/Certificate/StudentCertificate/Index.svelte
+++ b/apps/dashboard/src/lib/components/Pathways/components/Certificate/StudentCertificate/Index.svelte
@@ -2,11 +2,19 @@
import { pathway } from '$lib/components/Pathways/store';
import UnlockedCertificate from './UnlockedCertificate.svelte';
import LockedCertificate from './LockedCertificate.svelte';
+ import { getPathwayCompletedCoursesLength } from '$lib/utils/functions/pathway';
+
+ const getIsPathwayComplete = () => {
+ const completedCourses = getPathwayCompletedCoursesLength($pathway);
+ return completedCourses === $pathway.pathway_course.length;
+ };
+
+ $: isPathwayComplete = getIsPathwayComplete();
{#if $pathway.is_certificate_downloadable}
-
+
{:else}
{/if}
diff --git a/apps/dashboard/src/lib/components/Pathways/components/Certificate/StudentCertificate/UnlockedCertificate.svelte b/apps/dashboard/src/lib/components/Pathways/components/Certificate/StudentCertificate/UnlockedCertificate.svelte
index 2c8d5fb0a..674c4e0cb 100644
--- a/apps/dashboard/src/lib/components/Pathways/components/Certificate/StudentCertificate/UnlockedCertificate.svelte
+++ b/apps/dashboard/src/lib/components/Pathways/components/Certificate/StudentCertificate/UnlockedCertificate.svelte
@@ -17,9 +17,10 @@
import type { ProfilePathwayProgress } from '$lib/utils/types';
import { fetchProfilePathwayProgress } from '$lib/utils/services/pathways';
+ export let isPathwayComplete = false;
+
let isLoading = false;
let showCourses = true;
- let isPathwayComplete = true;
let progress: ProfilePathwayProgress | undefined;
function toggleCourse() {
diff --git a/apps/dashboard/src/lib/utils/functions/pathway.ts b/apps/dashboard/src/lib/utils/functions/pathway.ts
index c8c142357..f21293a49 100644
--- a/apps/dashboard/src/lib/utils/functions/pathway.ts
+++ b/apps/dashboard/src/lib/utils/functions/pathway.ts
@@ -40,6 +40,11 @@ export const getPathwayCompletedCoursesLength = (pathway: Pathway) => {
return completedCourses;
};
+export const getIsPathwayComplete = (pathway: Pathway) => {
+ const completedCourses = getPathwayCompletedCoursesLength(pathway);
+ return completedCourses === pathway.pathway_course.length;
+};
+
export const courseProgress = (lessons) => {
const totalLesson = lessons.length;
const completedLesson = lessons.filter((lesson) => lesson.is_complete).length;
diff --git a/apps/dashboard/src/lib/utils/services/pathways/index.ts b/apps/dashboard/src/lib/utils/services/pathways/index.ts
index 86501947e..2cf78490a 100644
--- a/apps/dashboard/src/lib/utils/services/pathways/index.ts
+++ b/apps/dashboard/src/lib/utils/services/pathways/index.ts
@@ -103,7 +103,7 @@ export async function fetchPathway(pathwayId?: Pathway['id'], slug?: Pathway['sl
};
}
-export async function updatePathway (
+export async function updatePathway(
pathwayId: Pathway['id'],
avatar: string | undefined,
pathway: Partial
@@ -194,30 +194,3 @@ export async function uploadAvatar(pathwayId: string, avatar: string) {
return logo;
}
-
-export async function updatePathways(
- pathwayId: Pathway['id'],
- avatar: string | undefined,
- pathway: Partial
-) {
- if (avatar && pathwayId) {
- const filename = `course/${pathwayId + Date.now()}.webp`;
-
- const { data } = await supabase.storage.from('avatars').upload(filename, avatar, {
- cacheControl: '3600',
- upsert: false
- });
-
- if (data) {
- const { data: response } = supabase.storage.from('avatars').getPublicUrl(filename);
-
- if (!response.publicUrl) return;
-
- pathway.logo = response.publicUrl;
- }
- }
-
- await supabase.from('pathway').update(pathway).match({ id: pathwayId });
-
- return pathway.logo;
-}
\ No newline at end of file
diff --git a/apps/dashboard/src/routes/lms/+page.svelte b/apps/dashboard/src/routes/lms/+page.svelte
index ae5f6ea7b..787e69414 100644
--- a/apps/dashboard/src/routes/lms/+page.svelte
+++ b/apps/dashboard/src/routes/lms/+page.svelte
@@ -47,7 +47,6 @@
const allResults = [...pathwaysWithFlag, ...coursesWithFlag];
- console.log('all result', allResults);
lmsCourses.set(allResults);
hasFetched = true;
} catch (error) {
@@ -56,6 +55,7 @@
}
}
+ //TODO: we should consider pathway courses too
function calcTotalProgress(courses: LMSCourse[] | any) {
totalCompleted = courses.reduce((acc, cur) => acc + (cur.progress_rate || 0), 0);
totalLessons = courses.reduce((acc, cur) => acc + (cur.total_lessons || 0), 0);
diff --git a/apps/dashboard/src/routes/lms/mylearning/+page.svelte b/apps/dashboard/src/routes/lms/mylearning/+page.svelte
index 6ade12bf9..89960b377 100644
--- a/apps/dashboard/src/routes/lms/mylearning/+page.svelte
+++ b/apps/dashboard/src/routes/lms/mylearning/+page.svelte
@@ -12,7 +12,7 @@
import type { LMSCourse } from '$lib/components/LMS/store';
import { fetchPathways } from '$lib/components/Org/Pathway/api';
import { courseMetaDeta } from '$lib/components/Courses/store';
- import { getPathwayCompletedCoursesLength } from '$lib/utils/functions/pathway';
+ import { getIsPathwayComplete } from '$lib/utils/functions/pathway';
let hasFetched = false;
let selectedId = '0';
@@ -90,19 +90,14 @@
if (currentTab === '1') {
filteredCoursesInProgress = filteredCourses.filter((course) => {
if (course.isPathway) {
- const incompleteCourses = course.pathway_course.filter((pathwayCourse) => {
- const lessons = pathwayCourse.course.lesson;
- return lessons.length > 0 && !lessons.every((lesson) => lesson.is_complete);
- });
- return incompleteCourses.length > 0;
+ return getIsPathwayComplete(course) == false;
}
return course.total_lessons !== course.progress_rate;
});
} else if (currentTab === '2') {
filteredCoursesCompleted = filteredCourses.filter((course) => {
if (course.isPathway) {
- const completedCourses = getPathwayCompletedCoursesLength(course);
- return completedCourses === course.pathway_course.length;
+ return getIsPathwayComplete(course);
}
return course.total_lessons === course.progress_rate;
});
@@ -124,7 +119,6 @@
value: '2'
}
];
- // $: currentTab = tabs[0].value;
diff --git a/apps/dashboard/src/routes/pathways/[id]/settings/+page.svelte b/apps/dashboard/src/routes/pathways/[id]/settings/+page.svelte
index fb3e64c3e..8990b8653 100644
--- a/apps/dashboard/src/routes/pathways/[id]/settings/+page.svelte
+++ b/apps/dashboard/src/routes/pathways/[id]/settings/+page.svelte
@@ -65,24 +65,17 @@
isSaving = true;
// try catch block to save to supabase
try {
- const {
- title,
- logo,
- description,
- prerequisite,
- is_published,
- lms_certificate,
- courses_certificate
- } = $pathwaySettings;
+ const { title, logo, description, prerequisite, is_published, lms_certificate } =
+ $pathwaySettings;
- await updatePathways($pathway.id, avatar, {
+ await updatePathway($pathway.id, avatar, {
title: title,
logo: logo,
description: description,
prerequisite: prerequisite,
is_published: is_published,
lms_certificate: lms_certificate,
- courses_certificate: courses_certificate,
+
slug: $pathway.slug
});
@@ -90,7 +83,6 @@
$pathway.description = description;
$pathway.logo = logo;
$pathway.is_published = is_published;
- $pathway.courses_certificate = courses_certificate;
$pathway.prerequisite = prerequisite;
$pathway.lms_certificate = lms_certificate;
@@ -273,7 +265,7 @@
{$t('pathway.pages.settings.disabled')}
-
+