diff --git a/apps/dashboard/src/lib/features/course/components/sidebar/course-sidebar-navigation.svelte b/apps/dashboard/src/lib/features/course/components/sidebar/course-sidebar-navigation.svelte index 7c2615c6..ec99a611 100644 --- a/apps/dashboard/src/lib/features/course/components/sidebar/course-sidebar-navigation.svelte +++ b/apps/dashboard/src/lib/features/course/components/sidebar/course-sidebar-navigation.svelte @@ -253,18 +253,20 @@ {item.title}
- { - event.preventDefault(); - event.stopPropagation(); - openContentModal(id); - }} - > - - + {#if !isStudent} + { + event.preventDefault(); + event.stopPropagation(); + openContentModal(id); + }} + > + + + {/if} {#if showContentCount} {/if} diff --git a/apps/dashboard/src/lib/features/course/pages/lesson.svelte b/apps/dashboard/src/lib/features/course/pages/lesson.svelte index 5be7ffd3..6a74230c 100644 --- a/apps/dashboard/src/lib/features/course/pages/lesson.svelte +++ b/apps/dashboard/src/lib/features/course/pages/lesson.svelte @@ -2,6 +2,7 @@ import { browser } from '$app/environment'; import { page } from '$app/stores'; import { goto } from '$app/navigation'; + import { SvelteURLSearchParams } from 'svelte/reactivity'; import { resolve } from '$app/paths'; import { untrack } from 'svelte'; import isEmpty from 'lodash/isEmpty'; @@ -65,18 +66,16 @@ const lessonTitle = $derived(lessonApi.lesson?.title || 'Lesson'); const isLessonUnlocked = $derived(lessonApi.lesson?.isUnlocked ?? false); - $inspect(isLessonUnlocked); - $inspect($globalStore.isStudent); function setModeQueryParam(value: (typeof MODES)[keyof typeof MODES]) { - const params = new URLSearchParams($page.url.searchParams); + const params = new SvelteURLSearchParams($page.url.searchParams); params.set('mode', value); - goto(`${$page.url.pathname}?${params.toString()}`, { replaceState: false }); + goto(resolve(`${$page.url.pathname}?${params.toString()}`, {}), { replaceState: false }); } function setTabQueryParam(value: string) { - const params = new URLSearchParams($page.url.searchParams); + const params = new SvelteURLSearchParams($page.url.searchParams); params.set('tab', value); - goto(`${$page.url.pathname}?${params.toString()}`, { replaceState: false }); + goto(resolve(`${$page.url.pathname}?${params.toString()}`, {}), { replaceState: false }); } function toggleMode() { @@ -117,7 +116,7 @@ if (tab.value === 1) { tab.badgeValue = isHtmlValueEmpty(content) ? 0 : 1; } else if (tab.value === 2) { - tab.badgeValue = !!slideUrl ? 1 : 0; + tab.badgeValue = slideUrl ? 1 : 0; } else if (tab.value === 3) { tab.badgeValue = !isEmpty(videos) ? videos.length : 0; } else if (tab.value === 4) { @@ -372,7 +371,7 @@ > - {#each tabs as tab} + {#each tabs as tab (tab.value)} {#if tab.icon} @@ -413,7 +412,7 @@ {:else if lessonApi.lesson && !isMaterialsEmpty} {#key lessonId}
- {#each viewModeComponents as Component} + {#each viewModeComponents as Component, index (index)} {/each} @@ -437,9 +436,11 @@ variant="page" class="text-center" > - + {#if !$globalStore.isStudent} + + {/if} {/if}
diff --git a/apps/dashboard/src/lib/utils/store/app.ts b/apps/dashboard/src/lib/utils/store/app.ts index 49d6bc23..3045c5f2 100644 --- a/apps/dashboard/src/lib/utils/store/app.ts +++ b/apps/dashboard/src/lib/utils/store/app.ts @@ -1,4 +1,5 @@ import { derived, writable } from 'svelte/store'; + import { PUBLIC_IS_SELFHOSTED } from '$env/static/public'; import { currentOrgPath } from './org'; @@ -17,6 +18,12 @@ export const globalStore = writable<{ /** * Single source of truth: is this a student experience? * Cloud: orgSite is always student. Self-hosted: check role. + * + * why are we not using isOrgStudent from org store? + * because this is derived from the currentOrg which returns null if no org OR boolean if org is present. Once org data is set, we then update globalStore.isStudent to the same value. + * + * why are we not using only globalStore.isStudent for this? + * because in the cloud instance, when a teacher logs into the lms aka org site, they need to be treated as a student so they see what the student sees. */ export const isStudentExperience = derived(globalStore, ($gs) => { const isCloud = PUBLIC_IS_SELFHOSTED !== 'true'; diff --git a/apps/dashboard/src/routes/course/[slug]/enroll/+page.svelte b/apps/dashboard/src/routes/course/[slug]/enroll/+page.svelte index 83da4a48..0088856c 100644 --- a/apps/dashboard/src/routes/course/[slug]/enroll/+page.svelte +++ b/apps/dashboard/src/routes/course/[slug]/enroll/+page.svelte @@ -84,7 +84,8 @@ already_joined: result.data.alreadyJoined }); - goto(result.data.redirectTo || '/lms'); + // need to force page reload to avoid cache issues + window.location.href = result.data.redirectTo || '/lms'; } finally { loading = false; } diff --git a/apps/dashboard/src/routes/courses/[id]/certificates/+page.svelte b/apps/dashboard/src/routes/courses/[id]/certificates/+page.svelte index 098f87b1..bb11a01e 100644 --- a/apps/dashboard/src/routes/courses/[id]/certificates/+page.svelte +++ b/apps/dashboard/src/routes/courses/[id]/certificates/+page.svelte @@ -4,7 +4,7 @@ import { t } from '$lib/utils/functions/translations'; - +