"use client"; /** * /quizzes — every quiz, with how many people have started and finished it. */ import { useEffect, useState } from "react"; import Link from "next/link"; import { toast } from "sonner"; import { quizzes, AdminError, type Quiz } from "@/lib/api"; import { Button } from "@/components/ui/button"; import { Table, THead, TH, TR, TD } from "@/components/ui/table"; import { Can } from "@/components/staff-context"; import { fmtDate } from "@/lib/utils"; import { KIND_LABEL } from "./labels"; import { Clamp } from "@/components/ui/clamp"; export default function QuizzesPage() { const [list, setList] = useState(null); useEffect(() => { quizzes .list() .then(setList) .catch((err) => { toast.error( err instanceof AdminError ? err.message : "Could not load quizzes", ); setList([]); }); }, []); return (

Quizzes

Quizzes on book chapters, lectures and conversations — or on their own. A published quiz shows a button on its page and appears in the app's quiz list.

{list === null ? (

Loading…

) : list.length === 0 ? (

No quizzes yet.

) : ( {list.map((q) => ( ))}
Quiz Attached to Questions Taken Status
{q.title}

Updated {fmtDate(q.updated_at)}

{KIND_LABEL[q.target_kind]}

{q.target_title && ( {q.target_title} )}
{q.question_count} {q.completed_count ?? 0} finished {" "} / {q.attempt_count ?? 0} started {q.published_at ? ( Published ) : ( Draft )}
)}
); }