So, you only want to display 5 out of 20 options randomly without user input?
And it is only the array question where this selection is displayed?
In this case you may do it by
inserting this script in a question of type "short text" (Q1)
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 array
var arr = [];
for (var i = 1; i < 21; i++)
{
w=("00" + i).slice(-2);
arr.push(w);
}
arr = shuffle(arr);
anumbers = arr.slice(0,5).join(',');
$('#question{QID} input[type="text"]').val("#"+anumbers);
// $('#question{QID}').hide();
});
</script>
You will get this
And the rows of the array you display with subquestion relevance using the function "strpos(haystack,needle)"
1st row: strpos(Q1,"01")>0
2nd row: strpos(Q1,"02")>0
...
Joffm
P.S. the hashtag is to avoid an index of "0".
Without it the result of strpos(Q1,"03") would be "0" (strpos starts counting at 0). But this also means "not found".