Previous Next

To open or use this sample form, go to the Design tab, scroll down to the Your forms and datasets section, and click + then Start new form; then enable Use a sample form as your starting point and choose Follow-ups: Asking follow-up questions for a list of selected items from the list. You can also click here to download the spreadsheet form definition (this is a .zip file that contains a .xlsx sample form, a .csv file containing sample data for pre-loading, and the original .xlsx source for the .csv file).

If you upload the spreadsheet form definition to your SurveyCTO server manually, be sure to attach the .csv file – or upload the .csv file as a dataset named sampleq4list_options and then attach that dataset – otherwise the form won't be able to find the data when users are filling it out.

This sample is somewhat advanced. It combines and extends techniques illustrated by the earlier Rosters: Collecting repeated information with multiple repeats and Pre-loading: Searching and selecting from pre-loaded data sample forms.

The focus here is on five methods you might use to ask follow-up questions for a selected list of options. For example, you might want to ask a farmer which of many possible crops she has cultivated, then follow up with a list of specific questions for each of the crops she chose; or, you might ask which of many types of assets she acquired over the past year, then follow up with additional questions about those assets. This sample itself is framed around crops, but the demonstrated techniques are entirely general: you can use them for any case in which you want to ask follow-up questions for just those items selected from a list.

Method 1 uses a simple select_multiple field to ask the user to check off one or more crops, then uses a repeat group to iterate through each selected crop. (This method is not recommended for reasons described below.)

typenamelabelrepeat_count
select_multiple croplistselected_crops1Please choose zero or more crops from the following list. 
begin repeatcrop_repeat1Follow-up questions (${crop_name1})count-selected(${selected_crops1})
...   
end repeatcrop_repeat1  

Within the repeat group, calculate fields are used to pull the appropriate crop ID and label from the earlier select_multiple field, which in turn informs the open-ended follow-up question follows:

typenamelabelcalculation
calculatecrop_id1 selected-at(${selected_crops1}, index()-1)
calculatecrop_name1 jr:choice-name(${crop_id1}, '${selected_crops1}')
textcrop_question1This is an example follow-up question about the following crop: ${crop_name1} 

See the "rosters" sample for the basics of asking repeated questions, or see the help on using expressions for more about the functions used in this form.

Method 2 is precisely the same, except the list of options comes from a pre-loaded .csv file (or attached dataset) rather than coming from the choices sheet. This method might be preferred when the list of options is extremely long and/or you would like to be able to update the list of options without having to update the form itself. See the sample on searching and selecting from pre-loaded data for more on pulling multiple-choice options from a pre-loaded .csv file. (This method is also not recommended for reasons described below.)

To the user, Method 3 looks identical to Method 2, but behind the scenes the implementation is importantly different – and it avoids one serious drawback present in both Method 1 and Method 2. In the earlier methods, everything would work fine so long as the user proceeded linearly through the form, selecting crops and entering follow-up responses, but it would present some difficulties if the user were to go back and change the crop selections after entering follow-up responses.

For example, say the user selects crops 1, 2, and 4, answers the follow-up questions, and then goes back and selects also crop 3. The third set of follow-up questions would now suddenly be associated with crop 3, whereas it had earlier been associated with crop 4 (since crop 4 had been the user's third selection). The user would need to go through and carefully adjust his or her responses accordingly.

The solution used by Method 3 is to always repeat the follow-up questions x times, where x is the total number of crops (in contrast, Methods 1 and 2 used the number of selected crops as x, rather than the total). In order to avoid asking questions about crops that weren't selected, Method 3 then employs the standard relevance capability, to simply hide the follow-up questions associated with crops that weren't selected.

Method 4 uses this same method, but using options from the choices sheet rather than using options pre-loaded from a .csv file. Thus, Method 3 is the preferred alternative to Method 2 and Method 4 is the preferred alternative to Method 1.

Both Methods 3 and 4 do come at a cost: by including follow-up questions for every possible choice – albeit, with the non-selected ones hidden – the form might perform a bit slower (particularly when there are a large number of options and/or follow-up questions and when the devices are older). More blank data will also be exported for all of the hidden follow-up questions, though this might be viewed as an advantage since the data structure might be simpler to use in practice.

Finally, Method 5 demonstrates an alternative questioning sequence to Method 3: instead of asking the user to select all relevant crops before moving to follow-up questions, Method 5 simply iterates through all crops asking a yes/no question first and then asking follow-up questions after each yes.

Upload the sample form – along with its pre-loaded option data, sampleq4list_options.csv, as an attachment (or upload the .csv file as a dataset named sampleq4list_options and then attach that dataset) – and try the form for yourself. It presents a simple enough interface for users but uses a few relatively advanced techniques to make that possible.

Previous Next