Question label shorthand is an abbreviated way to write a conditional statement using anyChecked
to reference a single question or variable.
In Q2B below, 'Q1' is shorthand for "all options selected at Q1".
1. Which products have you ever purchased?
type: checkbox
1. Cat litter
2. Gummy bears
3. Ghost Busters memorabilia
4. Vacuum cleaner
5. Water
2A. What item did you purchase most recently? type: radio optsfrom: Q1.options {if anyChecked($Q1,[id])}
2B. Now, here's the same condition, using question label shorthand instead.
type: radio
optsfrom: Q1
Note: The condition
decorator cannot be used with question label shorthand. If you need to apply a new condition, you must reference the list and add the condition
decorator to fully define the logic.
Additional examples
Excluding an option
Question label shorthand supports inclusion and exclusion syntax. In the example below, only options selected at Q1 will be shown at Q1A. However, option 4, Apples, will never be shown at Q1A, regardless of the selection.
setlist: SNACKS
1. Pretzels
2. Popcorn
3. Chips
4. Apples
5. Donuts
6. Wasabi Snow Peas
1. Which of these snacks do you like?
type: checkbox
optsfrom: SNACKS
1A. Which of these snacks would you eat at the movie theatre?
type: checkbox
optsfrom: Q1 -[4]
Using multiple question labels
Just as question and set list
widgets can use multiple optsfrom
listcalls, you can also apply question label shorthand multiple times — one per optsfrom
— as shown below. Any option selected at Q1 or Q2 will be stored in QALLCITIES.
1. Select all the cities you like to visit in the autumn.type: checkbox
randomize: y
1. Paris
2. Toronto
3. Beijing
4. Berlin
5. Istanbul
2. Select all the cities you like to visit in the spring.type: checkbox
randomize: y
11. Barcelona
12. Tokyo
13. Buenos Aires
14. Amsterdam
15. San Diego
ALLCITIES. All cities from Q1 and Q2type: coded multiple select
optsfrom: Q1
optsfrom: Q2
The example above uses a type: coded multiple select
to reduce lines of code.
Adding element decorators
Most element decorators can be added to question label shorthand syntax to further define the option selection or reporting descriptions. In QS7X2OPTS below, the weight
decorator is applied to ensure that among all the options selected at QS7X2, those with the highest weight are selected first.
setlist: BRANDLIST
randomize: y
1. Brand 1 {{BETTER: 1}} {{STANDARD: 0}} {{wgt: 1}}
2. Brand 2 {{BETTER: 1}} {{STANDARD: 0}} {{wgt: 1}}
3. Brand 3 {{BETTER: 0}} {{STANDARD: 1}} {{wgt: 1}}
4. Brand 4 {{BETTER: 0}} {{STANDARD: 1}} {{wgt: 1}}
5. Brand 5 {{BETTER: 1}} {{STANDARD: 0}} {{wgt: 100}}
S7X2. Please select all brands that you have <u>ever purchased</u> at any point....
instruct: Please select all that apply
type: checkbox
optsfrom: BRANDLIST
S7X2OPTS. QS7X2OPTS - 3 selections from S7.2
type: checkbox
selectby: weight,counts
maxgroups: 3
optsfrom: QS7X2 {weight: [wgt] + [BETTER]*100 + [STANDARD]*10}
Comments
0 comments
Please sign in to leave a comment.