Groups are used to group together survey content (questions, text, logic, etc.). Generally, any survey content embedded between the start group
widget and its corresponding end group
widget are grouped together – sometimes, sharing the same page, logic conditioning, or other attributes defined by the group.
Groups are most commonly used to enable survey logic and/or skip patterns, but they can be used for other purposes as well, such as populating variables (questions not seen by respondents) for use later on in the survey.
Tip! If you are creating a group for a single question for the purpose of adding the condition
tag, use the
show if
tag instead. It's concise, simple, and easier to understand.
Syntax
## Basic startgroup: GROUP_LABEL_HERE # Survey widgets here endgroup: GROUP_LABEL_HERE ## Unlabeled startgroup # Survey widgets here endgroup
Though permitted, unlabeled groups are not considered best practice. In r8.1+, if a group is created without a label, Survey Programmers (SPs) will see the following caution message upon parsing their survey: "Please name this group, so it will work better in IntelliBuilder."
Common tags
Groups work a bit like set defaults
- tags applied to the start group
widget apply to all groups and questions therein.
The following tags are commonly used with groups.
Tag | Description |
---|---|
condition |
For use with blocks, groups, and new pages. Evaluates a Boolean expression, and if "true," shows/executes group contents based on the results of that expression. |
goto
|
Routes respondents to a question or labeled group/page. After routing, the survey continues from that point and follows any page or group conditions therein. |
inline |
Accepts 'y' (yes) and 'n' (no) inputs; controls group page break behavior. Default is "no" if undefined. |
chapter
|
Places the group contents within a given chapter of the Reporting Field Tree. |
endgroupafter (alias endafter ) |
Can be applied to the startgroup widget instead of using an endgroup widget; specifies the final question to include in the group. |
(alias |
Can be applied to the startgroup widget instead of using an endgroup widget; specifies the first question after the group has ended. |
loop for |
In r8.0+; indicates the system should repeat or "loop" a group of questions over a specified list of options. Similar to blocks, loops may be iterated over the options from a setlist, spreadsheet, previous question's options, or previous question's selections. The |
Examples
Conditioning survey sections
The startgroup
widget can include a condition
tag to specify logic for whether a respondent should be shown a set of questions or not. In the following example, two groups are created, and respondents are shown a set of questions based on their responses to Q1.
With 'goto'
Labels on groups work with respondent routing tools, such as goto
. In this example, we have a group labeled 'bad' for respondents that fail the attention check — they are given the status B. Note that the 'bad' group is placed at the end of the survey, after the endsurvey
for respondents who completed. This is to ensure that respondents who completed are not inadvertently classified as status B.
Caution! goto
overrides group conditions - it is possible to route a respondent to a group with a condition that is false. However, group conditions are evaluated after every page submission within the group. So, if the condition is not met, the respondent will be routed out of the group immediately upon the first page submission.
Chapters
Using groups to define chapters will place all widgets within that group into the corresponding reporting chapter. In the example below, QS1 uses the chapter
tag and will be included with chapter A (Screener), and QD1 will be included with chapter B (Demographics).
Note, there is a newer, more succinct manner to achieve the same result as the example above. SPs can apply the chapter
tag directly to questions, tables, or variables without the need to create groups. See Survey chapters overview for more information.
Alternate group definitions
SPs may define a group in a single widget by applying either the endgroupafter
(alias endafter
) or endgroupbefore
(alias endbefore
) tag to the startgroup
widget. By specifying the final question to include in a group -- or the first question after the group, respectively -- in a single widget, this creates code that resembles the way clients often design their questionnaires. In the example below, if the respondent selects option '2. Girl' at Q6, then they will be asked Q7 - Q9. The endafter
tag states that this group "for girls only" ends after Q9. Q10 will then be asked to everyone.
6. What is your child's gender?
type: radio
1. Boy
2. Girl
startgroup: girl_follow_up
condition: anyChecked($Q6,2)
endafter: Q9
7. How old is your daughter?
type: integer
range: 0-18
8. Does your daughter play with dolls?
type: radio
1. Yes
2. No
9. Has your daughter ever been to an American Girl store?
type: radio
1. Yes
2. No
10. New question shown to everyone.
type: radio
1. Yes
2. No
Loops
Loops offer programmers the ability to define content that can be displayed repeatedly, or "looped," within a survey, with each iteration slightly different. Similar to blocks, a loop requires a list of elements that the questions are repeated for. To create a loop, apply the loop for
tag to a start group
widget and specify the list of elements for which the question(s) will be repeated.
SPs can use placeholders to pipe in the list options' text by including ~text~
in the looped questions' text or options. The ~id~
placeholder can also be used to pipe in the list options' IDs.
Tip! Loops are not designed to replace blocks, but rather to provide an easier syntax for creating simple iterations of a set of questions. For more complex situations, including nested groups of repeated questions, blocks should still be used.
Comments
0 comments
Please sign in to leave a comment.