Hello all
I would like to create a quiz form which shows a random selection out of a list of questions (e.g. 3 questions out of 10 in a list). It should also present 4 connected, possible answers per question (A-D). Finally, the selected answer should be validated against an answer key.
I've achieved the random selection of questions using Javascript. 3 unique random numbers are generated and used to lookup a specific question from the question list.
var arr = [];while (arr.length < 3) { var r = Math.floor(Math.random() * 10) + 1; if (arr.indexOf(r) === -1) arr.push(r);
var one = arr[0]; var two = arr[1]; var three = arr[2];}
NWF$(document).ready(function() { NWF$("#" + Q1).val(one);});
NWF$(document).ready(function() { NWF$("#" + Q2).val(two);});
NWF$(document).ready(function() { NWF$("#" + Q3).val(three);});
Now, I would like to show/lookup 4 answers per question (A-D) and validate these against the answer key. (e.g. For question 3, answer B is correct).
However, with the last part I'm struggling. Hopefully someone can help me with the correct list structure and lookup for the answers and validation for the answer.
Thanks in advance