1 Reply Latest reply on Dec 17, 2008 11:41 PM by kglad

    best way to make a quiz?

    shintashi Level 1
      Hi, I'm trying to create a quiz that asks questions one at a time, then switches to the next question, with each question having (in theory) the same number of options.

      I was thinking a multidimensional array would be the best way to go, with each element in the first array being an array;

      so the first question would present the question plus 3 options,
      the second question presents 3 options,
      and the third question presents 3 options.

      based on these three questions, I should be able to produce 27 different combinations using elements, and based on the pattern, I should be able to scale it up with more questions, or more options per question, for even more combinations.

      The problem I'm experiencing is summarized in the two coding options:

      option 1 doesn't work:
      var aQuestions:Array = ["No questions", "aQuestion3", "aQuestion2", "aQuestion3"];
      this just produces text
      var aQuestions:Array = ["No questions", aQuestions, aQuestion2, aQuestion3];
      this produces "No questions, undefined, undefined, undefined"

      even though these variables exist, they aren't acknowledged.
      var aQuestion1:Array = ["option1", "option2", "option3"];
      var aQuestion2:Array = ["option4", "option5", "option6"];
      var aQuestion3:Array = ["option7", "option8", "option9"];

      option 2 just produces a wall of text:
      var aQuestions:Array = new Array();
      aQuestions.push(["option1", "option2", "option3"]);
      aQuestions.push(["option4", "option5", "option6"]);
      aQuestions.push(["option7", "option8", "option9"]);

      should I be using functions instead of arrays or is my approach to arrays all wrong?