single
One coded answer from a list of options. The most common question type. Five styles cover the contexts a survey programmer typically needs.
What single is
single collects exactly one answer from a list of authored options.
The respondent picks one; everything else is ignored. The stored
answer is the option’s numeric code — not its label.
- qid: QBrand
type: single
text: Which brand do you prefer?
options:
1: Apple
2: Samsung
3: Sony
4: LG
Properties
| Property | Values | Notes |
|---|---|---|
qid | string | Required. Unique within the survey. |
type | single | Required. |
title, text, instruction | renderable | Visible content. Use {{ }} to pipe runtime values. HTML allowed. |
required | True | False | Default True. |
default.errors | True | False | custom string | Default True (uses the platform’s required-field message). |
validation | code block | Python; call fail() to reject. No default. |
readonly | True | False | Default False. Set True to render the question but disable input — the respondent sees it but can’t change the value. Used with scripts that prefill or compute a value. Pair with visibility: hide to fully hide a helper question. |
visibility | show | hide | Default show. Override the default render state. |
style | radio | dropdown | buttons | cards | image_cards | Default radio. |
order | fixed | random | randomEach | flip | alphabetical | reverse | Default fixed. How options are arranged. See below. |
group.order | same as order | Default fixed. Order of named groups when group: is used. |
layout.cols | integer | Default 1. Number of columns. |
options | list name or inline domain | Required when group: is not used. |
options.from | expression | Filter the visible options at runtime. No default. |
group | grouped list name | Required when options: is not used. |
custom | code block | Custom runtime block. No default. |
order values
| Value | Behaviour |
|---|---|
fixed | Render options in authored order. Default. |
random | Stable random order — shuffled once per respondent, reused every time the question renders for them. |
randomEach | Re-shuffle every time the question is rendered. Relevant inside loops, where the same question renders once per iteration. |
flip | Deterministic split sample — half the respondents see authored order, half see reversed. The assignment is made once per respondent and reused across every flip surface in the survey, so a respondent’s order is consistent throughout. |
alphabetical | Sort options alphabetically by label. |
reverse | Render in reversed authored order for every respondent. |
group.order and scale.order (on grids) accept the same values
and behave the same way against the group / scale dimension.
Group properties
When using group: to subdivide options, each named group can carry:
| Property | Values | Notes |
|---|---|---|
options | grouped option entries | Required. |
show.label | True | False | Default True. Set False to hide the group header label. |
anchor | True | False | Default False. Set True to pin the group in place under group.order: random. |
Per-option properties
Expand an option to a map to attach extra behaviour.
| Property | Values | Notes |
|---|---|---|
label | renderable | Required when expanding the option. Display text. Use {{ }} to pipe runtime values. |
image | URL string | Required for every option under style: image_cards; optional under style: cards. |
anchor | True | False | Default False. Set True to pin in place under order: random. |
specify | True | False | Default False. Set True to attach a free-text input to this option. |
specify.size | integer | Width of the specify input field (chars). No default — platform sizes the input automatically. |
specify.maxChar | integer | Max length of the specify text. No default — unlimited unless set. |
data | object | Metadata object for advanced authoring (custom code can read it). No default. |
options:
1: Apple
2: Samsung
3:
label: Other (please specify)
specify: True
specify.maxChar: 50
anchor: True
Methods & accessors
The runtime values you read in scripts, conditions, validation, and
piping. Return types are exact — see the
Glossary for what Code, CodeSet, Label
mean.
Accessors
| Expression | Returns | Meaning |
|---|---|---|
Q.value | Code | The chosen option code (number). None if unanswered. |
Q.selected | CodeSet | Collection containing the one chosen code. |
Q.selectedLabel | Label | Display label of the chosen option. None if unanswered. |
Q.all | CodeSet | All visible option codes (the effective domain). |
Q.allLabels | LabelList | Labels for Q.all. |
Q.answered | bool | True once the respondent has picked an option. |
Q.notAnswered | bool | Inverse of answered. |
Methods
| Expression | Returns | Meaning |
|---|---|---|
Q.set(N) | None | Set the answer to code N (one numeric code). Used in scripts on hidden helpers. |
Q.reset() | None | Clear the answer. |
Q.specify(N) | SpecifyObject | Read the specify text for option N (when that option has specify: True). |
Collection operations on Q.selected
The methods that read naturally on a single selection:
| Expression | Returns | Meaning |
|---|---|---|
Q.selected.size | int | Count of selected codes. 0 or 1 for single. |
Q.selected.any(N) | bool | True if code N is selected. |
Q.selected.any([1, 2]) | bool | True if any of the listed codes is selected. |
Q.selected.intersect([1, 2, 3]) | CodeSet | New collection of overlap between the selection and the list. Non-empty result is truthy in if. |
The same operations also work on Q.all and Q.allLabels. The full
set (.every, .union, .minus) lives on every collection — see
Collections for the full reference. On
single, those broader methods are rarely used.
Q.value returns a Code — a number — not a string. Compare with QBrand.value == 2, not == “2”. Q.selected contains numbers too: {2}, not {"2"}.Skins
Five visual styles. Pick by context — option count, label length, and whether the choice has a visual component.
radio Radio (default) cards Cards buttons Buttons image_cards Image cards dropdown Dropdown For really long lists (50+ rows like states or hospitals), prefer
lookup with type-ahead search over a
plain dropdown — it lets the respondent type to filter.
The exact appearance is driven by theme tokens — colours, radii, fonts. Every survey is themable from the theme builder; the previews above use defaults. See Customisation and Skin variants.
See it work
A quick interactive preview. Pick an option and the Live state panel shows what the runtime stores.
QBrand.answeredFalseQBrand.valueNoneQBrand.selected{}QBrand.selectedLabelNoneQBrand.selected.size0- qid: QBrand
type: single
text: Which brand do you prefer?
options:
1: Apple
2: Samsung
3: Sony
4: LG
5: None of these
Methods & accessors — live
The same preview shape, paired with a panel of expressions evaluating against the current selection. Pick an option above and watch each expression’s return value.
QBrand.answered → — QBrand.notAnswered → — QBrand.value → — QBrand.selected → — QBrand.selectedLabel → — QBrand.selected.size → — QBrand.selected.any(2) → — QBrand.selected.any([1, 2]) → — QBrand.selected.intersect([1, 2, 3]) → — QBrand.selected.intersect([1, 2, 3]).size → — QBrand.value == 2 → — QBrand.all.size → — A few things to notice as you click:
valueis a number. Pick “Samsung” andQBrand.valueis2, not"2". Compare with unquoted numbers:QBrand.value == 2.selectedis always a collection, even thoughsinglestores one code. The same routing patterns work acrosssingle,multi,rank, and grid rows because all of them expose.selectedas a collection..sizereturns the count. Forsinglethat’s0or1; formultiandrankit can be larger. The method is the same — the question type determines the range of values..any([1, 2])and.intersect([1, 2, 3])shine for screeners. Adding or removing qualifying codes is a list edit, not an operator change.
Examples
Screener — terminate the unqualified
- qid: QRole
type: single
text: Which best describes your role?
options:
1: Lab Director
2: Lab Manager
3: Nurse
4:
label: Other
specify: True
anchor: True
- script: |
if not QRole.selected.any([1, 2]):
endSurvey(status="terminate", redirect="https://example.com/thanks")
Anyone outside Lab Director / Lab Manager is terminated. The list
form (any([1, 2])) lets you add qualifying codes later without
touching the operator.
Conditional follow-up
- qid: QSatisf
type: single
text: How satisfied are you?
style: buttons
options:
1: Very satisfied
2: Satisfied
3: Neutral
4: Dissatisfied
5: Very dissatisfied
- qid: QWhy
type: open
text: What would have made it better?
if: QSatisf.selected.any([4, 5])
style: textarea
input.rows: 4
QWhy only shows for the dissatisfied. The if: is evaluated once,
when the platform decides whether to render QWhy.
Pipe the chosen label into a follow-up
- qid: QBrand
type: single
text: Which brand do you prefer?
options: brandList
- qid: QWhy
type: open
text: What do you like about {{ QBrand.selectedLabel }}?
style: textarea
input.rows: 3
If they pick “Samsung”, the next page asks “What do you like about
Samsung?” — selectedLabel returns the label, not the code.
Hidden helper computed by a script
- qid: QState
type: single
text: In which state are you employed?
style: dropdown
options: states
- script: |
# Group states into Census regions for downstream cuts.
if QState.selected.any([1, 4, 9, 10, 17]): hRegion.set(1) # Northeast
elif QState.selected.any([2, 3, 5, 6, 11]): hRegion.set(2) # South
elif QState.selected.any([7, 8, 19, 20]): hRegion.set(3) # Midwest
else: hRegion.set(4) # West
- qid: hRegion
type: single
options:
1: Northeast
2: South
3: Midwest
4: West
visibility: hide
readonly: True
required: False
hRegion.set(N) writes a single numeric code (single accepts
scalars only — no list or object form).
The h prefix is a naming convention for helper questions — it
has no effect on its own. What actually hides hRegion from the
respondent is visibility: hide; readonly: True then makes sure
the value can only be written by the script. Without those flags
the question would render normally.
Both QState and hRegion export normally — analysts get the raw
state and the derived region.
”Other (please specify)” text capture — with validation
- qid: QBrand
type: single
text: Which brand do you prefer?
options:
1: Apple
2: Samsung
3: Sony
4:
label: Other (please specify)
specify: True
specify.maxChar: 50
anchor: True
validation: |
if QBrand.selected.any(4):
text = QBrand.specify(4).value or ""
if len(text.strip()) < 3:
fail("Please tell us which brand you mean (at least 3 characters).")
Picking code 4 reveals an attached free-text field. The text
exports as QBrando4Specify — a separate column from the chosen
code. To read the typed text in a script, use
QBrand.specify(4).value.
The validation: | block runs after the respondent answers and
before the next page renders. It receives the respondent’s
answer through the same accessors used everywhere else
(QBrand.selected, QBrand.specify(4).value). Calling fail()
rejects the answer and shows the message — until the respondent
fixes it, the page can’t be submitted. fail() takes a language
code and the message text; multiple language codes are supported
when the survey is multilingual.
Other validation idioms:
if not condition: fail(...)— invert the check.- Multiple checks — each
fail()short-circuits the rest of the block, so the first failed check is the one shown. - No
fail()called — the answer passes.
Mask options based on a previous answer
- qid: QBrand
type: multi
text: Which brands have you heard of?
options: brandList
- qid: QFav
type: single
text: Which is your favourite of those?
options: brandList
options.from: QBrand.selected
QFav only shows brands the respondent picked at QBrand. The
authored option list is preserved in the model; options.from
filters which ones render.
Reusing an option list across questions
When the same option set appears on more than one question — states,
countries, brands, hospitals, products — declare it once in a
top-level - lists: block and reference it by name everywhere.
- lists:
brandList:
options:
1: Apple
2: Samsung
3: Sony
4: LG
99: None of these
stateList:
options:
1: Alabama
2: Alaska
# ... 47 more
50: Wyoming
- qid: QAware
type: multi
text: Which brands have you heard of?
options: brandList
- qid: QFav
type: single
text: Which is your favourite?
options: brandList
options.from: QAware.selected.minus([99])
- qid: QState
type: single
text: In which state do you live?
style: dropdown
options: stateList
The - lists: block lives at file level — it has no qid of its
own and produces no question. It’s just a declarative bag of named
option sets. Once declared, every question that needs a domain
references it with options: <listName>. Edit the list once and
every question that references it picks up the change.
For grouped lists and shared scales, see Defining lists.
Subdividing options into named groups
When the option list has natural sub-sections — clinical vs admin,
EU vs non-EU, paid vs free tiers — group: lets you break it up
with optional headers, per-group ordering, and per-group anchoring.
- qid: QRole
type: single
text: Which best describes your role?
instruction: Select one.
order: random # randomise within each group
group.order: random # also randomise the groups themselves
group:
senior:
show.label: False
options:
1: Lab Director
2: Lab Manager
clinical:
show.label: False
options:
3: Nurse Supervisor
4: Department Head
5: Quality Director
other:
show.label: False
anchor: True # always last group
options:
99:
label: Other (please specify)
specify: True
anchor: True
group.order: random shuffles the groups; order: random shuffles
the options within each group. Setting anchor: True on a group
pins it (here, the “Other” group is always last regardless of
group.order).
show.label: False hides the group heading — useful when the
groups exist purely to control ordering and shouldn’t render as
visible section breaks.
For a fully grouped reusable list (declare-once, use-everywhere), see Groups.
Image options for cards / image_cards
Visual choices — package designs, ad concepts, logo variants —
work best with style: image_cards. Each option carries an
image: URL.
- qid: QPackage
type: single
text: Which package design do you prefer?
style: image_cards
options:
1:
label: Design A
image: /assets/pkg-a.png
2:
label: Design B
image: /assets/pkg-b.png
3:
label: Design C
image: /assets/pkg-c.png
4:
label: Design D
image: /assets/pkg-d.png
image_cards renders the image prominently with the label
underneath. The cards style accepts images optionally — useful
when some options have illustrative images and others don’t, or
when the description text is more important than the image.
Image URLs can be absolute (https://…) or relative
(/assets/…); relative paths resolve against the survey’s media
base.
Export
| What | Column |
|---|---|
| The chosen code | qid (e.g. QBrand) — number |
| Specify text | qidoNSpecify (e.g. QBrando4Specify) — string |
single exports as one column. Masking with options.from affects
which codes a respondent could pick, not the column shape. See
Column naming.
See also
- multi — when more than one selection is allowed.
- rank — when ordering matters.
- lookup — for very long option lists with type-ahead.
- Conditional & dynamic —
options.from,if. - Collections — every method on
.selected. - Skin variants — visual reference across types.
- Customisation — theme tokens that drive style appearance.