Hi guys, I was looking for this solution Tony is written about for some long period of time. I imported the last survey example in my LimeSurvey 3.6.3. Does anybody know what should I change to make it work in my version?
This will maintain the order in multiple-choice questions, in different groups, using columns, in version 3.22.210.
(if using an earlier 3.x version, disable AJAX in the survey theme options)
In the first question:
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){//Identify the questionsvar thisQuestion = $('#question{QID}');var hiddenQuestion = $(thisQuestion).nextAll('.text-short:eq(0)');// Create an array of answer codesvar answerCodes =[];
$('.answer-item', thisQuestion).each(function(i){
answerCodes.push($(this).attr('id').split('X{QID}')[1]);});// Load the hidden question
$('input:text', hiddenQuestion).val(answerCodes);});</script>
In following questions:
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){//Identify this questionvar thisQuestion = $('#question{QID}');// Determine the number of items in the first columnvar rowCount = $('.answers-list.multiple-list > ul:eq(0) .question-item', thisQuestion).length;// Retrieve the answer codes from the "randomOrder" questionvar answerCodes ='{randomOrder}'.split(',');
console.log(answerCodes);// Loop through the answer codesvar row =0;var column =0;
$.each(answerCodes,function(i, val){// Move the answer item
$('.answers-list.multiple-list > ul:eq('+column+')', thisQuestion).append($('.answer-item[id$="X{QID}'+val+'"]', thisQuestion));if(row <(rowCount-1)){
row++;}else{// Increment the column
row =0;
column++;}});});</script>