Partially Randomized Answers - Multiple Options & List (radio) questions

This workaround allows the answers of Multiple Options & List (radio) questions to be randomized while always keeping a specified number of answers fixed at the end of the list.

It's useful if you want to randomize, say, the first 4 of your answers but always have the fifth and sixth displayed last as in the image below:




After the question randomizing has occurred, a function in the source of a question moves the answers with the highest answer codes to the end of the list.

Some conditions on the use of this are:

  • The "Show No answer" survey setting must be set to "No"
  • You must use sequential numbers, starting at 1 as response codes.


  1. Create a Multiple Options or List (radio) question with sequential response codes.
  2. Set the "Random order" question setting to "Randomize on each page load".
  3. Open the Advanced Settings panel for the question
  4. Scroll down to the heading Script




  5. Place the following script into the field Javascript for this question:
  6. In the JavaScript set the "fixedAnswers" variable as required (for example, if you want the last 3 answers to be fixed at end of the list replace default value with var fixedAnswers = 2;
	$(document).ready(function() {

// The number of answers to be fixed at the end of the list
var fixedAnswers = 2;
// Identify this question
var qID = {QID};
// Find the number of answers
var ansCount = $('#question'+qID+' .answer-item').length;
// Place the last n answers created at the end of the list
var fixedIndex = fixedAnswers - 1;

		for (var i=0; i<fixedAnswers; i++) {
var answerItem = $('.answer-item[id^="javatbd"][id$="X'+qID+(ansCount-fixedIndex)+'"]');
if($('#question'+qID).hasClass('multiple-opt')) {
$(answerItem).closest('.subquestion-list').append($(answerItem).parent());
}
else {
$(answerItem).closest('.answers-list').append(answerItem);
}
fixedIndex--;
}
});
36 of 79 people found this helpful.   




Powered by LiveZilla Live Chat