In the meantime I got a solution according to your first example in "examplequestions.lss"
Well, here it is.
First you create a random string of the numbers of your cards in a question of type "short text" (let's call it H0)
insert this javascript snippet.
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 = [];
// create an array with the number of your cards (here 20)
for (i = 1; i < 21; i++) {
w=("000" + i).slice(-3);
arr.push(w);
}
arr = shuffle(arr);
// Limit the array to the first (here 20) elements
anumbers = arr.slice(0,20).join('');
$('#question{QID} input[type="text"]').val(anumbers);
$('#question{QID}').hide();
$('#ls-button-submit').trigger('click');
});
</script>
You get something like this.
You see this string contains all numbers from 1 to 20, left padded like "001", "002, ...
In the later display we take the first and the second, the third and the fourth, ... number to select the displayed cards.
Next.
In a question of type "long text" you enter your cards as default answer. (let's call it H1)
Like
...
Each attribute of same length (here 20 characters). and a total length per row of 80 characters.
Now it is easy to select the row according to the number and each of the four attributes
So for the first number in the string:
1st attribute: {trim(substr(substr(H1, (substr(H0, 0, 3) - 1) * 82, 80),0,20))}
2nd attribute: {trim(substr(substr(H1, (substr(H0, 0, 3) - 1) * 82, 80),20,20))}
3rd attribute: {trim(substr(substr(H1, (substr(H0, 0, 3) - 1) * 82, 80),40,20))}
4th attribute: {trim(substr(substr(H1, (substr(H0, 0, 3) - 1) * 82, 80),60,20))}
So for the second number in the string:
1st attribute: {trim(substr(substr(H1, (substr(H0, 3, 3) - 1) * 82, 80),0,20))}
2nd attribute: {trim(substr(substr(H1, (substr(H0, 3, 3) - 1) * 82, 80),20,20))}
3rd attribute: {trim(substr(substr(H1, (substr(H0, 3, 3) - 1) * 82, 80),40,20))}
4th attribute: {trim(substr(substr(H1, (substr(H0, 3, 3) - 1) * 82, 80),60,20))}
You see the logic?
And the "82"? This is because you have to consider the added carriage return and linefeed character.
You will get questions like:
And because you created 20 numbers you will be able to display 10 questions with different options.
To adapt it is up to you.
Have a look at the example.
Joffm