You have to generate the random marks before.
Then you display them by subquestion relevance.
1. Create a question of type "short text". Let's call it Q0.
Enter this in the question text (source code mode)
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 <17; i++) {
arr.push(i);
}
arr = shuffle(arr);
anumbers = arr.slice(0,8).join(',');
$('#question{QID} input[type="text"]').val("#,"+anumbers+",");
$('#question{QID}').hide();
});
</script>
You will get something like "#,12,5,3,11,15,6,4,10,"
2. Set the subquestion relvances to
1st item: strpos(Q0,",1,")>0
2nt item: strpos(Q0,",2,")>0
3rd item: strpos(Q0,",3,")>0
...
16th item: strpos(Q0,",16,")>0
Joffm