fix(dashboard): use learner view for lesson lock empty states (#764)
Lock checks gated on isOrgStudent missed org-site students where isStudentExperience is true but org role may be unset. Introduce isCourseLearnerView (student experience OR org student) and mirror the exercise page branch structure so locked lessons always show StudentContentLockedNotice instead of the teacher empty state. Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
co-authored by
Cursor Agent
Rotimi Best
parent
7a867dad45
commit
3ef286ed39
+13
-3
@@ -7,7 +7,7 @@
|
||||
import { Button } from '@cio/ui/base/button';
|
||||
import * as Tooltip from '@cio/ui/base/tooltip';
|
||||
import { PercentRingProgress } from '@cio/ui/custom/percent-ring-progress';
|
||||
import { isOrgStudent } from '$lib/utils/store/app';
|
||||
import { isCourseLearnerView } from '$lib/utils/store/app';
|
||||
import { getStudentContentLockReason } from '$features/ai-assistant/utils/content-ask-ai-bar';
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
import { courseApi, lessonApi } from '$features/course/api';
|
||||
@@ -52,6 +52,16 @@
|
||||
|
||||
function goToContent(target: CourseContentItem | null) {
|
||||
if (!target) return;
|
||||
|
||||
if ($isCourseLearnerView) {
|
||||
const targetType = target.type === ContentType.Lesson ? ContentType.Lesson : ContentType.Exercise;
|
||||
const lockReason = getStudentContentLockReason(courseApi.course, target.id, targetType);
|
||||
|
||||
if (lockReason) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const courseIdResolved = courseApi.course?.id;
|
||||
if (!courseIdResolved) return;
|
||||
const path = getContentRoute(courseIdResolved, target);
|
||||
@@ -73,7 +83,7 @@
|
||||
const contentLockReason = $derived(
|
||||
lessonId ? getStudentContentLockReason(courseApi.course, lessonId, ContentType.Lesson) : null
|
||||
);
|
||||
const isLessonLocked = $derived($isOrgStudent === true && contentLockReason !== null);
|
||||
const isLessonLocked = $derived($isCourseLearnerView && contentLockReason !== null);
|
||||
const isVideoWatchLesson = $derived.by(() => {
|
||||
if (!lessonId) return false;
|
||||
|
||||
@@ -107,7 +117,7 @@
|
||||
isMarkingComplete || isLessonLocked || isLessonComplete || isVideoWatchLesson
|
||||
);
|
||||
const showWatchProgress = $derived(
|
||||
!!lessonId && $isOrgStudent && isVideoWatchLesson && !showVideoWatchCompleteState && !isLessonLocked
|
||||
!!lessonId && $isCourseLearnerView && isVideoWatchLesson && !showVideoWatchCompleteState && !isLessonLocked
|
||||
);
|
||||
|
||||
const watchProgressTooltip = $derived(
|
||||
|
||||
+3
-4
@@ -14,7 +14,7 @@
|
||||
import { IconButton } from '@cio/ui/custom/icon-button';
|
||||
import { RadioIcon } from '@cio/ui/custom/moving-icons';
|
||||
import CourseContentIcon from '$features/course/components/course-content-icon.svelte';
|
||||
import { isOrgStudent } from '$lib/utils/store/app';
|
||||
import { isCourseLearnerView } from '$lib/utils/store/app';
|
||||
|
||||
interface Props {
|
||||
path: string;
|
||||
@@ -99,7 +99,7 @@
|
||||
{#snippet child({ props })}
|
||||
{@const isContentLocked = (contentItem.isUnlocked ?? true) === false}
|
||||
{@const isLockedForStudent =
|
||||
$isOrgStudent === true && (isContentLocked || contentItem.accessible === false)}
|
||||
$isCourseLearnerView && (isContentLocked || contentItem.accessible === false)}
|
||||
<a
|
||||
href={resolve(getContentRoute(id, contentItem), {})}
|
||||
aria-disabled={isLockedForStudent}
|
||||
@@ -151,8 +151,7 @@
|
||||
<Sidebar.MenuSubButton isActive={(path || page.url.pathname).includes(contentItem.id)}>
|
||||
{#snippet child({ props })}
|
||||
{@const isContentLocked = (contentItem.isUnlocked ?? true) === false}
|
||||
{@const isLockedForStudent =
|
||||
$isOrgStudent === true && (isContentLocked || contentItem.accessible === false)}
|
||||
{@const isLockedForStudent = $isCourseLearnerView && (isContentLocked || contentItem.accessible === false)}
|
||||
<a
|
||||
href={resolve(getContentRoute(id, contentItem), {})}
|
||||
aria-disabled={isLockedForStudent}
|
||||
|
||||
Reference in New Issue
Block a user