}
title="Fill this class with material"
action={
<>
} onClick={() => fileRef.current?.click()}>
Upload class materials
} onClick={() => setImportOpen(true)}>
Import
} onClick={() => setNewKind({ kind: 'quiz' })}>
New quiz
} onClick={() => setNewKind({ kind: 'deck' })}>
New deck
>
}
>
Drop lecture slides, PDFs or notes anywhere on this page, import existing quizzes and flashcards, or write your own.
{currentExam && !searching ? (
}
action={
<>
} onClick={() => fileRef.current?.click()}>
Upload class materials
>
}
>
Add this {groupLabel.toLowerCase()}'s slides and notes, then generate quizzes and flashcards from them. Use Move on anything already in the class to bring it here.
) : (
}>
{query ? `No ${filter === 'all' ? 'items' : filter === 'deck' ? 'decks' : `${filter}s`} match "${query}".` : 'Try a different filter, or add something new.'}
)}
);
}
function PasteTextDialog({ open, onClose, classId, folderId }: { open: boolean; onClose: () => void; classId: string; folderId?: string | null }) {
const refresh = useRefresh();
const [title, setTitle] = useState('');
const [text, setText] = useState('');
const [busy, setBusy] = useState(false);
useEffect(() => {
if (open) {
setTitle('');
setText('');
}
}, [open]);
const save = async () => {
setBusy(true);
try {
await api.post('/api/documents/text', { classId, folderId: folderId ?? null, title, text });
await refresh();
toast.success('Added as a document');
onClose();
} catch (e) {
toast.error(errorMessage(e));
} finally {
setBusy(false);
}
};
return (
);
}
/* ------------------------------ exams ------------------------------ */
/**
* The second level of a class: one tab per exam (or unit, module… as the class calls them),
* plus "All" and, when anything is outside every exam, "Not in an exam".
*/
function ExamTabs({
exams,
items,
looseCount,
view,
label,
onView,
onNew,
onRename,
onShare,
onDelete,
onReorder,
}: {
exams: Folder[];
items: Item[];
looseCount: number;
view: string;
label: string;
onView: (v: string) => void;
onNew: () => void;
onRename: (f: Folder) => void;
onShare: (f: Folder) => void;
onDelete: (f: Folder) => void;
onReorder: (ids: string[]) => void;
}) {
const noun = label.toLowerCase();
const count = (id: string) => items.filter((i) => i.folderId === id).length;
const move = (index: number, by: number) => {
const ids = exams.map((f) => f.id);
const [id] = ids.splice(index, 1);
ids.splice(Math.max(0, Math.min(ids.length, index + by)), 0, id);
onReorder(ids);
};
if (exams.length === 0) {
return (
Divide this class into {noun}s so each keeps its own class materials, quizzes and flashcards, and generating uses only that {noun}'s material.
} onClick={onNew}>
New {noun}