mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -223,19 +223,32 @@ export default function ModifyQuiz() {
|
||||
const headerRef = useRef(null);
|
||||
const initialSnapshot = useRef(null);
|
||||
|
||||
const breadcrumbItems = [
|
||||
{ label: "Home", icon: <House className="size-4" />, to: "/admin" },
|
||||
{ label: "Courses", to: "/admin/courses" },
|
||||
{ label: course?.title ?? "…", to: `/admin/courses/${courseId}` },
|
||||
{ label: unit?.title ?? "…", to: `/admin/courses/${courseId}/units/${unitId}` },
|
||||
{ label: "Quiz" },
|
||||
];
|
||||
// Junction revamp — this builder runs course-scoped AND from the standalone
|
||||
// Unit Library (/admin/units/:unitId/quiz/edit, no :courseId param).
|
||||
const scopeBase = courseId
|
||||
? `/admin/courses/${courseId}/units/${unitId}`
|
||||
: `/admin/units/${unitId}`;
|
||||
|
||||
const breadcrumbItems = courseId
|
||||
? [
|
||||
{ label: "Home", icon: <House className="size-4" />, to: "/admin" },
|
||||
{ label: "Courses", to: "/admin/courses" },
|
||||
{ label: course?.title ?? "…", to: `/admin/courses/${courseId}` },
|
||||
{ label: unit?.title ?? "…", to: `/admin/courses/${courseId}/units/${unitId}` },
|
||||
{ label: "Quiz" },
|
||||
]
|
||||
: [
|
||||
{ label: "Home", icon: <House className="size-4" />, to: "/admin" },
|
||||
{ label: "Units Library", to: "/admin/units" },
|
||||
{ label: unit?.title ?? "…", to: `/admin/units/${unitId}/view` },
|
||||
{ label: "Quiz" },
|
||||
];
|
||||
|
||||
// ── Fetch — silently treat 404 as "no quiz yet" (create mode) ─────────────
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const { data } = await api.get(`/admin/courses/${courseId}/units/${unitId}/quiz`);
|
||||
const { data } = await api.get(`${scopeBase}/quiz`);
|
||||
const result = data?.data?.data ?? null;
|
||||
setLocalQuiz(result);
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user