Second revision: MCP servers, shared-link AI, flashcard modes, document previews
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 30s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 30s
Generation - Every quiz is NCLEX style; "Practice exam" writes 50 questions. - Calculation questions only when the material involves calculations (max 5 per exam). - Broad topics: the class's topics are listed in the prompt, a quick grouping call maps narrow labels onto broad ones, and leftover variants are merged. - Exact select-all count per batch; option order shuffled. - Python check: at most 3 runs, fixed problems count as passed, cosmetic remarks ignored. Assistant - Text, tool steps and cards appear in the order they happen, with paragraph breaks between steps. - Optional thinking box: fixed height, follows the newest text, can be scrolled back. - "+" opens a material picker listing recent items; items can be dragged in from class pages; shorter placeholder. MCP servers - Streamable HTTP client; encrypted headers. - Per-server instructions and switches for chat, Explain, generation and the quiz check. - Settings UI. Share links - Optional "Explain this" and "Ask about this material" per link, off by default. - Items are loaded on the server and checked against the share; no tools; rate-limited. - Migration 4 stores the switches. Study and documents - Standard flashcard mode (optionally repeat missed cards until known) next to spaced repetition. - Streak visuals restyled in the app palette. - Side by side / Original document views, with sandboxed previews of Word and PowerPoint files. Other - Built-in embedding model baked into the image; sharp stubbed if it cannot load; real load error shown in Settings. - Python runner blocks network and process modules in JavaScript too. - "View questions and answers" removed from the quiz start screen. - Docs updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5ea61c882c
commit
031f7bec31
45 changed files with 2918 additions and 397 deletions
|
|
@ -3,7 +3,9 @@ import { ArrowLeft, BookOpen, ChevronRight, Download, FileText, Layers, Link2Off
|
|||
import { useEffect, useMemo, useState, type ReactNode } from 'react';
|
||||
import { Link, useNavigate, useParams } from 'react-router';
|
||||
import { isFullyCorrect, scoreQuestion, seededShuffle } from '@shared/content';
|
||||
import { Explain } from '@/features/Explain';
|
||||
import { CramSession, freshCramState, reconcileCramState, type CramState } from '@/features/flashcards';
|
||||
import { SharedAssistant } from '@/features/SharedAssistant';
|
||||
import { QuizResults, QuizRunner } from '@/features/quiz';
|
||||
import { api, ApiError } from '@/lib/api';
|
||||
import type { AnswerState, PublicCollection, PublicDeck, PublicDocument, PublicNote, PublicPayload, PublicQuiz, SnapshotQuestion } from '@/lib/types';
|
||||
|
|
@ -116,7 +118,8 @@ function buildQuizState(quiz: PublicQuiz, mode: QuizState['mode'], shuffleQ: boo
|
|||
};
|
||||
}
|
||||
|
||||
function SharedQuiz({ quiz, storageKey, back }: { quiz: PublicQuiz; storageKey: string; back?: { to: string; label: string } }) {
|
||||
function SharedQuiz({ quiz, storageKey, back, explainUrl }: { quiz: PublicQuiz; storageKey: string; back?: { to: string; label: string }; explainUrl?: string }) {
|
||||
const renderExtra = explainUrl ? (q: SnapshotQuestion, selected: string[]) => <Explain url={explainUrl} body={{ kind: 'question', quizId: quiz.id, questionId: q.id, selected }} /> : undefined;
|
||||
const [state, setState] = useLocalStorage<QuizState | null>(storageKey, null);
|
||||
const [prefs, setPrefs] = useLocalStorage('sd.pub.prefs2', { mode: 'practice' as 'practice' | 'exam', shuffleQ: true, shuffleO: true, timed: false, minutes: 0 });
|
||||
const minutes = prefs.minutes > 0 ? prefs.minutes : Math.max(5, Math.round(quiz.questions.length * 1.2));
|
||||
|
|
@ -169,6 +172,7 @@ function SharedQuiz({ quiz, storageKey, back }: { quiz: PublicQuiz; storageKey:
|
|||
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={
|
||||
<>
|
||||
{missed.length > 0 && (
|
||||
|
|
@ -199,6 +203,7 @@ function SharedQuiz({ quiz, storageKey, back }: { quiz: PublicQuiz; storageKey:
|
|||
deadlineAt={state.deadlineAt ?? null}
|
||||
sataScoring="partial"
|
||||
exitLabel={state.deadlineAt ? 'Leave (the clock keeps running)' : 'Pause'}
|
||||
renderExtra={renderExtra}
|
||||
onAnswer={(qid, selected, checked) => setState((s) => (s ? { ...s, answers: { ...s.answers, [qid]: { selected, checked } } } : s))}
|
||||
onFlags={(flags) => setState((s) => (s ? { ...s, flags } : s))}
|
||||
onIndex={(index) => setState((s) => (s ? { ...s, index } : s))}
|
||||
|
|
@ -283,13 +288,24 @@ function SharedQuiz({ quiz, storageKey, back }: { quiz: PublicQuiz; storageKey:
|
|||
|
||||
/* ------------------------------ deck ------------------------------ */
|
||||
|
||||
function SharedDeck({ deck, storageKey, back }: { deck: PublicDeck; storageKey: string; back?: { to: string; label: string } }) {
|
||||
function SharedDeck({ deck, storageKey, back, explainUrl }: { deck: PublicDeck; storageKey: string; back?: { to: string; label: string }; explainUrl?: string }) {
|
||||
const [saved, setSaved] = useLocalStorage<CramState | null>(storageKey, null);
|
||||
const [running, setRunning] = useState(false);
|
||||
const state = useMemo(() => reconcileCramState(saved, deck.cards), [saved, deck.cards]);
|
||||
|
||||
if (running && state) {
|
||||
return <CramSession title={deck.title} subtitle="Shared flashcards" cards={deck.cards} state={state} onState={setSaved} onExit={() => setRunning(false)} exitLabel="Pause" />;
|
||||
return (
|
||||
<CramSession
|
||||
title={deck.title}
|
||||
subtitle="Shared flashcards"
|
||||
cards={deck.cards}
|
||||
state={state}
|
||||
onState={setSaved}
|
||||
onExit={() => setRunning(false)}
|
||||
exitLabel="Pause"
|
||||
renderExtra={explainUrl ? (card) => <Explain url={explainUrl} body={{ kind: 'card', deckId: deck.id, cardId: card.id }} /> : undefined}
|
||||
/>
|
||||
);
|
||||
}
|
||||
const seen = state ? Math.min(state.index, state.order.length) : 0;
|
||||
return (
|
||||
|
|
@ -456,16 +472,26 @@ export default function SharedPage() {
|
|||
}
|
||||
const back = nested ? { to: `/s/${token}`, label: 'All materials' } : undefined;
|
||||
const key = `sd.pub.${token.slice(0, 12)}.${data.kind}.${'id' in data ? data.id : ''}`;
|
||||
switch (data.kind) {
|
||||
case 'quiz':
|
||||
return <SharedQuiz key={key} quiz={data} storageKey={key} back={back} />;
|
||||
case 'deck':
|
||||
return <SharedDeck key={key} deck={data} storageKey={key} back={back} />;
|
||||
case 'note':
|
||||
return <SharedNote note={data} back={back} />;
|
||||
case 'document':
|
||||
return <SharedDocument doc={data} token={token} nested={nested} back={back} />;
|
||||
case 'collection':
|
||||
return <SharedCollection data={data} token={token} />;
|
||||
}
|
||||
const explainUrl = data.ai?.explain ? `/api/public/${token}/explain` : undefined;
|
||||
const assistant = data.ai?.assistant ? <SharedAssistant token={token} title={data.title} item={nested && data.kind !== 'collection' ? { kind: data.kind, id: data.id } : undefined} /> : null;
|
||||
const page = (() => {
|
||||
switch (data.kind) {
|
||||
case 'quiz':
|
||||
return <SharedQuiz key={key} quiz={data} storageKey={key} back={back} explainUrl={explainUrl} />;
|
||||
case 'deck':
|
||||
return <SharedDeck key={key} deck={data} storageKey={key} back={back} explainUrl={explainUrl} />;
|
||||
case 'note':
|
||||
return <SharedNote note={data} back={back} />;
|
||||
case 'document':
|
||||
return <SharedDocument doc={data} token={token} nested={nested} back={back} />;
|
||||
case 'collection':
|
||||
return <SharedCollection data={data} token={token} />;
|
||||
}
|
||||
})();
|
||||
return (
|
||||
<>
|
||||
{page}
|
||||
{assistant}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue