3 Replies Latest reply on Oct 12, 2006 3:08 AM by DazFaz

    Arrays

    leewilson86 Level 1
      Hello i am creating an assessment application in a similar style to the British driving theory test.

      As the user goes through each question their answer is stored in an array.

      The user is also given the choice to FLAG! a question if they are not sure of the answer so they can return to it later. This is the part i am having trouble as i want to recall this array to only show the question which is stored in this array,

      For example if the array which detects a flagged question is called:

      userFlagged = [];

      and if they are not sure of the answer to question 2, 5 and 9, then the array will look like this after the user has clicked flagged on this questions,

      userFlagged = [2,5,9];

      how would i be able to reload this array afterwards so that instead of the application going through question 1 then 2 then 3 then 4 etc etc etc, but instead go through the values in the array to show questions 2 then 5 then 9?

      this is the only thing i need help with as i can get the rest of the data to load correctly.

      thanks

      lee
        • 1. Re: Arrays
          DazFaz Level 1
          A few questions first.
          1. Are you posting the answers to a database?
          2. When you say "how would i be able to reload this array afterwards" does this mean the user can quit the application and come back to it days later?
          3. Is this a bespoked application (exe) or online?
          4. Is each test sat unique to that user. Meaning, do they login and so on?
          • 2. Re: Arrays
            leewilson86 Level 1
            Fistly thank you very much for your reply its appreciated,

            The application is online. The user does not log in as such however their name is saved to variables and they do need a password to get logged on as teachers in a school will log each child in.

            the values arent stored in a database as the user is required to answer each question there and then and then print off their results.

            the only thing i need to get round this is just to sort out the userFlagged array.

            i think using a FOR loop would work but i really do think that it will be very long winded and i am sure there is a quicker way of doing this.

            i hope this helps you understand the situation more

            thanks

            lee
            • 3. Arrays
              DazFaz Level 1
              // this would be trigggered on the very start of the test and only once
              QuestionsAnswered = function(){
              var answerArray = new Array()
              for(var x_x = 1;x_x<=numberOfQuestionsInTest;x_x++){
              answerArray[x_x] = 0;//sets ALL questions to NOT answered
              }
              }
              QuestionsAnswered();
              //Now all you have to do is populate this each time the user answers a quesiton
              answerArray[questionNumberThatTheUserIsOn] = 1
              //The at the end of the test all you have to do is cycle through the answer array
              // to see which ones are either 0 (NOT answered) or 1 (answered)