<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CNA TestBank Blog]]></title><description><![CDATA[CNA TestBank Blog]]></description><link>https://cnatestbank.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 20:57:29 GMT</lastBuildDate><atom:link href="https://cnatestbank.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Spaced Repetition for Exam Prep Apps: Implementing SM-2 in JavaScript]]></title><description><![CDATA[A compact SuperMemo 2 implementation, a sensible mapping from multiple-choice answers to quality scores, and how to apply it to a CNA question bank]]></description><link>https://cnatestbank.hashnode.dev/spaced-repetition-sm2-javascript-exam-prep</link><guid isPermaLink="true">https://cnatestbank.hashnode.dev/spaced-repetition-sm2-javascript-exam-prep</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[edtech]]></category><category><![CDATA[webdev]]></category><category><![CDATA[learning]]></category><dc:creator><![CDATA[CNA TestBank]]></dc:creator><pubDate>Thu, 26 Nov 2026 07:20:06 GMT</pubDate><content:encoded><![CDATA[<p>By Winfred, CNA TestBank</p>
<p>Cramming a question bank the night before a test feels productive and fades quickly. Spaced repetition is the usual fix: show an item again just as it is getting hard to recall, and stretch the interval as it gets easier. The SuperMemo 2 algorithm, published by Piotr Wozniak in the late 1980s and widely documented, is still a good default because it is small, testable, and easy to explain to users.</p>
<p>This article implements SM-2 in JavaScript, then maps it onto a multiple-choice healthcare practice bank — the same kind of product as the <a href="https://www.cnatestbank.com/exams/free-cna-practice-test-with-answers">free CNA practice questions</a> on CNA TestBank. It does not claim that any particular site already uses this scheduler. This is independent exam-prep education, not official examination content, and it is not affiliated with any testing vendor.</p>
<h2>The SM-2 state you have to store</h2>
<p>Each item, for each learner, carries three numbers:</p>
<ul>
<li><code>repetition</code> (n): how many times the learner has answered it successfully in a row. A failure resets this to 0.</li>
<li><code>interval</code>: the number of days until the item is due again.</li>
<li><code>easiness</code> (EF): a factor that starts at 2.5 and drifts as the learner does well or poorly, with a floor of 1.3.</li>
</ul>
<p>You also store <code>dueAt</code>, a timestamp you compute from the interval after each review. A session is then "all items that are due, plus a small number of new items," not "the entire bank in a random order."</p>
<p>The quality score <code>q</code> is an integer from 0 to 5. In the classic algorithm, a score of 3 or higher counts as a success; 0, 1, or 2 is a failure and restarts the repetition count.</p>
<h2>A straightforward implementation</h2>
<pre><code class="language-js">const MIN_EF = 1.3;
const DEFAULT_EF = 2.5;

export function reviewCard(card, quality) {
  if (quality &lt; 0 || quality &gt; 5 || !Number.isInteger(quality)) {
    throw new Error("quality must be an integer from 0 to 5");
  }

  let { repetition, interval, easiness } = card;
  easiness = easiness ?? DEFAULT_EF;
  repetition = repetition ?? 0;
  interval = interval ?? 0;

  const delta = 0.1 - (5 - quality) * (0.08 + (5 - quality) * 0.02);
  easiness = Math.max(MIN_EF, easiness + delta);

  if (quality &lt; 3) {
    repetition = 0;
    interval = 1;
  } else {
    if (repetition === 0) interval = 1;
    else if (repetition === 1) interval = 6;
    else interval = Math.round(interval * easiness);
    repetition += 1;
  }

  const dueAt = new Date();
  dueAt.setDate(dueAt.getDate() + interval);

  return { ...card, repetition, interval, easiness, quality, dueAt };
}

export function isDue(card, now = new Date()) {
  if (!card.dueAt) return true;
  return new Date(card.dueAt) &lt;= now;
}
</code></pre>
<p>That is the whole scheduler. The first successful review comes back in one day, the second in six days, and later reviews are <code>round(interval * easiness)</code> days later. A miss does not throw the item out of the bank; it puts it back on tomorrow's list and lets the easiness factor drop so future intervals grow more slowly.</p>
<p>A tiny set of tests will save you from off-by-one bugs in the first two repetitions:</p>
<pre><code class="language-js">const fresh = { repetition: 0, interval: 0, easiness: 2.5 };

const pass1 = reviewCard(fresh, 5);
// pass1.interval === 1, pass1.repetition === 1

const pass2 = reviewCard(pass1, 4);
// pass2.interval === 6, pass2.repetition === 2

const pass3 = reviewCard(pass2, 5);
// pass3.interval === Math.round(6 * pass3.easiness) after the EF update

const miss = reviewCard(pass3, 1);
// miss.repetition === 0, miss.interval === 1
</code></pre>
<p>Keep the function pure. Persist the returned object. If you mutate the card in place and also write an optimistic UI, you will lose a review when a save fails.</p>
<h2>Mapping a multiple-choice attempt to a quality score</h2>
<p>SM-2 was designed for recall cards ("What is the capital of France?"). A four-option CNA item is a recognition task, and a lucky guess looks like mastery if you treat every green check as a 5. You need a mapping that is honest about that.</p>
<p>A practical scale for a practice-test UI:</p>
<ul>
<li>0 — skipped, or timed out with no answer.</li>
<li>1 — incorrect, and the learner flagged it as a guess or answered very quickly.</li>
<li>2 — incorrect after some thought.</li>
<li>3 — correct, but slow, or the learner changed the answer before submitting.</li>
<li>4 — correct at a normal pace, no change of mind.</li>
<li>5 — correct and fast, or the learner later self-rates "I knew this cold."</li>
</ul>
<p>You can implement the middle of that scale without a self-rating widget. Capture elapsed time, whether the selected radio changed, and whether the answer was right. Then:</p>
<pre><code class="language-js">function qualityFromAttempt({ correct, elapsedMs, changedAnswer, skipped }) {
  if (skipped) return 0;
  if (!correct) return elapsedMs &lt; 8000 ? 1 : 2;
  if (changedAnswer || elapsedMs &gt; 45000) return 3;
  if (elapsedMs &lt; 12000) return 5;
  return 4;
}
</code></pre>
<p>The time thresholds are product choices, not laws. Clinical stems on a site like <a href="https://www.cnatestbank.com/exams/free-cna-practice-test-with-answers">CNA TestBank</a> are longer than flashcard prompts, so a twelve-second "fast" cutoff that works for a vocabulary deck will punish careful reading. Raise the thresholds for long stems, or drop time from the mapping and ask one question after the rationale: "Could you have explained this without the options?" Yes becomes a 5, "I was pretty sure" a 4, and "I guessed" a 3 even when the answer was correct. An honest 3 is more useful than a vanity 5.</p>
<p>Never award a 3 or higher for a wrong answer, even if the learner says the rationale now makes sense. SM-2 already brings failures back tomorrow. If you want a "teach me this again in ten minutes" button, put the item on a same-day queue instead of inflating <code>quality</code>.</p>
<h2>Applying the scheduler to a CNA question bank</h2>
<p>A nurse aide practice bank is not a stack of isolated facts. Items cluster by domain — safety, infection control, resident rights, ADLs, transfers, emergencies — and a learner who is weak on gait belts needs more than whichever single item happens to be due.</p>
<p>Use SM-2 at the item level, then add a thin layer on top:</p>
<ol>
<li>Pull every due item, as the algorithm requires.</li>
<li>If the due list is short, fill the session with new items from the learner's weakest domain, not with random leftovers from a topic they already handle well.</li>
<li>Cap new items per day so a 400-item bank cannot bury the reviews that are actually due.</li>
<li>After the session, show a domain report ("transfers: 4 of 9 correct") alongside the next due date. The report is for the human; the due dates stay per item.</li>
</ol>
<p>Store scheduling state next to the attempt, using the same <code>item_id</code> and <code>item_version</code> you would use in a versioned question schema. If an item's wording changes substantially, start a fresh card. A rewritten stem is not the memory the old interval was measuring.</p>
<p>Do not hide the schedule. A simple line — "This item comes back in 6 days" — teaches the learner what the system is doing and reduces the urge to smash through the whole bank in one sitting. That habit is the thing spaced repetition is trying to prevent.</p>
<h2>Limits worth being honest about</h2>
<p>SM-2 is old. Newer schedulers such as FSRS model memory with more parameters and often need less babysitting, but they also need more review history before they shine. For an exam-prep app with a few hundred items and learners who may only <a href="https://www.cnatestbank.com/blogs/how-to-pass-the-cna-exam-on-the-first-try-proven-tips">study for two weeks</a>, SM-2 is usually enough.</p>
<p>It will not fix a bad item. If two options are defensible, the algorithm will keep surfacing confusion. It will not tell a CNA candidate whether they are ready for a <a href="https://www.cnatestbank.com/cna-clinical-skills-checklist">state skills test</a>; a written practice bank only measures written practice. And it will not invent official exam weights. Use it to time the next review, then send people back to clear explanations, such as the rationales on <a href="https://www.cnatestbank.com/exams/free-cna-practice-test-with-answers">CNA TestBank</a>, to do the actual learning.</p>
<p>If you ship only one feature from this article, ship the card state and the due list. The mapping from clicks to <code>q</code> can be tuned later. The important decision is to treat each item as a memory you are willing to see again tomorrow, not as a deck to burn through once.</p>
]]></content:encoded></item><item><title><![CDATA[Building an Accessible Quiz UI: ARIA, Keyboard Navigation and Instant Feedback]]></title><description><![CDATA[How to ship a multiple-choice practice test that works with a keyboard and a screen reader, with lessons from CNA-style clinical items]]></description><link>https://cnatestbank.hashnode.dev/accessible-quiz-ui-aria-keyboard-feedback</link><guid isPermaLink="true">https://cnatestbank.hashnode.dev/accessible-quiz-ui-aria-keyboard-feedback</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Accessibility]]></category><category><![CDATA[a11y]]></category><category><![CDATA[webdev]]></category><category><![CDATA[edtech]]></category><dc:creator><![CDATA[CNA TestBank]]></dc:creator><pubDate>Thu, 26 Nov 2026 07:19:24 GMT</pubDate><content:encoded><![CDATA[<p>By Winfred, CNA TestBank</p>
<p>Most quiz interfaces look fine on a laptop with a mouse and fail as soon as someone Tabs through them. The stem is not tied to the choices, the selected option is only indicated with a light-blue border, feedback appears in a green box that a screen reader never hears, and after Submit the focus stays on a now-disabled button. None of that is hard to fix if you treat the quiz as a form, not a card deck with click handlers.</p>
<p>This article walks through a compact HTML and JavaScript pattern for a single-best-answer item: a labelled radio group, full keyboard support, and instant feedback that does not rely on color alone. The examples are written for long clinical stems of the kind you will see on a nurse aide practice test, such as the items on <a href="https://www.cnatestbank.com/exams/free-cna-practice-test-with-answers">CNA TestBank</a>. This is independent exam-prep education, not official examination content, and it is not affiliated with any testing vendor.</p>
<h2>Start with a real form control</h2>
<p>Use native radio buttons. They already implement the arrow-key behavior people expect, they participate in form validation, and they do not require you to re-create roving tabindex. Wrap the group in a <code>fieldset</code> whose <code>legend</code> is the lead-in, and put the longer stem in a heading or paragraph that the group is labelled by.</p>
<pre><code class="language-html">&lt;section class="quiz" aria-labelledby="q-heading"&gt;
  &lt;h2 id="q-heading"&gt;Question 4 of 20&lt;/h2&gt;
  &lt;p id="q-stem"&gt;
    A resident in a wheelchair asks the nurse aide to help him stand
    and walk to his room. The wheelchair brakes are unlocked.
  &lt;/p&gt;

  &lt;form id="quiz-form"&gt;
    &lt;fieldset aria-describedby="q-stem"&gt;
      &lt;legend&gt;What should the nurse aide do first?&lt;/legend&gt;

      &lt;label&gt;
        &lt;input type="radio" name="answer" value="A" /&gt;
        Walk beside him without a gait belt so he can leave quickly.
      &lt;/label&gt;
      &lt;label&gt;
        &lt;input type="radio" name="answer" value="B" /&gt;
        Lock the wheelchair brakes, then help him stand using a gait
        belt if one is indicated.
      &lt;/label&gt;
      &lt;label&gt;
        &lt;input type="radio" name="answer" value="C" /&gt;
        Tell him to stand while the aide holds the chair with one foot.
      &lt;/label&gt;
      &lt;label&gt;
        &lt;input type="radio" name="answer" value="D" /&gt;
        Get the nurse before locking the brakes.
      &lt;/label&gt;
    &lt;/fieldset&gt;

    &lt;button type="submit" id="submit-btn"&gt;Check answer&lt;/button&gt;
    &lt;div id="feedback" class="feedback" hidden&gt;&lt;/div&gt;
  &lt;/form&gt;
