mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
added: missing quiz notice per unit inside Course
This commit is contained in:
@@ -336,9 +336,13 @@ const UnitList = () => {
|
|||||||
|
|
||||||
const resetCompletion = () => setSelectedCompletion(false);
|
const resetCompletion = () => setSelectedCompletion(false);
|
||||||
|
|
||||||
// ── No-assessment notice — shown once per course visit, informational only ──
|
// ── Course-readiness notices — shown once per course visit, informational only ──
|
||||||
// Gated behind the "Course notices" toggle in Account Settings.
|
// Gated behind the "Course notices" toggle in Account Settings. Sequenced so at
|
||||||
|
// most one is open at a time: missing-quiz notice (unit-level) takes priority,
|
||||||
|
// then no-assessment (course-level) once that one is dismissed.
|
||||||
|
const [missingQuizDialogOpen, setMissingQuizDialogOpen] = useState(false);
|
||||||
const [noAssessmentDialogOpen, setNoAssessmentDialogOpen] = useState(false);
|
const [noAssessmentDialogOpen, setNoAssessmentDialogOpen] = useState(false);
|
||||||
|
const missingQuizNoticeShown = useRef(false);
|
||||||
const noAssessmentNoticeShown = useRef(false);
|
const noAssessmentNoticeShown = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -346,18 +350,27 @@ const UnitList = () => {
|
|||||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
missingQuizNoticeShown.current = false;
|
||||||
noAssessmentNoticeShown.current = false;
|
noAssessmentNoticeShown.current = false;
|
||||||
}, [courseId]);
|
}, [courseId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const shouldShow =
|
const noticesEnabled =
|
||||||
course && !courseBlocked && course.duration_seconds &&
|
course && !courseBlocked && course.duration_seconds &&
|
||||||
!course.assessment && !noAssessmentNoticeShown.current &&
|
|
||||||
profile && (profile.personal_info?.show_course_notices ?? true);
|
profile && (profile.personal_info?.show_course_notices ?? true);
|
||||||
if (!shouldShow) return;
|
if (!noticesEnabled) return;
|
||||||
noAssessmentNoticeShown.current = true;
|
|
||||||
setNoAssessmentDialogOpen(true);
|
if (!missingQuizNoticeShown.current && (course.units ?? []).some((u) => !u.quiz)) {
|
||||||
}, [course, courseBlocked, profile]);
|
missingQuizNoticeShown.current = true;
|
||||||
|
setMissingQuizDialogOpen(true);
|
||||||
|
return; // let the assessment notice wait until this one is dismissed
|
||||||
|
}
|
||||||
|
if (missingQuizDialogOpen) return;
|
||||||
|
if (!noAssessmentNoticeShown.current && !course.assessment) {
|
||||||
|
noAssessmentNoticeShown.current = true;
|
||||||
|
setNoAssessmentDialogOpen(true);
|
||||||
|
}
|
||||||
|
}, [course, courseBlocked, profile, missingQuizDialogOpen]);
|
||||||
|
|
||||||
// ── Session guard — block navigation while a quiz/assessment is in progress ─
|
// ── Session guard — block navigation while a quiz/assessment is in progress ─
|
||||||
const quizActiveRef = useRef(false); // sync check inside handlers
|
const quizActiveRef = useRef(false); // sync check inside handlers
|
||||||
@@ -847,6 +860,14 @@ const UnitList = () => {
|
|||||||
</div>
|
</div>
|
||||||
</ResponsiveModal>
|
</ResponsiveModal>
|
||||||
|
|
||||||
|
{/* ── Missing-quiz notice — informational, shown once per course visit ── */}
|
||||||
|
<InfoDialog
|
||||||
|
open={missingQuizDialogOpen}
|
||||||
|
onOpenChange={setMissingQuizDialogOpen}
|
||||||
|
title="Quizzes Coming Soon"
|
||||||
|
description="Some units in this course don't have a quiz yet — we are currently working on it. You may proceed with your studies. Enjoy!"
|
||||||
|
/>
|
||||||
|
|
||||||
{/* ── No-assessment notice — informational, shown once per course visit ── */}
|
{/* ── No-assessment notice — informational, shown once per course visit ── */}
|
||||||
<InfoDialog
|
<InfoDialog
|
||||||
open={noAssessmentDialogOpen}
|
open={noAssessmentDialogOpen}
|
||||||
|
|||||||
Reference in New Issue
Block a user