rank
Coded items in chosen order. The respondent picks how items rank against each other; the runtime stores the codes in rank order — first place to last.
What rank is
rank collects coded items in the order the respondent prefers them.
The stored answer is a collection of codes in rank order — index
0 is the top-ranked item, index 1 is second, and so on. Use it
when relative position matters more than presence — “rank these
features by importance”, “order these brands by preference”.
- qid: QTop3
type: rank
text: Rank these features by importance.
instruction: Most important on top.
exact: 3
options:
1: Battery life
2: Camera quality
3: Screen size
4: Build quality
5: Price
exact: 3 forces the respondent to fill exactly three rank positions.
Without it, all options can be ranked or only some.
Properties
| Property | Values | Notes |
|---|---|---|
qid | string | Required. Unique within the survey. |
type | rank | 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. |
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 ranking. Pair with visibility: hide to fully hide a helper question. |
visibility | show | hide | Default show. |
style | drag | arrows | tapToRank | dropdownRank | podium | Default drag. See Styles below. |
order | keyword or expression | Controls the starting order before the respondent reorders. Keywords: fixed (default), random, randomEach, alphabetical, reverse, flip — see below. Also accepts an expression like Q1.all or a literal [2, 4, 1, 3]. See Order. |
group.order | same as order | Default fixed. Order of named groups when group: is used. |
layout.cols | integer | Default 1. |
min | integer | Minimum positions to fill. No default. |
max | integer | Maximum positions to fill. No default. |
exact | integer | Exactly this many positions. Overrides min / max. No default. |
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 before the respondent reorders. Default. |
random | Stable random starting order, per respondent. |
randomEach | Re-shuffle the starting order every render. |
flip | Deterministic split sample — half see authored, half see reversed. |
alphabetical | Sort the starting order alphabetically by label. |
reverse | Reversed authored order as the start. |
order only affects the initial order presented to the
respondent. Once they rank, their chosen order is what’s stored.
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
| Property | Values | Notes |
|---|---|---|
label | renderable | Required when expanding the option. Use {{ }} to pipe runtime values. |
image | URL string | Optional thumbnail. |
anchor | True | False | Default False. Set True to pin the option in place under order: random. |
isolate | True | False | Default False. Set True to render this option as a whole-question opt-out toggle below the rank list — a “None of these / Prefer not to answer” checkbox. Picking it does not assign it a rank position. Pair with exclusive: True. |
exclusive | True | False | Default False. When set alongside isolate: True, selecting the opt-out clears the on-screen ranking + disables the ranking widget and satisfies required — the server nulls the ranking so the respondent can proceed. Rare on rank without isolate. |
specify | True | False | Default False. Attach a free-text input to this option (collected only when the option is ranked). |
specify.size | integer | Width of the specify input. No default. |
specify.maxChar | integer | Max length of the specify text. No default — unlimited unless set. |
data | object | Metadata object for advanced authoring. No default. |
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.selected | CodeSet | Codes in rank order. Index 0 is the top-ranked code. |
Q.selectedLabels | LabelList | Labels in rank order, parallel to Q.selected. |
Q.values | CodeList | Alias for Q.selected. Some authoring contexts read more naturally as “the values” — both produce the same data. |
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 filled at least one rank position (or the required minimum). |
Q.notAnswered | bool | Inverse of answered. |
selected is in rank order, not authored order. If the respondent ranks Sony first and Apple second, QTop3.selected is {3, 1}, not {1, 3}. The same applies to selectedLabels and values.Methods
| Expression | Returns | Meaning |
|---|---|---|
Q.set([2, 1, 3]) | None | Set the ranking to an ordered list of codes. The list order is the rank order. |
Q.reset() | None | Clear the ranking. |
Q.at(N) | Code | Code at zero-based rank position N — alias for Q.selected.at(N). |
Q.set() only accepts an ordered list — there’s no scalar or
tri-state form on rank. Duplicates and unknown codes are rejected.
Collection operations on Q.selected
| Expression | Returns | Meaning |
|---|---|---|
Q.selected.size | int | Number of ranked positions filled. |
Q.selected.at(N) | Code | The code at rank position N (zero-based). |
Q.selected.any(N) | bool | True if code N is anywhere in the ranking. |
Q.selected.any([1, 2]) | bool | True if any listed code is ranked. |
Q.selected.intersect([1, 2, 3]) | CodeSet | Overlap between the ranking and the list, preserving rank order. |
The same operations work on Q.selectedLabels, Q.values, Q.all,
and Q.allLabels. See Collections for the
full reference (including every, union, minus).
Skins
Five visual styles. Pick by context — list length, whether the respondent is on a touch device, and whether ranking the full list matters or just a top few.
drag Drag (default) arrows Arrows tapToRank Tap to rank dropdownRank Dropdown podium Podium 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 working preview. Tap an item to give it the next rank position; tap again to remove it (the others re-number automatically).
QTop3.answeredFalseQTop3.selected{}QTop3.selectedLabels{}QTop3.values{}QTop3.selected.size0QTop3.selected.at(0)None- qid: QTop3
type: rank
text: Rank these features by importance.
instruction: Most important first.
options:
1: Battery life
2: Camera quality
3: Screen size
4: Build quality
5: Price
The interaction shown here is “tap to add to next position” — the
shipping styles (arrows, drag, podium, etc.) will offer richer
UIs but the underlying state model is the same.
Methods & accessors — live
The same preview, paired with a panel of expressions evaluating against the current ranking. Rank some items above and watch each expression’s return value.
QTop3.answered → — QTop3.selected → — QTop3.selectedLabels → — QTop3.values → — QTop3.selected.size → — QTop3.selected.at(0) → — QTop3.selected.at(1) → — QTop3.selectedLabels.at(0) → — QTop3.selected.any(2) → — QTop3.selected.any(99) → — QTop3.selected.intersect([1, 2, 3]) → — A few things to notice as you rank:
selectedreflects rank order, not authored. Rank Sony (code 3) first then Apple (code 1) —selectedis{3, 1}..at(0)is the top-ranked code,.at(1)is second. This is the most-used method on rank.selectedLabelsis the human-readable parallel toselected— same order, labels instead of codes. Useful for piping the top rank into a follow-up question.- The “None of these” item is
isolate: Trueandexclusive: True.isolateputs it in its own group below the main list;exclusivemakes picking it clear the rest of the ranking. The two flags are independent — useisolatealone for purely visual separation, addexclusive: Truewhen “this option means the others don’t apply”. Tap “None of these” and watch the previous rankings clear, withselected.any(99)flipping toTrue.
Examples
Top three with exact
- qid: QTop3
type: rank
text: Rank your top three features.
instruction: First, second, and third.
exact: 3
options:
1: Battery life
2: Camera
3: Screen
4: Build
5: Price
The respondent must fill exactly three positions. With min: 3 /
max: 3 the rule is the same; exact is just clearer.
Rank a respondent’s earlier selections
- qid: QFeatures
type: multi
text: Which features matter to you?
min: 3
options: featureList
- qid: QRankFeatures
type: rank
text: Now rank the features you picked.
options.from: QFeatures.selected
The rank only shows options the respondent picked at the previous
multi. options.from filters the rank’s domain.
Pipe the top-ranked label into a follow-up
- qid: QTop3
type: rank
text: Rank these brands.
options: brandList
exact: 3
- qid: QTopReason
type: open
text: Why did you rank {{ QTop3.selectedLabels.at(0) }} first?
style: textarea
input.rows: 3
selectedLabels.at(0) is the top-ranked brand’s label. Pipe it
straight into the next question’s text.
Read positions in a script
- script: |
print("First:", QTop3.selectedLabels.at(0))
print("Second:", QTop3.selectedLabels.at(1))
print("Third:", QTop3.selectedLabels.at(2))
# Was a specific code ranked at all?
if QTop3.selected.any(5):
print("Price was ranked at position", QTop3.selected.at(0) == 5)
.any(N) checks if a code is anywhere in the ranking; .at(N) reads
a specific rank position.
Hidden helper that mirrors a ranking
- qid: hTop1
type: single
options: brandList
visibility: hide
readonly: True
required: False
- script: |
if QTop3.answered:
hTop1.set(QTop3.selected.at(0))
hTop1 stores just the top-ranked brand as a single-style answer —
useful when downstream analysis wants a flat “first choice” column
instead of working with the ranked list.
Validation example
- qid: QTop5
type: rank
text: Rank up to five.
max: 5
options: brandList
validation: |
# Require at least 3 ranked.
if QTop5.selected.size < 3:
fail("Please rank at least three brands.")
# Don't let "None of these" be ranked first.
if QTop5.selected.at(0) == 99:
fail("Please rank an actual brand first.")
Validation runs after the respondent ranks, before the next page.
Calling fail() rejects with a message; multiple fail() calls
short-circuit on the first that fires.
Reusing an option list
- lists:
brandList:
options:
1: Apple
2: Samsung
3: Sony
4: LG
99: None of these
- qid: QRankBrands
type: rank
text: Rank these brands by preference.
options: brandList
exact: 3
For the full reusable-list pattern see
single.
Export
rank exports one column per rank position:
| What | Column |
|---|---|
| Code at rank 1 | qidr1 (e.g. QTop3r1) — the first-ranked code |
| Code at rank 2 | qidr2 |
| … | … |
| Isolate opt-out active | qido<code> = 1 (e.g. QTop3o99) — one flag column per opt-out entry |
Positions the respondent didn’t fill (when exact isn’t set) export
as null.
QTop3r1 = 3 # Screen size, ranked first
QTop3r2 = 1 # Battery, ranked second
QTop3r3 = 5 # Price, ranked third
QTop3r4 = null # not ranked
QTop3r5 = null
When the isolate opt-out is active, every rank-position column reads null and the opt-out flag column QTop3o99 reads 1:
QTop3r1 = null
QTop3r2 = null
QTop3r3 = null
QTop3o99 = 1 # respondent chose "None of these"
The number of qidrN columns equals the size of the visible domain
— so a 10-option rank produces qidr1 through qidr10, with the
unfilled positions as null. Each isolate entry adds one qido<code> column.
See also
- single — when only one selection is needed.
- multi — when ordering doesn’t matter.
- Collections —
.at(),.any(), set ops. - Conditional & dynamic —
options.from. - Column naming —
qidrNand the rank-position rule.