Sheets 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.
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 that 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 columns can function as element decorators such as 'weight', 'explain', 'desc', 'condition', and 'autoother'. Decorator column headers 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 sheets to lists
When creating a sheet, it's helpful to think of a sheets as similar to a set list
. Each row represents an item in the list, and each column provides data points for the row. The following set list
and sheet are equivalent to each other:
SPL | Sheet equivalent | |||||||||||||||||||||||||||
set list: colors 10. Primary {collection header: y} 11. Red |
|
Referencing decorators from sheets
Once a sheet 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 sheets 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. - The
autoother
decorator functions like a combination of these two scenarios. To create an autoother text field, add a 'y' for the option in the "autoother" column. Any additional autoother parameters should be added locally as tags to individual questions or globally to theset defaults
widget.
Additional examples
For the following examples, assume the local survey sheet 'miscexamples' has been defined in the survey source.
definesheet: survey_id_containing_sheet.miscexamples
autoother
When the autoother
decorator is added as a column header in a sheet, adding 'y' in a cell for this column will trigger the creation of a text field for that option. Additional parameters can then be added as tags on questions referencing the sheet, as shown below.
Note, the single line approach for creating autoothers is not available when using autoother in a sheet.
Sheet | SPL needed | |||||||||||||||||||||||||||
|
1. Which shoe brands have you purchased for running in the past year? |
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.
Additional image formatting decorators can be included as sheet column headers as needed.
Sheet | SPL needed | ||||||||||||
|
1. Which type of apple is your favorite? |
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 supports 'y' and 'n' inputs as well as translation keys, like thetranslate
tag.
Sheet | ||||||||||||||||||
|
Collection headers and order
In addition to sheets 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 sheet has blanks in the column being referenced.
Comments
0 comments
Please sign in to leave a comment.