I'm using an array questions that has 18 subquestions. I want to randomize 17 subquestions (1-17) but the last one should always remain in the last place. Number 18 is not an exclusive option though.
thanks a lot for your answer! It works fine for the array type question. However, now I need the same for a multiple choice question. According to the code you sent it should also work for such question type. Nevertheless, even in the example survey it only works for array but not multiple choice. Might be it's because of the limesurvey version I'm using (3.6.2)?
I also attached the file (it's Q3)
Maybe you or someone else has an idea - would be highly appreciated.
Thanks for your help!
There have been HTML structure changes in 3.x so the script now needs to like this:
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var qID = {QID};
var thisQuestion = $('#question'+qID);
// Define the sub-question codes to be placed last
var lastItems = ['SQ006', 'SQ007', 'SQ008'];
// Loop through those sub-question codes
$.each(lastItems, function(i, val) {
// Move that item to the end of the list
// Multi-choice question
if($(thisQuestion).hasClass('multiple-opt')) {
$('.question-item[id$=X'+qID+val+']', thisQuestion).appendTo($('.question-item[id$=X'+qID+val+']', thisQuestion).parent());
}
// Array question
if($(thisQuestion).hasClass('array-flexible-row')) {
$('.answers-list[id$=X'+qID+val+']', thisQuestion).appendTo($('table.subquestion-list tbody:last', thisQuestion));
}
// List-radio question
if($(thisQuestion).hasClass('list-radio')) {
$('.answer-item[id$=X'+qID+val+']', thisQuestion).appendTo($('.answer-item[id$=X'+qID+val+']', thisQuestion).parent());
}
});
});
</script>
Here is your sample survey back with those changes: