Introduction
This article accompanies this sample form. Please read the following and test the sample form. Either save a copy of the sample form in your Google Drive or download as an Excel workbook.
The best way to facilitate ranking a list of items is using the ranking-choices field plug-in, which allows you to reorder a choice list on a single screen. Alternatively, use the form design strategy described below to rank a list of choices using a number of select_one fields on different screens. This form design strategy also has merit, as it would allow you to display and emphasise previously selected ranks from previous screens. |
The way to program a question in which a set of options are ranked is to use choice filtering on a series of select_one fields. Similar to the way we can use relevance to specify whether questions should be visible under a certain set of circumstances or not, choice filters allow you to specify whether all the choices in a choice list should be visible or not.
In this ranking programming method, you will have one select_one field per ranked item (1st, 2nd, 3rd, etc). In each subsequent field, you will filter out the selections made in all of the previous fields. In this way the choice from rank 1 will not be available to choose again when choosing rank 2 and so forth.
The first set of instructions will show you how to implement this using our online form designer. Scroll down to see how it will look in an Excel form or Google Sheet, and to download an example Excel file. You can upload the Excel file and then open it in the online Form Designer as well.
Note: the expressions needed for the choice_filter parameter for a field cannot be built in our Build Relevance or Build Calculation tools on the Design tab of the server console or the online form designer. They are custom expressions that you must specify by hand, and of course, you can use the examples here as a template to work with for your form.
Working in the online form designer
1. Create four select_one fields which all use the same choice list. In this example we are using a choice list named "rankoptions" and fields named "rank1" through "rank4".
2. Add a unique filter to each of the choice list options. The entry in the filter entry box should match whatever is in the value entry box in this case (for this specific use case - there are other situations where you’d use other values in the filter column). Then hit the Save now button to return to the main page of the online form designer.
3. Add the following expression to the choice_filter entry box of the
field "rank2":
not(selected(${rank1}, filter))
What this expression “says” is that for this question, a choice list option should only be displayed if it was not already selected in the field "rank1". Again, this is not an expression that can currently be constructed using our Build Relevance or Build Calculation tools. This is a custom expression that you must specify by hand.
4. Add the following expression to the choice_filter entry box of the field "rank3":
not(selected(${rank1}, filter)) and not(selected(${rank2}, filter))
5. Add the following expression to the choice_filter entry box of the field "rank4":
not(selected(${rank1}, filter)) and not(selected(${rank2}, filter)) and
not(selected(${rank3}, filter))
In points 4 and 5, above. This logic is extended. In Point 4, the selections made in "rank1" and "rank2" are filtered out of the available options for "rank3". The same is happening in point 5, cumulatively excluding the selection made in "rank3" from the options available in "rank4". You can extend this further, to establish more than 3 ranks.
View a Sample Form on Ranking
View a working sample form here in a Google Sheet that illustrates this programming method (linked above as well). You can download this sample as an Excel file or make a copy you can edit in Google Drive.
Upload this form to your SurveyCTO server from the Design tab by clicking on the Upload form definition button (after clicking on “+” after adding your first form). See the key ingredients of this programming approach below, on the survey and choices sheets of a SurveyCTO spreadsheet form template:
survey sheet
type |
name |
label |
choice_filter |
select_one rankoptions |
rank1 |
Which option is your first choice? |
|
select_one rankoptions |
rank2 |
Which option is your second choice? |
not(selected(${rank1}, filter)) |
select_one rankoptions |
rank3 |
Which option is your third choice? |
not(selected(${rank1}, filter)) and not(selected(${rank2}, filter)) |
select_one rankoptions |
rank4 |
Which option is your fourth choice? |
not(selected(${rank1}, filter)) and not(selected(${rank2}, filter)) and not(selected(${rank3}, filter)) |
choices sheet
list_name | value | label | filter |
rankoptions | 1 | Option 1 | 1 |
rankoptions | 2 | Option 2 | 2 |
rankoptions | 3 | Option 3 | 3 |
rankoptions | 4 | Option 4 | 4 |
Read more about the not() and selected() other functions in the topic on using expressions in your forms.
Do you have thoughts on this support article? We'd love to hear them! Feel free to fill out this feedback form.
0 Comments