The Rank Sort question offers an engaging ranking experience for respondents. With the Rank Sort question, respondents are able to rank a list of items by clicking the items or dragging and dropping them into their preferred order.
In some cases, however, there is a need to dynamically control certain aspects of the Rank Sort question (e.g., the number of rankable items or the minimum number of ranks) based on a control question. This article outlines the process for creating a dynamic ranking question that adjusts its response options according to respondents’ answers to the control question.
Programming the Control Question
In this example, the control question is a multi-select brand awareness question containing five unique brands. In the follow-up Rank Sort question, respondents will only be required to rank the brands with which they indicate they are familiar here.
Randomize Brand List
Brands in the control question can be randomized by checking the box for "Rows" under "Randomize" in the options panel.
Programming the Rank Sort Question
The Rank Sort Question is a dynamic question that is available within the Survey Elements Menu. To add a Rank Sort question, click "+ Element" and select "Rate, Rank, & Sort" under "Question Types".Then select "Rank Sort" and click "Add".
Note: The Rank Sort element utilizes a select form and must contain multiple labels and items.
The Rank Labels are the ranks that will be assigned by respondents. In this example, there are five rank labels, one for each potentially visible brand.
The Rankable Items are the options that respondents will rank. In this example, the same brand list is used as it was in the control question.
Learn More: Rank Sort Question
Randomize Brand List
As with the control question, the brands in a Rank Sort question can be randomized. This can be accomplished by checking the box for "Rows" under "Randomize" in the options panel.
However, this will display the brands in a new random order and can create confusion for respondents. Instead, the order of the brands should match that assigned in the control question. This can be adjusted by selecting “shuffleBy” in the "More Options" drop-down in the options panel and passing the question label of the control question as the value.
Show Brands Conditionally
Only brands selected in the control question should display in the Rank Sort question. This can be accomplished using the Answer Piping tool in the Survey Editor, or by adding the
rowCond attribute to the survey XML.
Rankable items can be displayed conditionally by selecting "Answer Piping" from the Rankable Item Actions menu:
Selecting "Answer Piping" will open the "Show rows/cols if" menu in the options panel. From the drop-down menu, select the control question and “is selected” to only show the brands with which respondents indicate they are familiar.
Learn More: Answer Piping
Since rankable items correspond to
<row> elements in the XML, this change can be made from the XML Editor by adding the
rowCond attribute to the question tag of the Rank Sort element.
The code below will display rankable items only if the row in the corresponding index was selected in the control question:
Learn More: Adding Condition/Skip Logic
Show Ranks Conditionally
The number of ranks that display should correspond to the number of items selected in the control question.
In the Rank Sort question, rank labels correspond to the
<choice> element in the XML. The number of displayed ranks can be controlled by adding the
choiceCond attribute to the question tag of the Rank Sort question.
The code below will show respondents only the rank labels that are equal to the number of brands selected in the control question:
choiceCond="q1.count ge choice.index+1"
Update minRanks Dynamically
One requirement for the Rank Sort question is the inclusion of the
minRanks defines the minimum number of ranks that must be assigned for a respondent to move past the Rank Sort question.
Unfortunately, a static value for
minRanks can present problems in situations such as this, where aspects of the Rank Sort question are dynamic. For instance, if
minRanks is set to
3 but only two rankable items and ranks are shown, the respondent will not be able to proceed in the survey.
This can be avoided by dynamically updating the
minRanks attribute based on the number of answers selected in the control question.
minRanks can be modified programmatically with Python code.
exec block below within the Rank Sort question will dynamically update the
minRanks attribute to the count of responses provided in the control question.
Q20.minRanks = Q19.count
Results of Dynamically Controlling a Rank Sort Question
A summary of the critical changes can be found below:
shuffleBy="Q19"matches the order of the brand list to the control question.
rowCond="Q19[row.index]"only displays brands that were selected in the control question.
choiceCond="Q19.count ge choice.index+1"limits the number of ranks to the count of brands selected in the control question.
Q20.minRanks = Q19.countdynamically updates the minimum number of ranks to the count of brands selected in the control question.
cond="Q19.count ge 1"
choiceCond="Q19.count ge choice.index+1"
<title>Please rank the following items:</title>
<comment>Click or drag each item into a rank position.</comment>
Q20.minRanks = Q19.count
<row label="r1">Brand 1</row>
<row label="r2">Brand 2</row>
<row label="r3">Brand 3</row>
<row label="r4">Brand 4</row>
<row label="r5">Brand 5</row>