- Posts: 5
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ 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; } //Identify this question var thisQuestion = $('#question{QID}'); var thisAnswerList = $('tr.answers-list:eq(0)', thisQuestion).parent(); // Fill the arrays with the subquestion codes var arrayA=[1,2,3]; var arrayB=[4,5,6]; var arrayC=[7,8,9]; shuffleArray(arrayA); shuffleArray(arrayB); shuffleArray(arrayC); var arrayZ=[arrayA,arrayB,arrayC]; shuffleArray(arrayZ); var answerCodes = arrayZ.join(",").split(','); // Loop through the answer codes $.each(answerCodes, function(i, val) { // Move the answer item $(thisAnswerList).append($('tr.answers-list[id$="X{QID}'+val+'"]', thisQuestion)); }); }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.