First revision: DeepSeek, numeric questions, background assistant, UI fixes
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 1m2s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 1m2s
Providers and pricing - Add a DeepSeek provider: thinking mode with low/high/max effort, reasoning_content replayed between tool steps, cache-hit usage, /models discovery and catalog prices. - Fix "does not support tool calling": a rejected forced tool_choice (DeepSeek thinking mode) now asks for the call in the prompt; only a genuine no-tools 400 is "unsupported". - Seven reasoning-effort levels (Off to Max) mapped per adapter. - Cached-input price per model, cache-write and DeepSeek off-peak aware cost estimates. - Built-in bge-small embedding model (transformers.js) as the semantic search default. Quizzes - Numeric (type-the-answer) questions: units ignored, optional ± tolerance; editor, runner, importer, templates and generation prompts. - Quiz start screen instead of showing answers; navigator ring no longer clipped and key legend removed; clock only for timed exams; 7-point letter grades. Assistant and generation - Assistant turns run on the server independently of the browser, with re-attach and an explicit stop; drafts tray shows generations in progress. - Per-chat model switcher, @-tagging of class materials, full-width assistant page and a smaller assistant button. - Editable generation instructions and built-in presets, separate from the chatbot import instructions. Other - Dialog footer padding, keyboard hints removed, copy buttons work over plain HTTP, class and folder shares include documents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ccdad9728b
commit
f0aabe4d5d
63 changed files with 3892 additions and 488 deletions
|
|
@ -18,6 +18,7 @@ import {
|
|||
type Issue,
|
||||
type NoteDraft,
|
||||
type QuizDraft,
|
||||
parseNumericAnswer,
|
||||
validateDraft,
|
||||
} from './content.ts';
|
||||
|
||||
|
|
@ -122,8 +123,27 @@ function normalizeQuestion(raw: unknown, notices: Issue[], index: number): Draft
|
|||
notices.push({ level: 'warning', index, message: `Question ${index + 1} is not an object and was skipped` });
|
||||
return null;
|
||||
}
|
||||
const options = normalizeOptions(pick(raw, 'options', 'choices', 'answers', 'answerOptions', 'answer_options'));
|
||||
let options = normalizeOptions(pick(raw, 'options', 'choices', 'answers', 'answerOptions', 'answer_options'));
|
||||
const answerKey = pick(raw, 'correctAnswers', 'correct_answers', 'correctAnswer', 'correct_answer', 'answer', 'correct', 'key');
|
||||
const rawTypeEarly = str(pick(raw, 'type', 'questionType', 'question_type', 'kind')).toLowerCase().replace(/[\s-]/g, '_');
|
||||
const numericType = NUMERIC_TYPES.includes(rawTypeEarly);
|
||||
// Calculation questions: the "options" are the accepted answers, or there is only an answer key.
|
||||
if (numericType || (options.length === 0 && (typeof answerKey === 'number' || (typeof answerKey === 'string' && parseNumericAnswer(answerKey) !== null)))) {
|
||||
if (options.length === 0 && answerKey !== undefined) {
|
||||
const keys = Array.isArray(answerKey) ? answerKey : [answerKey];
|
||||
options = keys.map((k) => ({ text: str(k).trim(), correct: true, why: '' })).filter((o) => o.text);
|
||||
}
|
||||
return {
|
||||
type: 'numeric',
|
||||
stem: str(pick(raw, 'stem', 'prompt', 'question', 'text', 'q')).trim(),
|
||||
options: options.map((o) => ({ ...o, correct: true })),
|
||||
rationale: str(pick(raw, 'rationale', 'explanation', 'reasoning', 'feedback')).trim(),
|
||||
topic: str(pick(raw, 'topic', 'category', 'subject', 'concept')).trim().slice(0, 80),
|
||||
difficulty: toDifficulty(pick(raw, 'difficulty', 'level')),
|
||||
tags: toTags(pick(raw, 'tags', 'keywords')),
|
||||
source: str(pick(raw, 'source', 'citation', 'reference')).trim() || undefined,
|
||||
};
|
||||
}
|
||||
if (answerKey !== undefined && !options.some((o) => o.correct)) {
|
||||
for (const idx of resolveAnswerRefs(answerKey, options)) options[idx].correct = true;
|
||||
}
|
||||
|
|
@ -195,8 +215,13 @@ function noteFrom(raw: Raw): NoteDraft {
|
|||
return { kind: 'note', title: str(pick(raw, 'title', 'name')).trim(), content: str(pick(raw, 'content', 'markdown', 'body', 'text')) };
|
||||
}
|
||||
|
||||
const NUMERIC_TYPES = ['numeric', 'number', 'numerical', 'calculation', 'calc', 'math', 'fill_in', 'fill_in_the_blank', 'short_answer', 'dosage'];
|
||||
|
||||
function looksLikeQuestion(v: unknown): boolean {
|
||||
return isObj(v) && pick(v, 'options', 'choices', 'answers', 'answerOptions') !== undefined;
|
||||
if (!isObj(v)) return false;
|
||||
if (pick(v, 'options', 'choices', 'answers', 'answerOptions') !== undefined) return true;
|
||||
const type = str(pick(v, 'type', 'questionType', 'question_type')).toLowerCase().replace(/[\s-]/g, '_');
|
||||
return NUMERIC_TYPES.includes(type) && pick(v, 'stem', 'question', 'prompt') !== undefined;
|
||||
}
|
||||
function looksLikeCard(v: unknown): boolean {
|
||||
return isObj(v) && pick(v, 'front', 'term') !== undefined && pick(v, 'back', 'definition') !== undefined;
|
||||
|
|
@ -305,7 +330,7 @@ export function parseTextQuestions(text: string): DraftQuestion[] {
|
|||
const questions: DraftQuestion[] = [];
|
||||
for (const block of blocks) {
|
||||
const lines = block.split('\n').filter((l) => l.trim());
|
||||
if (lines.length < 3) continue;
|
||||
if (lines.length < 2) continue;
|
||||
const stem: string[] = [];
|
||||
const options: DraftOption[] = [];
|
||||
let rationale = '';
|
||||
|
|
@ -343,6 +368,11 @@ export function parseTextQuestions(text: string): DraftQuestion[] {
|
|||
else if (section === 'rationale') rationale += `\n${line.trim()}`;
|
||||
else if (options.length) options[options.length - 1].text += ` ${line.trim()}`;
|
||||
}
|
||||
if (stem.length > 0 && options.length === 0 && answer && parseNumericAnswer(answer) !== null) {
|
||||
// "Answer: 12.5 mL" with no choices: a calculation the student types in.
|
||||
questions.push({ type: 'numeric', stem: stem.join('\n'), options: [{ text: answer.trim(), correct: true, why: '' }], rationale: rationale.trim(), topic, difficulty: 'medium', tags: [] });
|
||||
continue;
|
||||
}
|
||||
if (options.length < 2 || stem.length === 0) continue;
|
||||
if (answer && !options.some((o) => o.correct)) for (const idx of resolveAnswerRefs(answer, options)) options[idx].correct = true;
|
||||
const correctCount = options.filter((o) => o.correct).length;
|
||||
|
|
@ -513,6 +543,15 @@ export const QUIZ_JSON_TEMPLATE = JSON.stringify(
|
|||
difficulty: 'medium',
|
||||
tags: [],
|
||||
},
|
||||
{
|
||||
type: 'numeric',
|
||||
stem: 'Heparin 5,000 units subcut is ordered. The vial contains 10,000 units/mL. How many mL should the nurse give? Round to the nearest tenth.',
|
||||
options: [{ text: '0.5 mL', correct: true, why: '5,000 units ÷ 10,000 units/mL = 0.5 mL.' }],
|
||||
rationale: 'Desired over have: 5,000 ÷ 10,000 × 1 mL = 0.5 mL. Only the number is checked, so "0.5" and "0.5 mL" are both accepted.',
|
||||
topic: 'Dosage calculation',
|
||||
difficulty: 'easy',
|
||||
tags: [],
|
||||
},
|
||||
],
|
||||
}),
|
||||
null,
|
||||
|
|
@ -546,7 +585,12 @@ Topic: Electrolytes
|
|||
C. Hypertension
|
||||
*D. Bradycardia
|
||||
Rationale: Early toxicity is gastrointestinal and visual; bradycardia and dysrhythmias follow.
|
||||
Topic: Pharmacology`;
|
||||
Topic: Pharmacology
|
||||
|
||||
3. The provider orders 500 mL of normal saline over 4 hours. At what rate in mL/hr should the nurse set the pump?
|
||||
Answer: 125 mL/hr
|
||||
Rationale: 500 mL ÷ 4 hr = 125 mL/hr.
|
||||
Topic: Dosage calculation`;
|
||||
|
||||
export const TEXT_CARDS_TEMPLATE = `Furosemide\tLoop diuretic; monitor potassium
|
||||
Metoprolol\tBeta-1 selective blocker; hold for HR below 60
|
||||
|
|
@ -588,9 +632,10 @@ Use exactly this shape:
|
|||
}
|
||||
|
||||
Rules:
|
||||
- "type" is "single" (multiple choice) or "multi" (select all that apply).
|
||||
- "type" is "single" (multiple choice), "multi" (select all that apply) or "numeric" (the student types a number).
|
||||
- "single" questions have exactly 4 options and exactly one with "correct": true.
|
||||
- "multi" questions have 5 or 6 options, 2 to 5 of them correct, and the stem ends with "Select all that apply."
|
||||
- Use "numeric" for calculations (dosages, IV rates, drip rates, conversions, intake and output). Its "options" holds only the correct answer, e.g. [{ "text": "12.5 mL", "correct": true, "why": "Show the calculation" }]. The stem states the unit and how to round, e.g. "Round to the nearest tenth." Only the number is checked, so units in the answer are optional.
|
||||
- Write NCLEX-style questions that test clinical judgment: a short client scenario, one clear question, priority wording where it fits (first, best, most important), and distractors that are plausible but wrong for a specific reason. Never use "all of the above" or "none of the above".
|
||||
- Every option needs a one-sentence "why". The "rationale" explains the principle behind the correct answer.
|
||||
- "topic" is a short label. Reuse the same label for related questions and keep the number of different topics small.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue