I think that Bigred has put his finger on it, although my approach would be slightly different.
Let's say, for a simpler example, that you wanted to randomly display 4 out of a set of 10 questions.
Somewhere preceding the set of 10, I would place a multiple-short-text question with 10 sub-questions - one for each of the set.
In that multiple-short-text, I place the script below which shuffles an array and populates a random 4 of the sub-questions with "1". Then relevance is used to only show the questions in the set of 10 that correspond to sub-questions that equal 1.
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Hide this question
$('#question{QID}').hide();
// An array defining total number of questions in the set and number to be shown
// In this case, 4 of 10 will be shown
var setArray = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0];
// Shuffle the array
setArray = $.shuffle(setArray);
// Loop Through the array and populate the sub-questions
$(setArray).each(function(i, value) {
if($('#question{QID} input.text:eq('+i+')').val() == '') {
$('#question{QID} input.text:eq('+i+')').val(value);
}
});
});
// A function to shuffle arrays
(function($){
$.fn.shuffle = function() {
return this.each(function(){
var items = $(this).children();
return (items.length)
? $(this).html($.shuffle(items))
: this;
});
}
$.shuffle = function(arr) {
for(
var j, x, i = arr.length; i;
j = parseInt(Math.random() * i),
x = arr[--i], arr[i] = arr[j], arr[j] = x
);
return arr;
}
})(jQuery);
</script>
A sample survey: