Spreadsheets are commonly used as data sources within the platform and can function like lists. Each sheet must include at least an 'id' and a 'text' column. Additional columns can serve as element decorators such as 'weight', 'explain', 'desc', 'condition', among others.
id | text | collection_header | weight |
10 | Primary | y | 100 |
11 | Red | 100 | |
12 | Yellow | 100 | |
13 | Blue | 100 | |
20 | Secondary | y | 1 |
21 | Orange | 1 | |
22 | Purple | 1 | |
23 | Green | 1 |
Tip! Option data decorators use named decorators to define custom data which can also be used as sheet column headings.
Details
- The first column must be labeled 'id', and each row must have a unique value in the 'id' column.
- The second column should be labeled 'text' to serve as the option text for each item.
- Additional column names can then act as decorators. Decorator column headers (e.g., 'collection_header') are "reserved terms" and require specific inputs if used as headers in a survey sheet.
- Spaces are not allowed in column header names. Use an underscore when needed. For example, the decorator 'collection header' can be written as 'collection_header' instead.
- All column labels must be unique.
Comparing spreadsheets to lists
When creating a spreadsheet, it's helpful to think of sheets as similar to setlists. Each row represents an item in the list, and each column provides data points for the row. The following setlist and sheet are equivalent to each other:
SPL | Sheet equivalent | |||||||||||||||||||||||||||
setlist: colors 10. Primary {collection header: y} 11. Red |
|
Referencing decorators from spreadsheets
Once a spreadsheet is defined, decorator data can be used in survey programming.
First, define the sheet and invoke the sheet on the listcall (e.g., optsfrom
) as explained in Using spreadsheets in survey programming. Depending on the decorator, additional steps may be needed.
-
Automatically applied decorators: Decorators like
collection_header
andrandomize
manage option ordering and organization automatically. Conditions and translation instructions are also applied without additional steps. -
Explicitly referenced decorators: For decorators like
image
, explicitly includeimage: y
in the survey code to enable images for each relevant question.
Additional examples
For the following examples, assume the local survey sheet 'miscexamples' has been defined in your survey source.
definesheet: survey_id_containing_sheet.miscexamples
image
When the image
decorator is included in a sheet, the image
decorator or option images
tag should also be present at all relevant questions to "turn on" the image display.
Sheet | SPL needed | ||||||||||||
|
1. Show images here. |
condition
A list of conditions defined in a sheet are automatically applied to the survey. Notice, the 'if' is not needed.
Sheet | ||||||||||||
|
translate
By default, items in a sheet are not translated unless the translate
decorator provides additional instructions. The translate
decorator can support 'y' and 'n' inputs as well as language codes, just like the translate
tag.
Sheet | ||||||||||||||||||
|
Collection headers and order
In addition to spreadsheets supporting collection headers, decorators that define order placement and randomization can also be used.
In the example below:
- The 'collection_header' column flags 'Mass Merchandisers,' 'Pet Stores,' and 'Brick and Mortar's website' as headers.
- The 'order' column ensures:
- The 'Mass Merchandisers' group fully randomizes items 11 and 12.
- The 'Pet Store' group keeps items 21 and 22 together, randomizes their order, and mixes them among the group's four options.
- The 'alphabetize' column applies alphabetical sorting to the 'Brick and Mortar's website' group.
Sheet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Tip! Sheets automatically organize content in incrementing, sequential order based on the value in the 'id' column. Take this into consideration when numbering your collection headers so that they remain visually organized as the first item in their respective group.
Option data
Option data decorators can serve as sheet column headings, and the data stored in those columns is used similarly to option data inline in survey code.
The table below shows how decorators can store and retrieve data:
id | text | WC | EC | CITY | SHORT |
---|---|---|---|---|---|
1 | Bradenton Marauders | 1 | 0 | Bradenton | Marauders |
2 | Daytona Tortugas | 0 | 1 | Daytona | Tortugas |
3 | Clearwater Threshers | 1 | 0 | Clearwater | Threshers |
4 | Jupiter Hammerheads | 0 | 1 | Jupiter | Hammerheads |
To display the teams' "short" name, use the text
decorator at the listcall, and use square brackets to pull in the data found in the 'SHORT' column.
21. Which of the following teams have animals in their names?
type: checkbox
optsfrom: miscexamples {text: [SHORT]}
To apply a condition, such as only show West Coast (WC) teams, use an "if statement" with square brackets to only filter in where WC = '1'.
22. Of the following West Coast teams, which would you like to see play?
type: checkbox
optsfrom: miscexamples [if ([WC])]
Tip! Remember to wrap square brackets with parentheses, for example '([WC])', if your spreadsheet has blanks in the column being referenced.
Version Notice: This article covers features debuted in our r9/IS Pro platform.
Comments
0 comments
Please sign in to leave a comment.