Home
Theme

Question Types

Code Treadmill supports six distinct question formats. Workouts may use a single type or mix several.

Read

A syntax-highlighted code snippet is displayed. The student must determine what the snippet outputs and type the answer.

Read exercises use randomized template placeholders so the values (and therefore the correct answer) change on every attempt. See the Contributing guide for the placeholder reference.

Error identification

A variant of the read format where the code contains a deliberate bug. Instead of typing an output value, the student selects the error type from a set of buttons.

Write

The student writes code in an in-browser editor. Each write exercise includes:

  • A text description of what the function should do.
  • Starter code with a function stub.
  • Visible doctest-style examples the student can see.
  • Hidden tests that run on submission and confirm correctness.

Vim keybindings are available for students who prefer them. Code is sent to the server and executed in a sandboxed container — see Architecture for details. Each language uses a different test format — see the Languages page for notes about these formats.

Parsons problems

A set of code lines is presented in scrambled order. The student drags them into the correct sequence. Parsons problems focus on understanding code structure and control flow without requiring students to recall exact syntax.

Multiple choice

A question prompt is shown with 4 answer options. The student selects one. These appear in mixed-review workouts and test conceptual understanding rather than specific output prediction.

Multiple select

Like multiple choice, but more than one answer may be correct. The student selects all that apply before submitting.

HTML/CSS live preview

The student edits an HTML/CSS snippet in an editor; a side-by-side preview updates in real time. The exercise is marked correct when the student's output visually matches a target layout.

The target is shown as a pre-generated screenshot (PNG) rather than a live iframe, so students cannot inspect the target's DOM to copy the answer.

Example HTML/CSS exercise target — box model

HTML/CSS limitations

  • No <script> tags. Iframes use sandbox="allow-same-origin", which disables script execution. This is intentional — it prevents students from injecting scripts and lets the parent window safely read contentDocument.
  • No external resources. Images, fonts, or stylesheets loaded via<link> or url() won't resolve inside the sandboxed iframe. All styling must be inline or in <style> blocks.
  • Validation is computed-style based, not pixel-perfect. Two snippets that look slightly different may still be judged correct if they produce the same computed style values.