You can do this.
The question "randOrder" is a question of type "short text" where you generate your order with a small script
like this
Code:
<script type="text/javascript" charset="utf-8">
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
$(document).on('ready pjax:scriptcomplete',function(){
// Fill the arrays
var arrTopFix = [1,2] ;
var arrRand = [3,4,5,6];
var arrBottomFix = [7] ;
var arrTotal = ;
arrTopFix = arrTopFix.join(',');
arrRand = shuffle(arrRand).join(',');;
arrBottomFix = arrBottomFix.join(',');
arrTotal=arrTopFix.concat(',',arrRand,',',arrBottomFix);
$('#question{QID} input[type="text"]').val(arrTotal);
// Nach dem Testen in dieser letzten Zeile die Schrägstriche entfernen
//$('#question{QID}').hide();
});
</script>
Here you may adapt the three arrays to your needs.
Now you use the script to maintain a randomization order.
Code:
<script type="text/javascript" data-author="Tony Partner">
$(document).on('ready pjax:scriptcomplete',function(){
//Identify this question
var thisQuestion = $('#question{QID}');
var thisAnswerList = $('tr.answers-list:eq(0)', thisQuestion).parent();
// Retrieve the answer codes from the "randOrder" question
var answerCodes = '{randOrder}'.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>
The above script is for "array" questions.
For "multiple" questions you have to change this to
// Move the answer item
$(thisAnswerList).append($('li.checkbox-text-item[id$="X{QID}'+val+'"]', thisQuestion));
And for "list(radio)" to
// Move the answer item
$(thisAnswerList).append($('li.answer-item[id$="X{QID}'+val+'"]', thisQuestion));
Regarding this
Fix some answers in their current position
Here you may randomize all codes except these answers; then put them back to their position with function "splice()"
[url]
www.w3schools.com/jsref/jsref_splice.asp
[/url]
Joffm