Some situations require specific order assignments beyond what can be defined with an order
tag. For example, using one order for exactly half of respondents, and the reverse order for the other half. To accommodate these and similar requests, the order
tag can accept a variable as an input. This allows us to apply programming logic such as cvalue
or selectby
to the order.
Note: The variable containing the order must be populated with data before the list or other widget that will use the order.
Tip! Survey Programmers (SPs) should keep in mind that any order applied to a group will affect all elements in the group. For additional information on using order variables with groups and blocks, see Randomizing groups of pages and blocks.
Syntax
Open-end
To define an order within a text variable, put the string in the variable via cvalue
.
ORDERVAR. Ordering Variable type: text invisible: y cvalue: 'numeric string here' # e.g. '1,2,3,4,5' (note quotes)
Closed-end
A closed-end variable stores order strings in option text.
ORDERVAR. Ordering Variable type: radio selectby: random 1. numeric string here # e.g. 1,2,3,4,5 (no quotes) 2. another numeric string here # e.g. 5,4,3,2,1 (no quotes)
Note that unlike the open-end example above using cvalue
, variables defined with the selectby
tag do not require invisible: y
.
Referencing order variables
To reference closed or open-end variables, reference the field ID with a "$" prefix:
1. Question using custom ordering type: radio optsfrom: series[1..5] order: $QuestionID # e.g. $QORDERVAR
Tip! Both closed and open-ended variables are referenced as shown above. The order
tag can parse out that option text is needed from closed-end variables.
Examples
Open-end variable
Open-end with additional options
In this example, the ITEMORDER variable pulls the order from the list ITEMS, then adds a location for one more option ('5'), which will be an inline option added to the question that next uses the list. The variable ITEMORDER is considered open-ended due to its usage of the cvalue
tag, which is quoting the order from the list ITEMS. Note the '5' refers to the item's position in the order, not its actual option ID ('97').
Closed-end variable
In the following example, ORDERVAR is a radio variable which rotates between sequential and reverse orderings, and selectby
ensures that half of the respondents will see increasing options, and half will see decreasing.
Comments
0 comments
Please sign in to leave a comment.