Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.6.8+230227
Own server
Survey theme/template: Inherit [fruity]
==================
Hello,
I am currently creating a questionnaire containing one group with 18 array questions, with each question containing 6 (identical) subquestions. The subquestions should be presented in a random order for each question. The survey is displayed question by question to the participant. I therefore set the "Random order" Display option to "Yes". When I am previewing the question group, each question gets indeed an individual random subquestion order. This is not the case when activating the survey: in this case, the subquestions are randomly shuffled once, but this order is used for every question in the group. I tested the survey on Chrome and Firefox, the issue appeared on both.
The closest topic I found is this one :
forums.limesurvey.org/forum/can-i-do-thi...s-in-array-by-column
I did not try this solution due to the old age of the topic (5 years) - it seems like random order was not implemented on LimeSurvey on that version yet.
Is there a way to make sure the subquestions get reshuffled for each question? Is there another option I am missing?
Thank you very much, any help is appreciated!
Workaround
The JS code snippet from the old thread mentioned above fixes the problem. You'll need to copy the code below in the question text (using the "Source" editor).
Link:
forums.limesurvey.org/forum/can-i-do-thi...ray-by-column#158346
Code:
Code:
<script type="text/javascript" charset="utf-8">
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}
$(document).on('ready pjax:complete',function() {
var thisQuestion = $('#question{QID}');
var elements = $('tr.answers-list', thisQuestion).detach().toArray();
shuffleArray(elements);
$('tr.answers-list', thisQuestion).remove();
$. each (elements, function(i, el) {
$('table.subquestion-list tbody:eq(0)', thisQuestion).append(el);
});
});
</script>
Credit to
tpartner