Here an example with some javascript.
Included are two different ways to select 3 out of 8.
The first (with the four multiple questions)
Code:
<script type="text/javascript" charset="utf-8">
var numberToShow = 3;
$(document).on('ready', function(){
if($('#question{QID} input:checkbox:checked').length == 0) {
$('#question{QID} input:checkbox:lt('+numberToShow+')').each(function(i) {
$(this).nextAll('input:hidden').val('Y');
$(this).prop('checked', true).trigger('change');
});
}
});
</script>
All these questions have 8 subquesions and 3 are randomly checked.
So the relevance equation of your questions are like
M1_SQ001=="Y"
The second option with an question of type "short text"
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 arr1 = [11,12,13,14,15,16,17,18];
var arr2 = [21,22,23,24,25,26,27,28];
var arr3 = [31,32,33,34,35,36,37,38];
var arr4 = [41,42,43,44,45,46,47,48];
arr1 = shuffle(arr1);
arr2 = shuffle(arr2);
arr3 = shuffle(arr3);
arr4 = shuffle(arr4);
arr1 = arr1.slice(0,3).join(',');
arr2 = arr2.slice(0,3).join(',');
arr3 = arr3.slice(0,3).join(',');
arr4 = arr4.slice(0,3).join(',');
$('#question{QID} input[type="text"]').val("#,"+arr1+","+arr2+","+arr3+","+arr4);
$('#question{QID}').hide();
});
</script>
Four arrays are shuffled and then the first three elements are extracted and joined to the result string.
In this case the relevance equation looks like
strpos(Sel,"31")>0
ALL 48 questions get the same randomization group name.
Joffm