Add drag reordering, exam deadlines, frozen shared quizzes, batched OCR and semantic search
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 33s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 33s
- Drag-to-reorder for class materials, folders, quiz questions and deck cards. Pointer-based so touch works, plus keyboard (arrows/Home/End) with screen-reader announcements. - Timed exams get a wall-clock deadline. The server refuses late answers, submits overdue exams with what was saved, and the countdown keeps running while the page is closed. - Shared quiz sessions keep a frozen copy of their questions and flag later owner edits. - Scanned PDFs are read in cached 8-page batches with real page numbers (pdf-lib), removing the 30 MB whole-file limit. Compatible providers now receive PDFs as file parts. - Semantic search: embeddings for OpenAI, Gemini, Ollama and compatible servers, background indexing into chunk_vectors (migration 2), hybrid keyword + vector ranking for search, the assistant and focused generation, and a Settings -> AI section. 181 tests pass locally and in the Docker test stage on Node 24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3046e46d1c
commit
ccdad9728b
39 changed files with 1772 additions and 121 deletions
|
|
@ -110,6 +110,11 @@ export interface RunnerProps {
|
|||
index: number;
|
||||
elapsedSec: number;
|
||||
timeLimitSec: number | null;
|
||||
/**
|
||||
* Fixed end time on this device's clock. When set, the countdown follows the wall clock
|
||||
* and keeps running while the page is hidden or closed. Without it the clock pauses.
|
||||
*/
|
||||
deadlineAt?: number | null;
|
||||
sataScoring: SataScoring;
|
||||
onAnswer: (questionId: string, selected: string[], checked: boolean) => void;
|
||||
onFlags: (flags: string[]) => void;
|
||||
|
|
@ -131,7 +136,6 @@ export function QuizRunner(p: RunnerProps) {
|
|||
const topRef = useRef<HTMLDivElement>(null);
|
||||
const tick = useLatest(p.onTick);
|
||||
const finish = useLatest(p.onFinish);
|
||||
const elapsedRef = useLatest(elapsed);
|
||||
const autoSubmitted = useRef(false);
|
||||
|
||||
const total = p.questions.length;
|
||||
|
|
@ -156,24 +160,36 @@ export function QuizRunner(p: RunnerProps) {
|
|||
}
|
||||
return n > 0 ? { n, points, percent: Math.round((points / n) * 100) } : null;
|
||||
}, [p.mode, p.questions, p.answers, p.sataScoring]);
|
||||
const remaining = p.timeLimitSec !== null ? Math.max(0, p.timeLimitSec - elapsed) : null;
|
||||
const [wallNow, setWallNow] = useState(() => Date.now());
|
||||
const deadline = p.deadlineAt && p.timeLimitSec !== null ? p.deadlineAt : null;
|
||||
const remaining = deadline !== null ? Math.max(0, Math.ceil((deadline - wallNow) / 1000)) : p.timeLimitSec !== null ? Math.max(0, p.timeLimitSec - elapsed) : null;
|
||||
// Time used: wall clock for deadline exams, otherwise the active-study clock.
|
||||
const clock = deadline !== null && p.timeLimitSec !== null ? Math.max(elapsed, p.timeLimitSec - (remaining ?? 0)) : elapsed;
|
||||
const clockRef = useLatest(clock);
|
||||
|
||||
// Session clock: pauses while the tab is hidden.
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setWallNow(Date.now());
|
||||
// The untimed/legacy clock pauses while the tab is hidden.
|
||||
if (document.visibilityState === 'visible') setElapsed((e) => e + 1);
|
||||
}, 1000);
|
||||
return () => clearInterval(timer);
|
||||
// Catch up immediately when returning to a deadline exam.
|
||||
const onVisible = () => document.visibilityState === 'visible' && setWallNow(Date.now());
|
||||
document.addEventListener('visibilitychange', onVisible);
|
||||
return () => {
|
||||
clearInterval(timer);
|
||||
document.removeEventListener('visibilitychange', onVisible);
|
||||
};
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (elapsed > 0 && elapsed % 10 === 0) tick.current?.(elapsed);
|
||||
}, [elapsed, tick]);
|
||||
if (elapsed > 0 && elapsed % 10 === 0) tick.current?.(clockRef.current);
|
||||
}, [elapsed, tick, clockRef]);
|
||||
useEffect(() => {
|
||||
if (remaining === 0 && !p.finishing && !autoSubmitted.current) {
|
||||
autoSubmitted.current = true;
|
||||
finish.current(elapsedRef.current);
|
||||
finish.current(clockRef.current);
|
||||
}
|
||||
}, [remaining, p.finishing, finish, elapsedRef]);
|
||||
}, [remaining, p.finishing, finish, clockRef]);
|
||||
useEffect(() => {
|
||||
topRef.current?.scrollIntoView({ block: 'start' });
|
||||
}, [index]);
|
||||
|
|
@ -197,7 +213,7 @@ export function QuizRunner(p: RunnerProps) {
|
|||
);
|
||||
if (!ok) return;
|
||||
}
|
||||
p.onFinish(elapsed);
|
||||
p.onFinish(clock);
|
||||
};
|
||||
|
||||
const primary = () => {
|
||||
|
|
@ -248,7 +264,7 @@ export function QuizRunner(p: RunnerProps) {
|
|||
)}
|
||||
<div className={cx('num flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[13px] font-medium', remaining !== null && remaining < 60 ? 'bg-bad-soft text-bad' : 'text-ink-2')} aria-label={remaining !== null ? 'Time remaining' : 'Time elapsed'}>
|
||||
<Clock className="size-3.5" />
|
||||
{formatDuration(remaining ?? elapsed)}
|
||||
{formatDuration(remaining ?? clock)}
|
||||
</div>
|
||||
<button type="button" onClick={() => setNavOpen(true)} className="num flex h-9 items-center gap-1.5 rounded-[9px] border border-line-strong bg-surface px-2.5 text-[13px] font-medium shadow-1 hover:border-ink-3" aria-label="Question navigator">
|
||||
<LayoutGrid className="size-3.5 text-ink-3" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue