Groups are used to organize survey content such as questions, logic, and text. Content placed between a start group
widget and its corresponding end group
widget is grouped together.
1. Have you ever purchased groceries online?
type: radio
1. Yes
2. No
start group: PURCHASED
condition: anyChecked($Q1,1)
2. What prompted you to use the online option for buying groceries?
type: textbox
2A. Will you continue to purchase groceries this way?
type: radio
1. Yes
2. No
end group: PURCHASED
start group: NOT_PURCHASED
condition: anyChecked($Q1,2)
3. Why do you prefer to purchase groceries in the store?
type: textbox
3A. Is there anything that would make you try an online grocery purchase?
type: radio
1. Yes
2. No
end group: NOT_PURCHASED
Details
- Tags on a
start group
widget automatically apply to all questions and widgets within that group. - Groups are most commonly used to create skip patterns, but they can be used for other purposes as well, such as populating variables for use later on in the survey.
- The
start group
widget can include acondition
tag to determine whether a respondent sees a specific set of questions, as shown above. - The
start group
widget supports theorder
tag to organize the group's content. - The
start group
widget supports theloopfor
tag to repeat the group's content.
Tip! For a single question with a condition, use the show if
tag instead of creating a group.
Common tags
The following tags are commonly used with groups and are applied directly to the start group
widget.
Tag | Description |
chapter |
Places the group's contents in a chapter of the reporting field tree. |
condition |
Evaluates a conditional statement and shows/excludes group content if the logical statement is true. |
endgroupafter (alias endafter ) |
Can be applied to the |
endgroupbefore (alias endbefore ) |
Can be applied to the |
goto |
Routes respondents to another question, labeled group, or page. |
inline |
Controls page breaks within a group. Accepts 'y' and 'n' inputs; default is "no" if undefined. |
loopfor |
Repeats, or "loops," content within a group with slight variations in each iteration. |
order |
Specifies how to organize multiple questions in a group. |
Caution! The goto
tag overrides group conditions, allowing respondents to be routed to a group even if its condition is false. However, group conditions are re-evaluated after each page submission. If the condition is not met, the respondent will be routed out of the group after the first page submission.
Additional examples
Creating chapters
Groups can be used to create reporting chapters at the global level, automatically assigning all widgets within the group to the specified chapter. For example, applying the chapter
tag to QS1 places it in Chapter A (Screener), while QD1 is included in Chapter B (Demographics).
define chapters
A. Screener
B. Demographics
startgroup: screener_group
chapter: A
S1. What is your age?
preface: This is the screener.
type: integer
datatype: whole
size: 3
range: <120
endgroup: screener_group
startgroup: demo_group
chapter: B
D1. What is your annual household income?
type: integer
datatype: whole
prefix: $
endgroup: demo_group
Using 'endgroupafter'
You can also define a group using only the startgroup
widget if you apply the endgroupafter
or endgroupbefore
tag to the widget.
These tags specify either the last question in the group (endgroupafter
) or the first question outside the group (endgroupbefore
). This method streamlines the code, resembling the structure of client-designed questionnaires.
For example, if a respondent selects option '2. Girl' at Q6, they will proceed to questions Q7–Q9. The endgroupafter
tag indicates that the "for girls only" group concludes after Q9. Question Q10 will then be displayed to all respondents.
6. What is your child's gender?
type: radio
1. Boy
2. Girl
startgroup: girl_follow_up
condition: anyChecked($Q6,2)
endgroupafter: 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
Looping through questions in a group
To create a loop for a group of questions, apply the loopfor
tag to a start group
widget and specify the list of elements for which the question(s) will be repeated. In the example below, we use question label shorthand (e.g., loopfor: Q20
) to reference the selections made in Q20.
Randomizing content within a group
As with lists, content within a group can be ordered or randomized. To order content within a group, apply the order
tag to the group definition. The order
tag supports all of the same inputs as it does when used with lists.
In the example below, Q1, Q2, and Q3 are displayed on separate pages. All pages will be randomized ([*]
), and the final page will be anchored ($
), which is Q3.
startgroup: RANDOMIZE
order: [*],$
1. This question could be shown first or second.
type: text
2. This question could be shown first or second as well.
type: text
3. This question is anchored in place with the '$' symbol, and will always be last.
type: text
endgroup: RANDOMIZE
Randomizing nested groups
order
tag also works with nested groups so that content (pages with text, questions, and groups) can be ordered within other ordered groups. In this next example, INNER_GROUP_A and INNER_GROUP_B are randomized, so some respondents see questions 3 and 4 first, while others see questions 1 and 2. The content within each groups is also randomized. However, each set of randomized questions will always appear together.
startgroup: OUTER_GROUP
order: [*]
startgroup: INNER_GROUP_A
order: [*]
1. Question 1 is randomized with question 2.
type: radio
1. Yes
2. No
2. Question 2 is randomized with question 1.
type: radio
1. Yes
2. No
endgroup: INNER_GROUP_A
startgroup: INNER_GROUP_B
order: [*]
3. Question 3 is randomized with question 4.
type: radio
1. Yes
2. No
4. Question 4 is randomized with question 3.
type: radio
1. Yes
2. No
endgroup: INNER_GROUP_B
endgroup: OUTER_GROUP
Comments
0 comments
Please sign in to leave a comment.