Varied question openers, readable rationales, plain practice score
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 30s

- Stems no longer all open the same way: the writing rules, batch prompt and
  planner ask for varied openings (age openings stay part of the mix), and when
  one opener covers more than a quarter of a quiz the excess stems have only
  their opening reworded, keeping every number, before the check.
- Rationales are asked for as Markdown (a bold key point, then short bullets);
  older one-paragraph rationales are laid out the same way on display.
- The practice score in the quiz header is a plain "x/y correct", with no
  percentage or colour.
- Fix a flaky assertion: the mock's answer-key fix is a no-op when the shuffle
  already put the answer in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-16 12:05:46 -07:00
parent 10be5c39da
commit 517278be71
15 changed files with 382 additions and 24 deletions

View file

@ -4,6 +4,7 @@ import { isFullyCorrect, letterGrade, optionLetter, parseNumericAnswer, scoreQue
import type { AnswerState, SnapshotQuestion } from '@/lib/types';
import { cx, formatDuration, formatMinutes, plural, useHotkeys, useLatest } from '@/lib/util';
import { Markdown } from '@/ui/Markdown';
import { formatRationale } from '@shared/rationale';
import { Badge, Button, Dialog, IconButton, Input, ProgressBar, Segmented, useConfirm } from '@/ui';
import { ExplainSideContext } from './Explain';
@ -345,14 +346,9 @@ export function QuizRunner(p: RunnerProps) {
<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', { good: 'bg-good-soft text-good', warn: 'bg-warn-soft text-warn', bad: 'bg-bad-soft text-bad' }[gradeToneFor(live.percent)])}
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 className="num flex items-center rounded-full px-2.5 py-1 text-[13px] font-medium text-ink-2" aria-label={`Score so far: ${fmtPoints(live.points)} of ${live.n} correct`}>
{fmtPoints(live.points)}/{live.n}
<span className="hidden sm:inline">&nbsp;correct</span>
</div>
)}
{/* The clock is a timed-exam feature; untimed sessions track time quietly for the results. */}
@ -402,7 +398,7 @@ export function QuizRunner(p: RunnerProps) {
{question.rationale && (
<div className="rounded-[14px] border border-line bg-surface p-4">
<div className="eyebrow mb-1.5">Rationale</div>
<Markdown className="text-[15px]">{question.rationale}</Markdown>
<Markdown className="text-[15px]">{formatRationale(question.rationale)}</Markdown>
</div>
)}
<ExplainSideContext.Provider value={explainSide}>{p.renderExtra?.(question, answerTexts(question, selected))}</ExplainSideContext.Provider>
@ -708,7 +704,7 @@ export function QuizResults(p: ResultsProps) {
{r.q.rationale && (
<div className="mt-3.5 rounded-xl bg-sunken px-4 py-3">
<div className="eyebrow mb-1">Rationale</div>
<Markdown className="text-[14.5px]">{r.q.rationale}</Markdown>
<Markdown className="text-[14.5px]">{formatRationale(r.q.rationale)}</Markdown>
</div>
)}
{p.renderExtra && (

View file

@ -8,6 +8,7 @@ import { useState, type ReactNode } from 'react';
import { GENUI_COMPONENTS, GENUI_GROUPS, GENUI_ROOT } from '@shared/genui';
import { cx } from '@/lib/util';
import { Markdown } from '@/ui/Markdown';
import { formatRationale } from '@shared/rationale';
import { BarChart, LineChart, PieChart, type ChartSeries } from './charts';
type Props = Record<string, any>;
@ -367,7 +368,7 @@ const R: Record<string, Renderer> = {
{right ? <Check className="size-4" /> : <X className="size-4" />}
{right ? 'Correct' : 'Not quite'}
</div>
{props.rationale && <Markdown className="text-[14px] text-ink-2">{text(props.rationale)}</Markdown>}
{props.rationale && <Markdown className="text-[14px] text-ink-2">{formatRationale(text(props.rationale))}</Markdown>}
<button type="button" onClick={() => (setChecked(false), setPicked([]))} className="inline-flex items-center gap-1 text-[12.5px] font-medium text-ink-3 hover:text-ink">
<RotateCcw className="size-3.5" /> Try again
</button>

View file

@ -10,6 +10,7 @@ import { qk, useClass, useClasses, useQuiz, useRefresh } from '@/lib/queries';
import type { Draft } from '@/lib/types';
import { cx, plural, useDocumentTitle } from '@/lib/util';
import { Markdown } from '@/ui/Markdown';
import { formatRationale } from '@shared/rationale';
import { Badge, Button, Callout, EmptyState, ErrorState, Field, IconButton, Input, PageLoading, ProgressBar, Segmented, Select, Textarea, useConfirm } from '@/ui';
const KIND = { quiz: { label: 'Quiz', icon: <BookOpen />, url: 'quizzes' }, deck: { label: 'Flashcards', icon: <Layers />, url: 'decks' }, note: { label: 'Note', icon: <NotebookPen />, url: 'notes' } } as const;
@ -36,7 +37,7 @@ function QuestionPreview({ q }: { q: DraftQuestion }) {
{q.rationale && (
<div className="mt-3 rounded-xl bg-sunken px-4 py-3">
<div className="eyebrow mb-1">Rationale</div>
<Markdown className="text-[14.5px]">{q.rationale}</Markdown>
<Markdown className="text-[14.5px]">{formatRationale(q.rationale)}</Markdown>
</div>
)}
{q.source && (

View file

@ -13,6 +13,7 @@ import { useAssistantContext } from '@/lib/assistantStore';
import { useAiStatus, useQuiz, useRefresh } from '@/lib/queries';
import { cx, downloadFile, formatDateTime, formatMinutes, gradeTone, pct, plural, timeAgo, useDocumentTitle, useLocalStorage } from '@/lib/util';
import { Markdown } from '@/ui/Markdown';
import { formatRationale } from '@shared/rationale';
import { SortableList } from '@/ui/Sortable';
import { Badge, Button, Callout, ClassDot, Dialog, EmptyState, ErrorState, Field, IconButton, Input, Menu, MenuItem, MenuSeparator, Segmented, Skeleton, Switch, Textarea, useConfirm } from '@/ui';
@ -254,7 +255,7 @@ function QuestionView({ q, index, stat }: { q: Question; index: number; stat?: {
</button>
{open && q.rationale && (
<div className="mt-2 rounded-xl bg-sunken px-4 py-3">
<Markdown className="text-[14.5px]">{q.rationale}</Markdown>
<Markdown className="text-[14.5px]">{formatRationale(q.rationale)}</Markdown>
</div>
)}
</>