fix 3 test case FAIL issue

This commit is contained in:
rgrgogu
2026-07-23 16:16:17 +08:00
parent ed500509eb
commit 9c560aa45c
2 changed files with 7 additions and 1 deletions
@@ -5,6 +5,7 @@ import { ArrowLeft, House, Plus, Save, ClipboardList, ChevronUp, ChevronDown, Al
import { toast } from "sonner"; import { toast } from "sonner";
import { useCourses } from "@/contexts/AdminCoursesContext"; import { useCourses } from "@/contexts/AdminCoursesContext";
import { useAuth } from "@/contexts/AuthContext"; import { useAuth } from "@/contexts/AuthContext";
import { useUnsavedChangesGuard } from "@/hooks/useUnsavedChangesGuard";
import { PageMeta } from "@/contexts/MetadataContext"; import { PageMeta } from "@/contexts/MetadataContext";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
@@ -421,6 +422,8 @@ export default function CourseAssessment() {
? questions.length > 0 ? questions.length > 0
: snapAssessment({ title, passingScore, timeLimit, isRequired, maxQuestions, maxAttempts, cooldownHours, shuffleQuestions, questions }) !== initialSnapshot.current; : snapAssessment({ title, passingScore, timeLimit, isRequired, maxQuestions, maxAttempts, cooldownHours, shuffleQuestions, questions }) !== initialSnapshot.current;
const { dialog: unsavedChangesDialog } = useUnsavedChangesGuard(isDirty);
// ── Auto-save unsaved changes to localStorage as a draft ─────────────────── // ── Auto-save unsaved changes to localStorage as a draft ───────────────────
useEffect(() => { useEffect(() => {
if (initializing) return; if (initializing) return;
@@ -832,6 +835,8 @@ export default function CourseAssessment() {
</div> </div>
</div> </div>
)} )}
{unsavedChangesDialog}
</div> </div>
); );
} }
+2 -1
View File
@@ -1,5 +1,6 @@
// ─── utils/exportToExcel.js ─────────────────────────────────────────────────── // ─── utils/exportToExcel.js ───────────────────────────────────────────────────
import XLSX from "xlsx-js-style"; import XLSX from "xlsx-js-style";
import { toast } from "sonner";
import { BOOLEAN_FIELD_LABELS } from "@/utils/table.util"; import { BOOLEAN_FIELD_LABELS } from "@/utils/table.util";
import { isIsoDateTimeString, fmtDateTimeCompact, fmtDateTimeWithOffset } from "@/utils/datetime.util"; import { isIsoDateTimeString, fmtDateTimeCompact, fmtDateTimeWithOffset } from "@/utils/datetime.util";
@@ -234,7 +235,7 @@ export function exportToExcel({
footerNote = "Confidential – For authorized personnel only.", footerNote = "Confidential – For authorized personnel only.",
} = {}) { } = {}) {
if (!data.length || !columns.length) { if (!data.length || !columns.length) {
console.warn("exportToExcel: no data or columns to export."); toast("Nothing to export — the table has no rows.");
return; return;
} }