Fifth revision: share-link AI safety, sturdier generation, cleaner UI
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
- Malformed model JSON is sent back for repair, then retried; a failed job starts over once before it fails. Visitors can dismiss failed sets. - Generated sets get a short distinct name and description; flashcards are atomic and have no hints; standard study shows known/learning counts. - Share links: "In progress" list, finished sets join the normal lists with a "New" tag, plain progress steps, newest exam first. - Share-link AI expires after a week, can be limited to the US or Arizona (DB-IP Lite or Cloudflare headers) and is locked by abuse protection (migration 8). - The assistant never answers from general knowledge; MCP and web search tools load without a manual test. - Plain-text copy, no question count in exam mode, filler text removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d8df5edf30
commit
85d5c9186d
46 changed files with 1242 additions and 283 deletions
|
|
@ -12,7 +12,7 @@ import { api, ApiError } from '@/lib/api';
|
|||
import type { AnswerState, PublicCollection, PublicDeck, PublicDocument, PublicNote, PublicPayload, PublicQuiz, ShareAi, SnapshotQuestion } from '@/lib/types';
|
||||
import { cx, formatBytes, plural, useDocumentTitle, useLocalStorage, useMediaQuery, useTheme } from '@/lib/util';
|
||||
import { Markdown } from '@/ui/Markdown';
|
||||
import { Button, EmptyState, IconButton, Input, PageLoading, Segmented, Switch } from '@/ui';
|
||||
import { Badge, Button, EmptyState, IconButton, Input, PageLoading, Segmented, Switch } from '@/ui';
|
||||
|
||||
/* ------------------------------ frame ------------------------------ */
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ function Frame({ children, back, wide }: { children: ReactNode; back?: { to: str
|
|||
</IconButton>
|
||||
</header>
|
||||
<main className={cx('mx-auto animate-in px-4 pt-4 pb-20 sm:px-5 sm:pt-8', wide ? 'max-w-5xl' : 'max-w-3xl')}>{children}</main>
|
||||
<footer className="pb-8 text-center text-xs text-ink-3">Shared with Study Desk. Your progress is saved in this browser only.</footer>
|
||||
<footer className="pb-8 text-center text-xs text-ink-3">Shared with Study Desk</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -178,7 +178,6 @@ function SharedQuiz({ quiz, storageKey, back, explainUrl, onImmersive }: { quiz:
|
|||
sataScoring="partial"
|
||||
onExit={() => (setState(null), setRunning(false))}
|
||||
exitLabel="Back to start"
|
||||
footnote="This result is stored in your browser only. The person who shared the quiz cannot see it."
|
||||
renderExtra={renderExtra}
|
||||
actions={
|
||||
<>
|
||||
|
|
@ -254,25 +253,22 @@ function SharedQuiz({ quiz, storageKey, back, explainUrl, onImmersive }: { quiz:
|
|||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<div className="grid grid-cols-2 gap-2" role="radiogroup" aria-label="Mode">
|
||||
{(
|
||||
[
|
||||
{ v: 'practice', t: 'Practice', b: 'See the answer and rationale after each question.' },
|
||||
{ v: 'exam', t: 'Exam', b: 'Answers and score are shown at the end.' },
|
||||
] as const
|
||||
).map((m) => (
|
||||
<button key={m.v} type="button" role="radio" aria-checked={prefs.mode === m.v} onClick={() => setPrefs((p) => ({ ...p, mode: m.v }))} className={cx('rounded-xl border p-3.5 text-left', prefs.mode === m.v ? 'border-accent bg-accent-soft' : 'border-line-strong hover:border-ink-3')}>
|
||||
<div className="font-semibold">{m.t}</div>
|
||||
<div className="mt-1 text-[13px] leading-snug text-ink-2">{m.b}</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<Segmented
|
||||
label="Mode"
|
||||
value={prefs.mode}
|
||||
onChange={(mode) => setPrefs((p) => ({ ...p, mode }))}
|
||||
options={[
|
||||
{ value: 'practice', label: 'Practice' },
|
||||
{ value: 'exam', label: 'Exam' },
|
||||
]}
|
||||
className="w-full"
|
||||
/>
|
||||
<div className="mt-4 space-y-3.5">
|
||||
<Switch checked={prefs.shuffleQ} onChange={(v) => setPrefs((p) => ({ ...p, shuffleQ: v }))} label="Shuffle questions" />
|
||||
<Switch checked={prefs.shuffleO} onChange={(v) => setPrefs((p) => ({ ...p, shuffleO: v }))} label="Shuffle answer choices" />
|
||||
{prefs.mode === 'exam' && (
|
||||
<>
|
||||
<Switch checked={prefs.timed} onChange={(v) => setPrefs((p) => ({ ...p, timed: v }))} label="Time limit" description="The exam submits itself when time runs out." />
|
||||
<Switch checked={prefs.timed} onChange={(v) => setPrefs((p) => ({ ...p, timed: v }))} label="Time limit" />
|
||||
{prefs.timed && (
|
||||
<label className="flex items-center gap-2 text-sm text-ink-2">
|
||||
<Timer className="size-4 text-ink-3" />
|
||||
|
|
@ -283,7 +279,6 @@ function SharedQuiz({ quiz, storageKey, back, explainUrl, onImmersive }: { quiz:
|
|||
</>
|
||||
)}
|
||||
</div>
|
||||
<p className="mt-4 text-[13px] text-ink-3">Select-all-that-apply questions give partial credit: a point for each correct choice, minus one for each incorrect choice, never below zero.</p>
|
||||
<Button variant={inProgress ? 'secondary' : 'primary'} size="lg" block className="mt-5" icon={<Play className="fill-current" />} onClick={() => begin()}>
|
||||
{inProgress ? 'Start over' : 'Start'}
|
||||
</Button>
|
||||
|
|
@ -479,6 +474,9 @@ function SharedDocument({ doc, token, nested, back }: { doc: PublicDocument; tok
|
|||
);
|
||||
}
|
||||
|
||||
/** Quizzes and decks added in the last two hours are marked "New". */
|
||||
const NEW_FOR_MS = 2 * 3_600_000;
|
||||
|
||||
const ITEM_ICON = { quiz: <BookOpen />, deck: <Layers />, note: <NotebookPen />, document: <FileText /> };
|
||||
|
||||
/** The same order and names as the owner's class page; a type with nothing in it is left out. */
|
||||
|
|
@ -486,8 +484,8 @@ const KIND_ORDER = ['quiz', 'deck', 'note', 'document'] as const;
|
|||
const KIND_HEADING = { quiz: 'Quizzes', deck: 'Flashcards', note: 'Notes', document: 'Class Materials' } as const;
|
||||
|
||||
function SharedCollection({ data, token }: { data: PublicCollection & { ai?: ShareAi }; token: string }) {
|
||||
// One section per exam in the class's order; material outside any exam comes last.
|
||||
const groups = [...data.folders, { id: null as string | null, name: 'Other' }].map((f) => ({ ...f, items: data.items.filter((i) => (f.id === null ? !i.folderId || !data.folders.some((x) => x.id === i.folderId) : i.folderId === f.id)) })).filter((g) => g.items.length > 0);
|
||||
// One section per exam, the latest first; material outside any exam comes last.
|
||||
const groups = [...[...data.folders].reverse(), { id: null as string | null, name: 'Other' }].map((f) => ({ ...f, items: data.items.filter((i) => (f.id === null ? !i.folderId || !data.folders.some((x) => x.id === i.folderId) : i.folderId === f.id)) })).filter((g) => g.items.length > 0);
|
||||
return (
|
||||
<Frame>
|
||||
<div className={cx('border-l-[5px] border-tab pl-4', `tab-${data.color}`)}>
|
||||
|
|
@ -518,7 +516,10 @@ function SharedCollection({ data, token }: { data: PublicCollection & { ai?: Sha
|
|||
<Link to={`/s/${token}/${i.kind}/${i.id}`} className="flex items-center gap-3 px-4 py-3.5 hover:bg-ink/4">
|
||||
<span className={cx('grid size-10 shrink-0 place-items-center rounded-[11px] [&>svg]:size-[18px]', i.kind === 'quiz' ? 'bg-accent-soft text-accent' : i.kind === 'deck' ? 'bg-marker/45 text-ink dark:bg-marker/20 dark:text-marker' : i.kind === 'document' ? 'bg-sunken text-ink-2' : 'bg-good-soft text-good')}>{ITEM_ICON[i.kind]}</span>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate text-[15px] font-medium">{i.title}</span>
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<span className="truncate text-[15px] font-medium">{i.title}</span>
|
||||
{i.createdAt && Date.now() - i.createdAt < NEW_FOR_MS && <Badge tone="accent">New</Badge>}
|
||||
</span>
|
||||
<span className="text-xs text-ink-3">{i.kind === 'quiz' ? plural(i.count, 'question') : i.kind === 'deck' ? plural(i.count, 'card') : i.kind === 'document' ? (i.count ? plural(i.count, 'page') : 'File') : 'Note'}</span>
|
||||
</span>
|
||||
<ChevronRight className="size-4 text-ink-3" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue