Examplary
Start for free
Developer docs

Exam sections

Group a test's questions into titled sections with the REST API, and see how sections map to QTI assessment sections on import and export.

Sections split a test into titled parts, like "Reading" and "Writing". A test either has no sections, or every one of its questions is in a section.

Beta

Sections are in beta, available to workspaces with the exam-sections feature flag. With the flag on, teachers can add sections in the editor, and QTI imports and AI generation can create them. Students taking a test and printed tests still see one list of questions, in section order. To try sections, contact us at hi@examplary.ai.

How sections are stored

A test (an exam in the API) has a sections list, in the order they're shown. Each question points at its section with sectionId:

{
  "id": "exam_...",
  "name": "English final",
  "sections": [
    { "id": "sec_reading", "title": "Reading" },
    { "id": "sec_writing", "title": "Writing" }
  ],
  "questions": [
    { "id": "q_1", "type": "exam-intro", "sectionId": "sec_reading", ... },
    { "id": "q_2", "type": "multiple-choice-single-answer", "sectionId": "sec_reading", ... },
    { "id": "q_3", "type": "essay", "sectionId": "sec_writing", ... },
    { "id": "q_4", "type": "exam-outro", "sectionId": "sec_writing", ... }
  ]
}
FieldDescription
sections[].idAny string that's unique within the test. You pick it; Examplary uses a sec_ prefix for the IDs it creates.
sections[].titleThe title shown above the section, at most 255 characters.
questions[].sectionIdThe ID of the section the question is in. Not set, or null, in a test without sections.

Tests without sections have no sections field, or an empty list.

How questions are ordered

Whenever the questions or sections of a test change, the API puts the questions in section order and fills in every sectionId. So the questions list always reads in the right order, also for integrations that ignore sections:

  • Questions follow the order of sections. Within a section, they keep the order you sent them in.
  • The intro (exam-intro) always comes first, in the first section, and the outro (exam-outro) always comes last, in the last section, whatever their sectionId says.
  • A question without a sectionId, or with one that isn't in sections, goes into the last section.
  • When a test has no sections, every sectionId is set to null.

For example, with the sections sec_a and sec_b, these questions:

[
  { "id": "q_b1", "sectionId": "sec_b", ... },
  { "id": "q_a1", "sectionId": "sec_a", ... },
  { "id": "q_new", ... }
]

are stored as:

[
  { "id": "q_a1", "sectionId": "sec_a", ... },
  { "id": "q_b1", "sectionId": "sec_b", ... },
  { "id": "q_new", "sectionId": "sec_b", ... }
]

Adding sections

Sections are set with Update exam, together with the questions. Both sections and questions replace what the test has, so always send every section and every question. The easiest way is to start from what Get exam returns.

To try it, create an empty test first:

POST/exams
{
  "name": "English final"
}

Then give it two sections, and a question in each:

PATCH/exams/{id}
{
  "sections": [
    {
      "id": "sec_reading",
      "title": "Reading"
    },
    {
      "id": "sec_writing",
      "title": "Writing"
    }
  ],
  "questions": [
    {
      "id": "q_reading_1",
      "type": "single-line-text",
      "title": "What is the main argument of the text?",
      "settings": {},
      "sectionId": "sec_reading"
    },
    {
      "id": "q_writing_1",
      "type": "essay",
      "title": "Write a letter to the editor about the text.",
      "settings": {},
      "sectionId": "sec_writing"
    }
  ]
}

Section IDs must be unique, and every section needs an id and a title. Otherwise the request fails with a 400.

Renaming, reordering and removing sections

To change only the sections, send sections without questions. The API then re-sorts the questions to match:

  • Rename a section by changing its title.
  • Reorder sections by changing their order in the list. Their questions move with them.
  • Remove a section by leaving it out. Its questions are not deleted: they no longer point at a known section, so they move to the last section. To delete them too, also leave them out of questions.
  • Remove all sections with "sections": []. The questions stay, and their sectionId is cleared.
PATCH/exams/{id}
{
  "sections": [
    {
      "id": "sec_writing",
      "title": "Part A: Writing"
    },
    {
      "id": "sec_reading",
      "title": "Part B: Reading"
    }
  ]
}

Moving and adding questions

To move one question to another section, set its sectionId with Update question. The section must exist in the test, or the request fails with a 400:

PATCH/exams/{id}/questions/q_reading_1
{
  "sectionId": "sec_writing"
}

You can also change sectionId in the full questions list you send to Update exam.

Add question puts a question with a known sectionId in that section, and any other question in the last section. The response only shows a question's section if you passed one, so get the test to see where the others ended up.

AI generation

When the flag is on, a test made with Generate exam can come back with sections. The AI only adds them when the test has clearly distinct parts, such as different skills or units, or when the test's generation instructions (context) ask for sections.

QTI import and export

Sections map to QTI assessment sections (qti-assessment-section in QTI 3.0, assessmentSection in QTI 2.1). In QTI 3.0:

<qti-assessment-section identifier="sec_reading" title="Reading" visible="true">
  <qti-assessment-item-ref identifier="q_1" href="q_1.xml"/>
  ...
</qti-assessment-section>

Export (QTI 3 or QTI 2.1) writes one test part with a visible section for every section that has questions. The section's id becomes its identifier. Empty sections are left out, and a section without a title is named after its position, like "Section 2". A test without sections exports as a single section, SECTION-1.

Import (Import exam or Import questions) reads the test's sections:

  • Each question goes into the innermost section around its item reference. Nested sections are flattened, and each imported section gets a new sec_ ID.
  • A package with only one section imports without sections, since most tools wrap every test in one.
  • Rubric blocks for candidates, like a reading passage or instructions, become paragraph questions at the start of their section. Rubric blocks for scorers or tutors are left out.
  • Imported sections are added after the test's existing sections. If the test already has questions but no sections, those questions first go into a new section called "Section 1", so they stay at the start.
  • Without the exam-sections flag, the questions are imported without sections.

See QTI assessment items for how the questions themselves are imported.