Hi, please, do not confuse us.
You are a long time user to know that "group" has a special meaning in the LS structure.
Well, my idea is:
In a question of type "short text" (QOrder) create the order.
- Three arrays with the question codes without the code of the header
- Shuffle the arrays
- Put the header codes at the beginning of each array
- Create a random number (1-6)
- Depending on this number "concat" the arrays
- Put the "other" code at the and of the final array
Code:
<script type="text/javascript">
$(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;
array = array[j];
array[j] = temp;
}
return array;
}
//Identify this question
var thisQuestion = $('#question{QID}');
var thisAnswerList = $('tr.answers-list:eq(0)', thisQuestion).parent();
// Create the arrays with "normal" codes
var array1=[2,3,4];
var array2=[6,7,8,9];
var array3=[11,12];
var arrayG=;
// Shuffle the arrays
shuffleArray(array1);
shuffleArray(array2);
shuffleArray(array3);
// Add the Header code
array1.unshift(1);
array2.unshift(5);
array3.unshift(10);
// Create a random number (1-6)
var rn=Math.floor(Math.random() * 6 + 1);
if(rn==1) { arrayG=array1.concat(array2,array3); }
if(rn==2) { arrayG=array1.concat(array3,array2); }
if(rn==3) { arrayG=array2.concat(array1,array3); }
if(rn==4) { arrayG=array2.concat(array3,array1); }
if(rn==5) { arrayG=array3.concat(array1,array2); }
if(rn==6) { arrayG=array3.concat(array2,array1); }
// Add the "other"code
arrayG.push('other');
$('input:text', thisQuestion).val(arrayG);
});
</script>
In your multiple question insert this script
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
//Identify this question
var thisQuestion = $('#question{QID}');
var thisAnswerList = $('li.answer-item:eq(0)', thisQuestion).parent();
// Retrieve the answer codes from the "randomOrder" question
var answerCodes = '{QOrder}'.split(',');
// Loop through the answer codes
$.each(answerCodes, function(i, val) {
// Move the answer item
$(thisAnswerList).append($('li.answer-item[id$="X{QID}'+val+'"]', thisQuestion));
});
});
</script>
The remaining issue is:
You removed the checkboxes of the headers fix.
You should remove the headers if the codes are equal a header code.
Joffm