Address first round of feedback
- Flashcards: whole card flips on click (both sides), 3D turn, swipe-away on grading, streak chip and flame bursts, bigger cards on desktop, arrow keys for everything - Review and browse keep the sidebar on desktop - Quizzes: live practice score, partial-credit explanation, time limit for shared exams - Class page: items grouped by type inside each folder - Import: copyable, editable instructions for outside chatbots - Assistant: reads notes and links to library items Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
c59591ccb9
commit
aed14cd04f
13 changed files with 769 additions and 216 deletions
|
|
@ -71,13 +71,30 @@ function OptionList({
|
|||
);
|
||||
}
|
||||
|
||||
function Verdict({ score }: { score: number }) {
|
||||
/** "2 of 3" style credit for a select-all question, so partial credit is never a mystery. */
|
||||
function creditDetail(question: SnapshotQuestion, selected: string[], sata: SataScoring): string | null {
|
||||
if (question.type !== 'multi') return null;
|
||||
const correctIds = question.options.filter((o) => o.correct).map((o) => o.id);
|
||||
const right = selected.filter((id) => correctIds.includes(id)).length;
|
||||
const wrong = selected.length - right;
|
||||
if (right === correctIds.length && wrong === 0) return null;
|
||||
if (sata === 'strict') return 'All-or-nothing scoring is on, so every correct choice (and no others) is needed for credit.';
|
||||
const earned = Math.max(0, right - wrong);
|
||||
return `Partial credit: ${right} correct ${right === 1 ? 'choice' : 'choices'}${wrong > 0 ? ` minus ${wrong} incorrect` : ''} = ${earned} of ${correctIds.length} ${correctIds.length === 1 ? 'point' : 'points'} for this question.`;
|
||||
}
|
||||
|
||||
const fmtPoints = (n: number) => (Number.isInteger(n) ? String(n) : n.toFixed(1));
|
||||
|
||||
function Verdict({ score, detail }: { score: number; detail?: string | null }) {
|
||||
const full = isFullyCorrect(score);
|
||||
const partial = !full && score > 0;
|
||||
return (
|
||||
<div className={cx('flex items-center gap-2 text-[15px] font-semibold', full ? 'text-good' : partial ? 'text-warn' : 'text-bad')} role="status">
|
||||
{full ? <CircleCheck className="size-5" /> : <CircleX className="size-5" />}
|
||||
{full ? 'Correct' : partial ? `Partly correct (${Math.round(score * 100)}%)` : 'Incorrect'}
|
||||
<div role="status">
|
||||
<div className={cx('flex items-center gap-2 text-[15px] font-semibold', full ? 'text-good' : partial ? 'text-warn' : 'text-bad')}>
|
||||
{full ? <CircleCheck className="size-5" /> : <CircleX className="size-5" />}
|
||||
{full ? 'Correct' : partial ? `Partly correct (${Math.round(score * 100)}%)` : 'Incorrect'}
|
||||
</div>
|
||||
{detail && <p className="mt-1 text-[13px] text-ink-2">{detail}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -125,6 +142,19 @@ export function QuizRunner(p: RunnerProps) {
|
|||
const answeredCount = p.questions.filter((q) => (p.mode === 'practice' ? p.answers[q.id]?.checked : (p.answers[q.id]?.selected.length ?? 0) > 0)).length;
|
||||
const flagged = p.flags.includes(question.id);
|
||||
const isLast = index === total - 1;
|
||||
// Running score for practice mode (select-all questions can earn part of a point).
|
||||
const live = useMemo(() => {
|
||||
if (p.mode !== 'practice') return null;
|
||||
let n = 0;
|
||||
let points = 0;
|
||||
for (const q of p.questions) {
|
||||
const a = p.answers[q.id];
|
||||
if (!a?.checked) continue;
|
||||
n += 1;
|
||||
points += scoreQuestion(q, a.selected, p.sataScoring);
|
||||
}
|
||||
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;
|
||||
|
||||
// Session clock: pauses while the tab is hidden.
|
||||
|
|
@ -201,6 +231,17 @@ export function QuizRunner(p: RunnerProps) {
|
|||
<div className="truncate text-sm font-semibold">{p.title}</div>
|
||||
<div className="text-xs text-ink-3">{p.mode === 'exam' ? 'Exam' : 'Practice'}</div>
|
||||
</div>
|
||||
{live && (
|
||||
<div
|
||||
className={cx('num flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[13px] font-semibold', live.percent >= 80 ? 'bg-good-soft text-good' : live.percent >= 60 ? 'bg-warn-soft text-warn' : 'bg-bad-soft text-bad')}
|
||||
aria-label={`Score so far: ${fmtPoints(live.points)} of ${live.n} correct, ${live.percent} percent`}
|
||||
>
|
||||
<span className="hidden sm:inline">
|
||||
{fmtPoints(live.points)}/{live.n} correct ·
|
||||
</span>
|
||||
{live.percent}%
|
||||
</div>
|
||||
)}
|
||||
<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)}
|
||||
|
|
@ -233,7 +274,7 @@ export function QuizRunner(p: RunnerProps) {
|
|||
|
||||
{checked && (
|
||||
<div className="mt-5 animate-in space-y-4">
|
||||
<Verdict score={score} />
|
||||
<Verdict score={score} detail={creditDetail(question, selected, p.sataScoring)} />
|
||||
{question.rationale && (
|
||||
<div className="rounded-[14px] border border-line bg-surface p-4">
|
||||
<div className="eyebrow mb-1.5">Rationale</div>
|
||||
|
|
@ -419,7 +460,7 @@ export function QuizResults(p: ResultsProps) {
|
|||
<div className="eyebrow mb-1">{p.mode === 'exam' ? 'Exam result' : 'Practice result'}</div>
|
||||
<h1 className="display text-[30px]">{headline}</h1>
|
||||
<p className="mt-1.5 text-[15px] text-ink-2">
|
||||
<span className="num font-semibold text-ink">{Number.isInteger(points) ? points : points.toFixed(1)}</span> of <span className="num font-semibold text-ink">{scored.length}</span> points
|
||||
<span className="num font-semibold text-ink">{fmtPoints(points)}</span> of <span className="num font-semibold text-ink">{scored.length}</span> points
|
||||
{p.elapsedSec > 0 ? ` in ${formatMinutes(p.elapsedSec)}` : ''}
|
||||
{skipped > 0 ? `. ${plural(skipped, 'question')} skipped and not scored.` : '.'}
|
||||
</p>
|
||||
|
|
@ -490,6 +531,7 @@ export function QuizResults(p: ResultsProps) {
|
|||
{r.q.stem}
|
||||
</Markdown>
|
||||
<OptionList question={r.q} selected={r.selected} revealed />
|
||||
{r.scored && !r.correct && r.answered && creditDetail(r.q, r.selected, p.sataScoring) && <p className="mt-2.5 text-[13px] text-ink-2">{creditDetail(r.q, r.selected, p.sataScoring)}</p>}
|
||||
{r.q.rationale && (
|
||||
<div className="mt-3.5 rounded-xl bg-sunken px-4 py-3">
|
||||
<div className="eyebrow mb-1">Rationale</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue