Third revision: web search, MCP sign-in, exams, intelligent UI, clarifying questions
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 1m0s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 1m0s
- Built-in Parallel web search (keyless; optional sign-in for higher limits and research) with its own settings page; OAuth sign-in (RFC 9728/8414/7591, PKCE, RFC 8707) for any MCP server, with token refresh and pre-registered client support - Friendly tool steps (icon, name, status; details on click) and ids stripped from results; per-chat tool switches; taller thinking box - Exams within classes: exam tabs, scoped lists, uploads, imports and Generate; exam-only material for generation; class setting for what the groups are called - Assistant can ask clarifying questions in an inline form before generating - OpenUI blocks (charts, questions, flashcards, inputs) in assistant, Explain and share chats - Explain beside the quiz on wide screens, grounded in the cited source pages - Quiz results: percentage ring coloured by score band, rainbow at 100 - Share links: assistant button like the owner's, hidden during quizzes; documents readable in the browser - Live draft and library updates over server-sent events Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
60cf2322f7
commit
c595e0ff2c
54 changed files with 4710 additions and 387 deletions
|
|
@ -5,7 +5,7 @@ import type { AnswerState, SnapshotQuestion } from '@/lib/types';
|
|||
import { cx, formatDuration, formatMinutes, plural, useHotkeys, useLatest } from '@/lib/util';
|
||||
import { Markdown } from '@/ui/Markdown';
|
||||
import { Badge, Button, Dialog, IconButton, Input, ProgressBar, Segmented, useConfirm } from '@/ui';
|
||||
import { Ring } from './charts';
|
||||
import { ExplainSideContext } from './Explain';
|
||||
|
||||
/* ------------------------------ option list ------------------------------ */
|
||||
|
||||
|
|
@ -398,7 +398,7 @@ export function QuizRunner(p: RunnerProps) {
|
|||
<Markdown className="text-[15px]">{question.rationale}</Markdown>
|
||||
</div>
|
||||
)}
|
||||
{p.renderExtra?.(question, answerTexts(question, selected))}
|
||||
<ExplainSideContext.Provider value>{p.renderExtra?.(question, answerTexts(question, selected))}</ExplainSideContext.Provider>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
@ -482,6 +482,80 @@ export function QuizRunner(p: RunnerProps) {
|
|||
|
||||
/* ------------------------------ results ------------------------------ */
|
||||
|
||||
type ScoreTier = 'perfect' | 'a' | 'b' | 'c' | 'fail';
|
||||
|
||||
/** Bands of the 7-point scale: 93+ green, 85-92 blue, 77-84 yellow, below 77 (failing) red; 100% is a rainbow. */
|
||||
export function scoreTier(percent: number): ScoreTier {
|
||||
const p = Math.round(percent);
|
||||
return p >= 100 ? 'perfect' : p >= 93 ? 'a' : p >= 85 ? 'b' : p >= 77 ? 'c' : 'fail';
|
||||
}
|
||||
|
||||
const TIER_COLOR: Record<Exclude<ScoreTier, 'perfect'>, string> = { a: 'var(--good)', b: 'var(--accent)', c: 'var(--score-yellow)', fail: 'var(--bad)' };
|
||||
|
||||
/** The result ring: fills up and counts to the score; a perfect score cycles through a rainbow. */
|
||||
function ScoreRing({ percent, size = 136, stroke = 12 }: { percent: number; size?: number; stroke?: number }) {
|
||||
const tier = scoreTier(percent);
|
||||
const [shown, setShown] = useState(0);
|
||||
useEffect(() => {
|
||||
if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches) return setShown(percent);
|
||||
let frame = 0;
|
||||
const started = performance.now();
|
||||
const tick = (now: number) => {
|
||||
const t = Math.min(1, (now - started) / 1100);
|
||||
setShown(Math.round(percent * (1 - (1 - t) ** 3)));
|
||||
if (t < 1) frame = requestAnimationFrame(tick);
|
||||
};
|
||||
frame = requestAnimationFrame(tick);
|
||||
return () => cancelAnimationFrame(frame);
|
||||
}, [percent]);
|
||||
const r = (size - stroke) / 2;
|
||||
const c = 2 * Math.PI * r;
|
||||
const gid = `score-${size}`;
|
||||
return (
|
||||
<div className="relative shrink-0" style={{ width: size, height: size }} role="img" aria-label={`Score ${percent} percent`}>
|
||||
<svg width={size} height={size} className={cx('-rotate-90', tier === 'perfect' && 'ring-rainbow')} aria-hidden>
|
||||
{tier === 'perfect' && (
|
||||
<defs>
|
||||
<linearGradient id={gid} x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stopColor="#ff4d6d" />
|
||||
<stop offset="20%" stopColor="#ff9f1c" />
|
||||
<stop offset="40%" stopColor="#ffd60a" />
|
||||
<stop offset="60%" stopColor="#2ec27e" />
|
||||
<stop offset="80%" stopColor="#3a86ff" />
|
||||
<stop offset="100%" stopColor="#9b5de5" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
)}
|
||||
<circle cx={size / 2} cy={size / 2} r={r} fill="none" stroke="var(--line)" strokeWidth={stroke} />
|
||||
<circle
|
||||
cx={size / 2}
|
||||
cy={size / 2}
|
||||
r={r}
|
||||
fill="none"
|
||||
stroke={tier === 'perfect' ? `url(#${gid})` : TIER_COLOR[tier]}
|
||||
strokeWidth={stroke}
|
||||
strokeLinecap="round"
|
||||
strokeDasharray={c}
|
||||
strokeDashoffset={c * (1 - shown / 100)}
|
||||
/>
|
||||
</svg>
|
||||
<div className="absolute inset-0 grid place-items-center">
|
||||
<span className="num display text-[38px] leading-none font-medium">
|
||||
{shown}
|
||||
<span className="text-[20px] text-ink-3">%</span>
|
||||
</span>
|
||||
</div>
|
||||
{tier === 'perfect' && shown === 100 && (
|
||||
<span className="pointer-events-none absolute inset-0" aria-hidden>
|
||||
{[0, 1, 2, 3, 4, 5, 6, 7].map((i) => (
|
||||
<span key={i} className="score-spark absolute top-1/2 left-1/2 size-2 rounded-full" style={{ ['--a' as string]: `${i * 45}deg`, background: ['#ff4d6d', '#ff9f1c', '#ffd60a', '#2ec27e', '#3a86ff', '#9b5de5', '#ff4d6d', '#2ec27e'][i] }} />
|
||||
))}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export interface ResultsProps {
|
||||
title: string;
|
||||
mode: 'practice' | 'exam';
|
||||
|
|
@ -517,8 +591,6 @@ export function QuizResults(p: ResultsProps) {
|
|||
const partial = scored.filter((r) => !r.correct && r.score > 0).length;
|
||||
const wrong = scored.length - right - partial;
|
||||
const skipped = rows.length - scored.length;
|
||||
const tone = gradeToneFor(percent);
|
||||
const grade = letterGrade(percent);
|
||||
|
||||
const topics = useMemo(() => {
|
||||
const map = new Map<string, { n: number; s: number }>();
|
||||
|
|
@ -533,7 +605,8 @@ export function QuizResults(p: ResultsProps) {
|
|||
}, [scored]);
|
||||
|
||||
const visible = rows.filter((r) => (filter === 'all' ? true : filter === 'wrong' ? r.scored && !r.correct : p.flags.includes(r.q.id)));
|
||||
const headline = { A: 'Excellent work', B: 'Strong result', C: 'Passing', D: 'Just below passing', F: 'Worth another pass' }[grade];
|
||||
const tier = scoreTier(percent);
|
||||
const headline = { perfect: 'Perfect score!', a: 'Excellent work', b: 'Strong result', c: 'Passing', fail: 'Worth another pass' }[tier];
|
||||
|
||||
return (
|
||||
<div className="min-h-dvh bg-paper">
|
||||
|
|
@ -548,14 +621,9 @@ export function QuizResults(p: ResultsProps) {
|
|||
<main className="mx-auto max-w-3xl animate-in px-4 pt-8 pb-24 sm:px-5">
|
||||
<section className="card p-6 sm:p-8">
|
||||
<div className="flex flex-col items-center gap-6 text-center sm:flex-row sm:text-left">
|
||||
<Ring value={percent / 100} size={128} stroke={11} tone={tone}>
|
||||
<div className="flex flex-col items-center leading-none">
|
||||
<span className="display text-[40px] font-medium">{grade}</span>
|
||||
<span className="num mt-1 text-[13px] font-medium text-ink-3">{percent}%</span>
|
||||
</div>
|
||||
</Ring>
|
||||
<ScoreRing percent={percent} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="eyebrow mb-1">{p.mode === 'exam' ? 'Exam result' : 'Practice result'} · grade {grade}</div>
|
||||
<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">{fmtPoints(points)}</span> of <span className="num font-semibold text-ink">{scored.length}</span> points
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue