Option data decorators use named labels within double curly braces to append custom option data to list items. These are useful for text manipulations, limiting which options are shown, and linking images to option text.
setlist: RAINBOW
1. Roaring Red {{COLOR: Red}}
2. Outrageous Orange {{COLOR: Orange}}
3. Yucky Yellow {{COLOR: Yellow}}
4. Gorgeous Green {{COLOR: Green}}
5. Blushing Blue {{COLOR: Blue}}
6. Iconic Indigo {{COLOR: Indigo}}
7. Viscous Violet {{COLOR: Violet}}
7. Which of the following colors are your favorites?
instruct: Select up to 3
type: checkbox
maxchecked: 3
optsfrom: RAINBOW
8. Of the following, which is your most favorite?
type: radio
optsfrom: RAINBOW {if anyChecked($Q7,[id])} {text: [COLOR]} {desc: [COLOR]}
autocode: $Q7 {if countChecked($Q7) == 1}
What is option data?
Option data refers to the information stored in a list. Standard lists have two "fields," or descriptor labels, of option data: a list item ID ([id]
) and the item's text content ([text]
). When a list is referenced at a listcall, our software knows to replace the [id]
placeholder with the corresponding item ID for every item in the list. For example, the expression anyChecked($Q1,[id])
is evaluated as anyChecked($Q1,1)
for option 1, anyChecked($Q1,2)
for option 2, and so on. Option data decorators expand on this functionality by allowing additional labels to be defined in the survey code, which can then be referenced in the same way as [id]
and [text]
.
Details
- IntelliSurvey's SPL includes some default decorators with reserved names. Avoid using these reserved names as your custom data labels.
- Once the option data decorator is defined, the assigned label can be used at listcalls such as
rowsfrom
oroptsfrom
, or any context where[id]
or[text]
could be used. -
Option data decorator labels are case insensitive, e.g.,
{{TXT: word here}}
can be called in as[TXT]
or[txt]
. - Option data decorators can be utilized in crosslists.
- Option data decorators can be utilized in a sheet as column names.
Additional examples
Using option data with the explain decorator
The explain
decorator can be used to show option data decorator text as a mouseover/tooltip, which allows for smaller option buttons when screen space may be a concern.
Using option data decorators to reference a subset of list options
Option data can be used to designate when certain options should be displayed. In the example below, "WC" stands for West Coast. Options are assigned '1' to indicate the team is on the West Coast, and '0' to indicate the team is not on the West Coast. The same applies to "EC" for East Coast.
Using option data decorators on collection headers
If you are programming on r9+, a set list with collection headers can also have option data attached to its items and headers. In the example below, Q23 uses the text
decorator to display a lower-case version of the text found in the option data label 'lc'. For example, "Dry groceries" will now appear as "dry groceries."
Then, at Q23A the header: only
filter is used to pull in a subset of items — 'Food', 'Alcohol', and 'Health & Beauty'. However, the option data label 'primary' is also applied as a filter, and now only 'Alcohol', and 'Health & Beauty' will be shown to the respondent. Calling in the option data decorators is not case sensitive.
Note, although the collection items all display in lower-case, the collection header, e.g., Food, will always display as a "proper" heading with the first letter capitalized.
Option data decorators with blocks and loops
To use option data decorators in blocks, surround the label in double '%%'. For example, an option data decorator with the label 'TXT' would be programmed as %%TXT%%
within question, option, or row text.
setlist: APP_LIST
1. Spotify and Apple Music {{APP1: Spotify}} {{APP2: Apple Music}}
2. Spotify and Amazon Music {{APP1: Spotify}} {{APP2: Amazon Music}}
3. Apple Music and Amazon Music {{APP1: Apple Music}} {{APP2: Amazon Music}}
block: <<BLK
9_%%ID%%. On a scale of 1-10, how much do you agree with the following statements?
type: radio table
optsfrom: series [1..10]
headings: Not agree at all, Strongly agree
rows:
1. The music I am exposed to on %%APP1%% is very different than the music I am exposed to on %%APP2%%
2. People use %%APP1%% for different reasons than people use %%APP2%%
3. Paid tier is a better value on %%APP1%% than on %%APP2%%
BLK
list: APP_LIST
To use option data decorators in loops, surround the label with '~'. For example, an option data decorator with the label 'TXT' would be programmed as ~TXT~
within a question, option, or row text.
Using option data decorators for images
Option data decorators can also connect images to options. First save the images to your survey, then define a setlist where each option's image is specified via an option data decorator (in this case, IMG_TAG
). Q11 shows both the text and logo, while Q12 shows only the logo. The double underscore before and after IMG_[id]
is the syntax required since the images are linked to the options by the set conditioned text
. Also, the desc
decorator is applied here to provide an alternate text for reports.
Comments
0 comments
Please sign in to leave a comment.