Natural reworded openers and exam formatting on finished quizzes
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 29s

Checked against a quiz generated from four neuro and mental health
lectures:
- The opener rewording now asks for the plain, active openings a real
  exam uses and rules out inverted sentences ("Two days of vomiting have
  left a client weak", "An order is received for…"). It steps in only
  above 30% of a quiz, since the exam's most common opener was 24%.
- The finished set is tidied after review: plain stems, no closing
  period on phrase choices, and first-person choices to a "Which
  statement…" question in quotes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-16 15:17:24 -07:00
parent 39a85ebb0c
commit f738fbe7be
5 changed files with 68 additions and 15 deletions

View file

@ -10,7 +10,7 @@ describe('question openers', () => {
expect(stemOpener('The nurse is caring for…')).toBe('the nurse');
});
it('flags an opener used by more than a quarter of the quiz and keeps a spread-out share of it', () => {
it('flags an opener used by more than 30% of the quiz and keeps a spread-out share of it', () => {
const stems = [
...Array.from({ length: 16 }, (_, i) => q(`A ${40 + i}-year-old client with condition ${i} reports pain. Which action is first?`)),
...Array.from({ length: 4 }, (_, i) => q(`The nurse is caring for client ${i}. Which finding requires follow-up?`)),
@ -19,8 +19,8 @@ describe('question openers', () => {
expect(groups).toHaveLength(1);
expect(groups[0]!.opener).toBe('a #-year-old');
expect(groups[0]!.total).toBe(16);
// 20 questions allow 5 of one opener: 11 are reworded, the 5 kept are spread out.
expect(groups[0]!.reword).toHaveLength(11);
// 20 questions allow 6 of one opener: 10 are reworded, the 6 kept are spread out.
expect(groups[0]!.reword).toHaveLength(10);
expect(groups[0]!.reword).not.toContain(0);
expect(openerAdvice(stems)).toMatch(/"A 40-year-old client…"/);
});
@ -54,3 +54,25 @@ describe('plain stems', () => {
expect(plainStem('A dose of 2 * 3 mg is ordered.')).toBe('A dose of 2 * 3 mg is ordered.');
});
});
describe('plain choices', () => {
it('drops the closing period of a phrase but keeps quoted speech and longer text as written', async () => {
const { plainChoice } = await import('../server/ai/generate.ts');
expect(plainChoice('Sit the client upright and lower the legs.')).toBe('Sit the client upright and lower the legs');
expect(plainChoice('0.9% sodium chloride')).toBe('0.9% sodium chloride');
expect(plainChoice('"I will take my anticoagulant every day as prescribed."')).toBe('"I will take my anticoagulant every day as prescribed."');
expect(plainChoice('Stop the drug. Notify the provider.')).toBe('Stop the drug. Notify the provider.');
expect(plainChoice('Wait...')).toBe('Wait...');
});
});
describe('quoted statements', () => {
it('quotes first-person choices and leaves the rest alone', async () => {
const { quoteStatement } = await import('../server/ai/generate.ts');
expect(quoteStatement('I will turn him on his side and time how long it lasts')).toBe('"I will turn him on his side and time how long it lasts."');
expect(quoteStatement("We'll keep the follow-up appointment.")).toBe('"We\'ll keep the follow-up appointment."');
expect(quoteStatement('"I will call my provider."')).toBe('"I will call my provider."');
expect(quoteStatement('Increased appetite with weight gain')).toBe('Increased appetite with weight gain');
expect(quoteStatement('IV fluid boluses of normal saline')).toBe('IV fluid boluses of normal saline');
});
});