Author > Creating questions and responses > Question type overview > Creating loops to ask the same questions for different subjects
 
Creating loops to ask the same questions for different subjects
You may want to ask the same group of questions a number of times, for a different subject each time. One way to do this is to use a Loop, which is a container for a set of questions, with options for determining how many times the questions are asked. The questions can be asked:
a fixed number of times
a number of times based on a list of entered responses
a variable number of times, where the number is taken from the response to a numeric question
once for each response in a single or multiple response question
a number of times based on a shared list of responses
an unspecified number of times (known as an unbounded loop).
For example, suppose that you have a set of questions about vacations, such as, "How long the vacation lasted", "The number of people in your group", "Mode of travel", and you want to ask the questions for a number of vacations that the respondent has taken. You might choose to do this in a number of ways; here are some examples:
Decide on a fixed number in advance and ask all respondents to answer the questions this many times. For example, "For each of the last three vacations you took, please say...".
Begin by asking "How many vacations did you take last year?", then ask the questions once for each vacation that the respondent took.
Begin by asking the respondent to select a range of destinations and then ask the question once for each destination selected.
You can create a loop and then add questions to it, or you can select existing questions and group them in a loop. Loops can contain any type of question.
See also Creating grid questions.
Notes
The Routings section of the Properties pane allows you to select an interviewing mode for the questionnaire. This controls the supported question types. Paper - Scanning mode does not support True or False, Date/Time, Loop, or Block question types. So if you select Paper - Scanning for the interviewing mode, selection of these question types will be automatically disabled.
When a loop is not directly in a routing (for example, in an existing block or loop), it is not considered a routing item. In these cases it is not possible to set a loop iterator from within UNICOM Intelligence Author. You can achieve similar functionality by creating a script routing item that sets the loop iterator (from within UNICOM Intelligence Professional for example).
Creating a new loop
1 From the menu, choose Insert > Question > Loop or press Alt+I, Q, L.
2 Create the questions you want to add to the loop.
3 Select the questions using Shift+click or Ctrl+click.
4 While still in the Routings pane, drag the selected questions into the newly created loop. The questions are added to the loop.
5 The loop has an automatically generated name. Optionally, select the default name and change it to a more meaningful name. See Automatically generated names.
6 Optionally, enter a loop description in the text field located beneath the Name field. The description will display at the top of the page.
Grouping existing questions in a loop
1 Use Shift+click to select all the questions you want to group.
2 From the menu, choose Group > Group In > Loop or press Alt+G, G, L.
A new Loop item appears in the Routings pane, and the selected questions are moved into the loop.
3 The loop has an automatically generated name. Optionally, select the default name and change it to a more meaningful name. See Automatically generated names.
4 Optionally, enter a loop description in the text field located beneath the Name field. The description will display at the top of the page.
Configuring a numeric iterator for a child loop that is grouped under a parent loop
The following code sample provides an example:
Persons.QuestionFilter = PeopleInHousehold
For Each Person in Persons
Person.Details.Ask()
Person.NumberOfTrips.Ask()
Person.Trips.QuestionsFilter = Person.NumberOfTrips
Person.Trips.Ask()
Next
See also
Specifying additional question details in the Properties pane
Setting the number of times to ask the questions in the loop
Question type overview