&lt;/section&gt;
</code></pre>
<p>The question number is a heading, which gives screen-reader users a landmark when they move to the next item. The stem is connected with <code>aria-describedby</code> so it is read with the group, not stranded above a set of unlabeled controls. Visible <code>&lt;label&gt;</code> text is the choice, not a separate "Option A" chip that a mouse user can click and a keyboard user cannot. The stem is a typical <a href="https://www.cnatestbank.com/topics/mobility-transfers">transfer-safety</a> item: unlocked brakes, then the aide's first action.</p>
<p>Do not replace the radios with styled <code>div</code>s and <code>role="radio"</code> unless you are prepared to implement the entire APG radio-group pattern, including arrow keys, Space, <code>aria-checked</code>, and a single tab stop. Native inputs plus CSS are almost always less work.</p>
<h2>Keyboard behavior you should not break</h2>
<p>With native radios, Tab moves into the group and onto the checked radio (or the first one if none is checked). Arrow keys move between choices. Tab again moves to Submit. Leave that alone. Avoid breaking it:</p>
<ul>
<li>Do not put <code>tabindex="0"</code> on every label or card. That adds extra stops and makes Arrow keys compete with Tab.</li>
<li>Do not handle <code>Enter</code> on the radios yourself if the control is inside a form. Enter should submit the form.</li>
<li>After the learner submits, move focus to the feedback region so keyboard and screen-reader users are not left sitting on a disabled button, wondering whether anything happened.</li>
<li>The Next question button should appear in the feedback region or immediately after it, not at the top of the card.</li>
</ul>
<p>A compact submit handler looks like this:</p>
<pre><code class="language-js">const form = document.getElementById("quiz-form");
const feedback = document.getElementById("feedback");
const KEY = "B";
const WHY = {
  A: "Speed is not the first concern. Unlocking is a fall risk.",
  B: "Locking the brakes removes the immediate fall risk.",
  C: "A foot on the wheel is not a substitute for locked brakes.",
  D: "Locking brakes for a routine transfer is in the aide role."
};

form.addEventListener("submit", (event) =&gt; {
  event.preventDefault();
  const picked = form.elements.answer.value;
  if (!picked) {
    feedback.hidden = false;
    feedback.className = "feedback";
    feedback.setAttribute("role", "alert");
    feedback.innerHTML = "&lt;p&gt;Select an answer before checking.&lt;/p&gt;";
    feedback.focus();
    return;
  }

  const ok = picked === KEY;
  feedback.hidden = false;
  feedback.className = ok ? "feedback is-correct" : "feedback is-wrong";
  feedback.setAttribute("tabindex", "-1");
  feedback.setAttribute("role", "region");
  feedback.setAttribute("aria-label", "Answer feedback");
  feedback.innerHTML = `
    &lt;h3&gt;${ok ? "Correct" : "Not quite"}&lt;/h3&gt;
    &lt;p&gt;${WHY[picked]}&lt;/p&gt;
    &lt;button type="button" id="next-btn"&gt;Next question&lt;/button&gt;
  `;
  form.querySelectorAll("input[name=answer]").forEach((el) =&gt; {
    el.disabled = true;
  });
  document.getElementById("submit-btn").disabled = true;
  feedback.focus();
});
</code></pre>
<p>Two details matter for assistive technology. First, the empty-state message uses <code>role="alert"</code> so it is announced immediately. The scored feedback uses a focusable region instead of a live region that might be easy to miss on a long rationale. Second, disabling the radios after scoring prevents a learner from silently changing the answer while still hearing the old explanation.</p>
<h2>Instant feedback without relying on color</h2>
<p>Color is allowed; color as the only signal is not. Mark the correct choice and the selected choice with text, an icon that has an accessible name, or both. A green border around B and a red border around C is invisible to many people and meaningless when the page is printed or forced into high contrast.</p>
<pre><code class="language-css">.feedback { outline: none; margin-top: 1rem; padding: 1rem; }
.feedback.is-correct { border-left: 4px solid #0b7a43; }
.feedback.is-wrong { border-left: 4px solid #b42318; }
label:has(input:checked) { font-weight: 600; }
label:has(input:disabled) { opacity: 0.9; }
</code></pre>
<p>In the markup for a scored item, append a visually available word, not only a class name: "Your answer — not correct" next to the chosen label, and "Correct answer" next to the key. If you reveal all four rationales on Review, keep them in the DOM as real text, not as a tooltip that only appears on hover.</p>
<p>Clinical stems, including <a href="https://www.cnatestbank.com/hardest-cna-exam-questions">harder exam-style items</a>, can run to several sentences. That is a feature, not a layout bug. Let the stem wrap. Do not truncate it, and do not put the only copy of the stem inside a canvas or a background image. Learners who zoom to 200 percent still need to read the last clause; that clause is often where "first," "best," or "the nurse aide" appears, and missing it is how people fall for a distractor.</p>
<h2>Timing, motion, and long sessions</h2>
<p>If you offer a timed mode, expose the remaining time in a visible element and update it on a modest interval. A live region that announces every second will drown out the question. Announcing once per minute, plus a warning at the last minute, is plenty. Never make the timer the only way to submit; a keyboard user who is still on the last choice should not lose the item without a chance to check it.</p>
<p>Respect <code>prefers-reduced-motion</code>. A sliding card transition is a pleasant flourish until it makes a screen-reader cursor or a keyboard focus indicator lag behind the content. Swap the item, update the heading ("Question 5 of 20"), and move focus to that heading or to the fieldset. The heading change is also what makes a long practice session navigable with a heading rotor.</p>
<p>Finally, do not auto-advance after a correct answer. Instant feedback is only useful if the learner has time to read the rationale. Auto-advance is especially hostile with a screen reader, which may still be announcing "Correct" when the next stem replaces the node.</p>
<h2>A short test plan</h2>
<p>Before you ship, walk through one item with the keyboard only, then with a screen reader, then at 200 percent zoom:</p>
<ol>
<li>Tab into the group, change the selection with arrow keys, and submit with Enter.</li>
<li>Confirm the feedback heading takes focus and can be read in full.</li>
<li>Confirm the Next button is the next tab stop, and that the question heading updates.</li>
<li>Confirm a skipped submit ("Check answer" with nothing selected) is announced.</li>
<li>Confirm correct and incorrect states are still obvious with a grayscale filter or in forced-colors mode.</li>
</ol>
<p>If you want a live product to compare against, work a few items on <a href="https://www.cnatestbank.com/exams/free-cna-practice-test-with-answers">CNA TestBank</a> and ask whether each stem, choice, and rationale can be reached without a mouse. An accessible quiz is the difference between a practice test people can use and a pretty card that only looks like one.</p>
]]></content:encoded></item><item><title><![CDATA[Designing a Multiple-Choice Question Bank Schema for Healthcare Exam Prep]]></title><description><![CDATA[A practical data model for stems, per-choice rationales, skill tags, and safe content versioning, with JSON and Postgres examples]]></description><link>https://cnatestbank.hashnode.dev/question-bank-schema-healthcare-exam-prep</link><guid isPermaLink="true">https://cnatestbank.hashnode.dev/question-bank-schema-healthcare-exam-prep</guid><category><![CDATA[database]]></category><category><![CDATA[postgres]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[edtech]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[CNA TestBank]]></dc:creator><pubDate>Thu, 26 Nov 2026 07:17:02 GMT</pubDate><content:encoded><![CDATA[<p>By Winfred, CNA TestBank</p>
<p>A weekend quiz app can get by with four option columns and a <code>correct_index</code>. A healthcare exam-prep bank cannot. Add a rationale, a curriculum tag, or a typo fix, and that model starts lying: learners replay a changed item as if it were the same card, and you cannot explain why option B is wrong.</p>
<p>This article sketches a data model for multiple-choice healthcare practice banks. The running example is nurse aide exam prep — the same kind of product as the <a href="https://www.cnatestbank.com/exams/free-cna-practice-test-with-answers">free practice questions</a> on CNA TestBank — but the shape works for any study tool where the explanation matters as much as the key. This is independent exam-prep education, not official examination content, and it is not affiliated with any testing vendor or state registry.</p>
<h2>What the data has to remember</h2>
<p>Write the jobs down before you draw tables:</p>
<ul>
<li>A stem, a lead-in, and a small set of mutually exclusive options, with exactly one correct choice on a standard item.</li>
<li>A rationale for the correct option <em>and</em> a short reason each distractor fails. Learners who only read why the key is right keep missing the same trap.</li>
<li>Tags for curriculum domain (infection control, resident rights, safety, ADLs) and, optionally, a skill name such as gait-belt use.</li>
<li>A stable public identifier plus a version, so progress history can point at the wording a person actually saw.</li>
<li>An editorial state: draft, in review, published, retired.</li>
</ul>
<p>If your model cannot answer "show me the exact wording this user saw on 3 March," it is not ready.</p>
<h2>A JSON document for one item</h2>
<p>JSON is a good design sketch even if Postgres is the system of record:</p>
<pre><code class="language-json">{
  "itemId": "cna-safety-0018",
  "version": 3,
  "status": "published",
  "kind": "single_best_answer",
  "stem": "A resident in a wheelchair asks the nurse aide to help him stand and walk to his room. The wheelchair brakes are unlocked.",
  "leadIn": "What should the nurse aide do first?",
  "choices": [
    {
      "key": "A",
      "text": "Walk beside him without a gait belt so he can leave quickly.",
      "correct": false,
      "rationale": "Speed is not first. An unlocked wheelchair and no gait belt are unsafe."
    },
    {
      "key": "B",
      "text": "Lock the wheelchair brakes, then help him stand using a gait belt if one is indicated.",
      "correct": true,
      "rationale": "Locking the brakes removes an immediate fall risk, then an indicated gait belt is used."
    },
    {
      "key": "C",
      "text": "Tell him to stand while the aide holds the chair with one foot.",
      "correct": false,
      "rationale": "A foot on the wheel is not a substitute for locked brakes."
    },
    {
      "key": "D",
      "text": "Get the nurse before locking the brakes, because only a nurse may touch a wheelchair.",
      "correct": false,
      "rationale": "Locking brakes and using a gait belt for a routine transfer are in the aide role."
    }
  ],
  "domains": ["safety", "transfers"],
  "skillTags": ["gait-belt", "wheelchair-brakes"],
  "disclaimer": "Practice item for study. Not an official exam question."
}
</code></pre>
<p>The business key (<code>itemId</code>) is separate from <code>version</code>. Keep the lead-in in its own field so the UI can announce a reusable prompt such as "What should the nurse aide do first?" Each choice carries its own rationale, which stays aligned when options are shuffled. Status and a disclaimer live on the item so a renderer does not invent them.</p>
<p>Validate on the write path, not only in the client:</p>
<pre><code class="language-js">function assertItem(item) {
  if (!item.itemId || !Number.isInteger(item.version)) {
    throw new Error("itemId and integer version are required");
  }
  const keys = item.choices.map((c) =&gt; c.key);
  if (new Set(keys).size !== keys.length) {
    throw new Error("choice keys must be unique");
  }
  const correct = item.choices.filter((c) =&gt; c.correct);
  if (item.kind === "single_best_answer" &amp;&amp; correct.length !== 1) {
    throw new Error("single_best_answer items need exactly one correct choice");
  }
  if (item.choices.some((c) =&gt; !c.text?.trim() || !c.rationale?.trim())) {
    throw new Error("every choice needs text and a rationale");
  }
}
</code></pre>
<h2>Relational tables that survive editorial work</h2>
<p>When several authors review items, a relational model is easier to trust than a pile of documents:</p>
<pre><code class="language-sql">CREATE TYPE item_status AS ENUM ('draft', 'in_review', 'published', 'retired');

CREATE TABLE question_item (
  id           bigserial PRIMARY KEY,
  item_id      text NOT NULL,
  version      integer NOT NULL CHECK (version &gt; 0),
  status       item_status NOT NULL DEFAULT 'draft',
  stem         text NOT NULL,
  lead_in      text NOT NULL,
  disclaimer   text NOT NULL,
  published_at timestamptz,
  UNIQUE (item_id, version)
);

CREATE UNIQUE INDEX question_item_one_published
  ON question_item (item_id)
  WHERE status = 'published';

CREATE TABLE question_choice (
  id         bigserial PRIMARY KEY,
  item_pk    bigint NOT NULL REFERENCES question_item (id) ON DELETE CASCADE,
  key        char(1) NOT NULL,
  body       text NOT NULL,
  is_correct boolean NOT NULL,
  rationale  text NOT NULL,
  UNIQUE (item_pk, key)
);

CREATE UNIQUE INDEX question_choice_one_correct
  ON question_choice (item_pk)
  WHERE is_correct;

CREATE TABLE question_domain (
  item_pk bigint NOT NULL REFERENCES question_item (id) ON DELETE CASCADE,
  domain  text NOT NULL,
  PRIMARY KEY (item_pk, domain)
);

CREATE TABLE attempt_answer (
  id           bigserial PRIMARY KEY,
  user_id      bigint NOT NULL,
  item_id      text NOT NULL,
  item_version integer NOT NULL,
  choice_key   char(1) NOT NULL,
  is_correct   boolean NOT NULL,
  answered_at  timestamptz NOT NULL DEFAULT now()
);
</code></pre>
<p>The partial unique index on <code>published</code> is the constraint that matters: version 2 can stay live while version 3 sits in review. Attempts store <code>item_id</code> plus <code>item_version</code>, not a pointer to "whatever is published today," so a later typo fix does not rewrite last week's history. The second partial unique index enforces a single correct choice and will catch a bad bulk import.</p>
<h2>Tagging by domain and skill</h2>
<p>Tags are how you build a study session, show a weak-area report, and keep a bank from over-representing one topic.</p>
<p>Use a controlled vocabulary for domains and a looser list for skill tags. For nurse aide prep, a practical domain set is safety, infection control, resident rights, communication, vital signs, ADLs, mobility and transfers, nutrition, elimination, emergencies, and restorative care. Skill tags such as <code>gait-belt</code> let you drill a <a href="https://www.cnatestbank.com/topics/mobility-transfers">transfer procedure</a> without treating it as a whole domain. Avoid a free-text <code>tags</code> column or you will spend a year merging <code>Infection Control</code> and <code>IPC</code>. If an item spans two domains, attach both.</p>
<h2>Versioning without destroying history</h2>
<p>Published wording should be immutable. A typo fix or a rewritten rationale is a new <code>version</code>. Retire the old row only after the new row is published. The public URL can keep using <code>item_id</code>; scoring must receive the version.</p>
<pre><code class="language-sql">BEGIN;
  UPDATE question_item
     SET status = 'retired'
   WHERE item_id = 'cna-safety-0018' AND status = 'published';

  UPDATE question_item
     SET status = 'published', published_at = now()
   WHERE item_id = 'cna-safety-0018' AND version = 3 AND status = 'in_review';
COMMIT;
</code></pre>
<p>Run the swap in a transaction so you never have zero published rows. Shuffle choices for display if you want, but persist keys (<code>A</code>, <code>B</code>, <code>C</code>, <code>D</code>) as stable identifiers, not display indexes.</p>
<p>Keep a single server-side command that copies <code>item_id</code>, increments <code>version</code>, starts in <code>draft</code>, runs <code>assertItem</code>, and inserts the item, choices, and tags together. Partial writes are how empty options reach production.</p>
<h2>What you should not store</h2>
<p>A practice bank for a regulated exam attracts pressure to look official. Resist that in the schema as well as in the copy. Do not add columns for "official item number" or "exam weight" unless you have licensed content and a contract to store it. Independent sites such as <a href="https://www.cnatestbank.com/exams/free-cna-practice-test-with-answers">CNA TestBank</a> write original practice items. A <code>source</code> field can record an author and a review date; it should not imply an affiliation you do not have. Do not delete items that have attempts hanging off them — retire them.</p>
<p>If you want a concrete product to test a model like this against, work through a session on <a href="https://www.cnatestbank.com/exams/free-cna-practice-test-with-answers">CNA TestBank</a> and list what the data must support: a clinical stem, one best answer, a rationale, and a bank that can grow without silently rewriting history. A clean schema will not make an item well written. It will keep a well-written item trustworthy after the hundredth edit.</p>
]]></content:encoded></item></channel></rss>