fix(dashboard): show locked notice instead of teacher empty state on lessons (#760)
* fix(dashboard): show locked notice instead of teacher empty state on lessons Students viewing a locked or progression-blocked lesson were falling through to the teacher empty state with Get Started. Align lesson access checks with the shared getStudentContentLockReason helper used by exercises and the course layout, treat missing course content as inaccessible for students, and use org student role for sidebar lock blocking on the app host. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(dashboard): only show lesson lock notice when lock reason is known Address Greptile review: avoid defaulting to teacher_locked when the lesson is missing from the content tree, and wait for course/lesson state before dismissing the student loading spinner. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> --------- ]Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>
This commit is contained in:
co-authored by
Rotimi Best
parent
c9b7c79365
commit
9681770270
+5
-3
@@ -8,6 +8,7 @@
|
||||
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 { getStudentContentLockReason } from '$features/ai-assistant/utils/content-ask-ai-bar';
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
import { courseApi, lessonApi } from '$features/course/api';
|
||||
import { getOrderedNavigableContent, getContentRoute } from '$features/course/utils/content';
|
||||
@@ -69,8 +70,10 @@
|
||||
const showMarkComplete = $derived(!!lessonId && !exerciseId);
|
||||
|
||||
const currentLessonItem = $derived(lessonId ? lessonItems.find((l) => l.id === lessonId) : null);
|
||||
const isTeacherLocked = $derived($isOrgStudent && currentLessonItem && !(currentLessonItem.isUnlocked ?? false));
|
||||
const isProgressionLocked = $derived($isOrgStudent && currentLessonItem?.accessible === false && !isTeacherLocked);
|
||||
const contentLockReason = $derived(
|
||||
lessonId ? getStudentContentLockReason(courseApi.course, lessonId, ContentType.Lesson) : null
|
||||
);
|
||||
const isLessonLocked = $derived($isOrgStudent === true && contentLockReason !== null);
|
||||
const isVideoWatchLesson = $derived.by(() => {
|
||||
if (!lessonId) return false;
|
||||
|
||||
@@ -98,7 +101,6 @@
|
||||
|
||||
const watchVideosRequired = $derived(lessonApi.lesson?.watchProgress?.videosRequired ?? 0);
|
||||
const watchVideosComplete = $derived(lessonApi.lesson?.watchProgress?.videosComplete ?? 0);
|
||||
const isLessonLocked = $derived(isTeacherLocked || isProgressionLocked);
|
||||
const isVideoWatchComplete = $derived(isVideoWatchLesson && (lessonApi.lesson?.watchProgress?.isComplete ?? false));
|
||||
const showVideoWatchCompleteState = $derived(isVideoWatchComplete || (isVideoWatchLesson && isLessonComplete));
|
||||
const isMarkCompleteDisabled = $derived(
|
||||
|
||||
Reference in New Issue
Block a user