Varied question openers, readable rationales, plain practice score
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
- 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:
parent
10be5c39da
commit
517278be71
15 changed files with 382 additions and 24 deletions
|
|
@ -636,8 +636,8 @@ Rules:
|
|||
- "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.
|
||||
- Write NCLEX-style questions that test clinical judgment: a short client scenario (vary how stems open so they do not all start the same way), 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, laid out for quick reading: one bold key sentence, then 2 to 4 short bullet points (use \\n between lines).
|
||||
- "topic" is a short label. Reuse the same label for related questions and keep the number of different topics small.
|
||||
- "difficulty" is "easy", "medium" or "hard".
|
||||
- Markdown is allowed inside strings (bold, lists, tables). Write line breaks inside strings as \\n.
|
||||
|
|
|
|||
74
shared/rationale.ts
Normal file
74
shared/rationale.ts
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* Rationale layout. New rationales are written as Markdown (a bold key point, then short
|
||||
* bullets); older ones are often one long paragraph. `formatRationale` breaks such a paragraph
|
||||
* into readable pieces for display: the first sentence on its own, then short paragraphs, and
|
||||
* a list when it walks through the choices ("Option A…", "Choice 2…"). Text that already has
|
||||
* structure (line breaks, lists, headings) is returned unchanged.
|
||||
*/
|
||||
|
||||
/** Words that end with a period without ending the sentence. */
|
||||
const ABBREVIATIONS = /(?:^|\s|\()(?:e\.g|i\.e|vs|etc|approx|dr|mr|mrs|ms|st|no|fig|min|max|hr|hrs|mg|mcg|kg|ml|mL|dL|mEq|U|gtt|q|b\.i\.d|t\.i\.d|q\.i\.d|p\.r\.n|a\.m|p\.m)\.$/i;
|
||||
|
||||
/** Splits plain prose into sentences, keeping decimals ("2.5 mg") and abbreviations together. */
|
||||
export function splitSentences(text: string): string[] {
|
||||
const out: string[] = [];
|
||||
let start = 0;
|
||||
const re = /([.!?])(["'”’)*_]*)\s+(?=["“'(*_]*[A-Z0-9])/g;
|
||||
let m: RegExpExecArray | null;
|
||||
while ((m = re.exec(text))) {
|
||||
const end = m.index + m[1].length + m[2].length;
|
||||
const piece = text.slice(start, end);
|
||||
if (m[1] === '.' && ABBREVIATIONS.test(text.slice(start, m.index + 1))) continue;
|
||||
if (piece.trim()) out.push(piece.trim());
|
||||
start = re.lastIndex;
|
||||
}
|
||||
const rest = text.slice(start).trim();
|
||||
if (rest) out.push(rest);
|
||||
return out;
|
||||
}
|
||||
|
||||
const CHOICE_START = /^(?:\*\*)?(?:option|choice|answer|distractor)\s*(?:[A-F]|[1-6])\b/i;
|
||||
const FOLLOW_ON = /^(?:it|this|that|these|those|they|however|instead|also|because|but)\b/i;
|
||||
|
||||
export function formatRationale(text: string): string {
|
||||
const value = text.trim();
|
||||
// Already laid out, or short enough to read at a glance.
|
||||
if (value.length < 260 || /\n/.test(value)) return value;
|
||||
const sentences = splitSentences(value);
|
||||
if (sentences.length < 3) return value;
|
||||
const [lead, ...rest] = sentences;
|
||||
// The key point leads in bold, as new rationales do (unless it already has emphasis).
|
||||
const blocks: string[] = [/[*_]/.test(lead!) ? lead! : `**${lead}**`];
|
||||
let paragraph: string[] = [];
|
||||
const flush = () => {
|
||||
if (paragraph.length) blocks.push(paragraph.join(' '));
|
||||
paragraph = [];
|
||||
};
|
||||
let bullets: string[] = [];
|
||||
const flushBullets = () => {
|
||||
if (bullets.length) blocks.push(bullets.map((b) => `- ${b}`).join('\n'));
|
||||
bullets = [];
|
||||
};
|
||||
// Walk-throughs of the choices become a list when there are at least two of them.
|
||||
const choiceCount = rest.filter((s) => CHOICE_START.test(s)).length;
|
||||
for (const sentence of rest) {
|
||||
if (choiceCount >= 2 && CHOICE_START.test(sentence)) {
|
||||
flush();
|
||||
bullets.push(sentence);
|
||||
continue;
|
||||
}
|
||||
if (bullets.length) {
|
||||
// A follow-on sentence about the same choice ("It…", "This…") stays in its bullet.
|
||||
if (FOLLOW_ON.test(sentence) && sentence.length < 160) {
|
||||
bullets[bullets.length - 1] += ` ${sentence}`;
|
||||
continue;
|
||||
}
|
||||
flushBullets();
|
||||
}
|
||||
paragraph.push(sentence);
|
||||
if (paragraph.length >= 2 || paragraph.join(' ').length > 220) flush();
|
||||
}
|
||||
flush();
|
||||
flushBullets();
|
||||
return blocks.join('\n\n');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue