Skip to content
Learnomy

Rich Question Stems

A rich question stem is an optional formatted passage, code block, or image shown above the answer choices for any question type. It gives students the material they need to answer, without cluttering the plain question prompt.

What you can do

  • Add a formatted passage (headings, lists, bold, links) above the answers of any question.
  • Paste a code block for programming or scripting questions.
  • Insert an image, chart, or diagram that the question refers to.
  • Use one stem across every question type: multiple choice, true/false, short answer, fill in the blank, essay, and the Pro types.
  • Author the stem in wp-admin (Question Bank editor) or in the Pro front-end course builder. The same stem renders in every quiz that uses the question.
  • Keep the stem separate from the question prompt, so a reading passage or dataset is shown once and the actual question stays short.

Rich question stem editor

How to use it

  1. Go to Learnomy > Question Bank.
  2. Click Add Question to create a new question, or click Edit on an existing one.
  3. In the Question Details section, type the question prompt into the Question Text field as usual.
  4. Below it, find the Passage / Context (optional) field. This is the rich stem editor.
  5. Click into the editor and add your content. It supports formatting, so you can add a passage, a code block, or an image that appears above the answers.
  6. Fill in the rest of the question (type, answers, category, difficulty, status) as normal.
  7. Save the question. The stem is stored on the question, so every quiz that uses this question shows the same stem.
  8. Preview the quiz as a student. The stem renders above the answer choices in every quiz layout (focused, classic, sectioned, conversational, and the review board).

Instructors using Learnomy Pro can author the same stem from the front-end course builder when adding or editing a question. The stem field behaves the same way and writes to the same place.

Settings & options

  • Field label: Passage / Context (optional). Found in the Question Bank editor under Question Details.
  • Storage: the stem is saved to its own stem column on the lrn_questions table (added in migration 3_12_0). It never overlaps the fill-in-the-blank token body, which stays in the content field.
  • Passage / Context vs Additional Context: the rich Passage / Context field supports formatting, code, and images. The separate Additional Context (plain text) field is plain text only. Use the rich field when you need formatting.
  • Sanitizing: stem content is cleaned on save through the shared content engine, so it stores as canonical, round-trip-safe HTML and renders the same way lessons and courses do. When the HTML content model is switched off (via the learnomy_store_content_as_html filter), the stem falls back to wp_kses_post sanitizing.
  • Rendering: the stem is rendered server-side and escaped before display. It is shown above the answers in all five quiz templates and is hidden automatically when a question has no stem.

For developers

  • Storage column: lrn_questions.stem (longtext), introduced in includes/db/migrations/class-migration-3_12_0.php.
  • Sanitizing helper: \Learnomy\prepare_question_stem( string $raw ): string in includes/functions.php. It routes through \Learnomy\Content\Content_HTML::for_storage() when HTML storage is enabled, otherwise wp_kses_post.
  • Kill switch: the learnomy_store_content_as_html filter controls whether the stem (and all content) stores as canonical HTML or plain kses'd markup.
  • REST field: send stem (string, Editor.js JSON or HTML) on the question create and update endpoints under the learnomy/v1 namespace (for example POST /learnomy/v1/questions and the per-question update route). It is defined in question_args() in includes/api/class-questions-controller.php with no arg-level sanitize, because sanitizing happens at the storage layer so block JSON is not stripped.
  • Editor field: the wp-admin mount point is #lrn-question-stem with the hidden serialising input name="stem" (#lrn-question-stem-input), wired in assets/js/admin/question-editor.js and rendered by includes/admin/views/question-editor.php.
  • Templates: each quiz layout renders the stem into .lrn-quiz-question__stem from the per-item stemHtml value (see templates/quiz/classic.php, focused.php, sectioned.php, conversational.php, and review-board.php).

Related