6 Replies Latest reply on Feb 6, 2009 7:47 AM by John Hall

    Add levels to a quiz?

    Handycam Level 1
      I have created the beginnings of a quiz application. I have an mxml component of a "question" which i instantiate into a viewstack depending on the number of questions in an XML file (thank you, Greg Lafrance!). I populate each with the appropriate info from the xml file. I am still in the process of adding feedback, scoring, etc.

      My question is, what would be the cleanest way to add multiple levels for this quiz? If right now my xml file has 10 questions and i want that to be level one, and if the score exceeds a certain number, they can move on the level 2. Managing the move up I can do, it's just what would be the cleanest and most scalable way to structure my xml file and the loop to create the questions for each level?
        • 1. Add levels to a quiz?
          Gregory Lafrance Level 6
          I'm tempted to say that each level's question should be in it's own file, that way you could add as many levels as necessary with no code change.

          In that case, if the score exceeds the threshold number to move to the next level, and if there were a next level, then just load the data for the next level from the next question file. There would be some metadata mechanism so the app knows for the current quiz, when there is a next level.

          One additional idea that probably is a bit out of place at this point in your idea phase. There could be one large questions file (or there could be multiple question files if there is some concern about the hit for downloading them all), and there could be some way to access those questions by ID. Then if questions could belong to one level for one quiz, and a different level for another quiz, the quiz metadata could pull questions from the master questions pool, assigning them to levels appropriate for that quiz.

          Just an idea, and please forgive me if I have overstepped the bounds of being helpful, into the realm of being intrusive. :-)
          • 2. Re: Add levels to a quiz?
            Handycam Level 1
            quote:

            Originally posted by: Greg Lafrance
            I'm tempted to say that each level's question should be in it's own file, that way you could add as many levels as necessary with no code change.


            I was thinking along those lines as well. How would I best do that? Use the same httpservice? Is it as simple as setting dataRequest.url="quiz-lvel2.xml" and dataRequest.send()?
            • 3. Re: Add levels to a quiz?
              Gregory Lafrance Level 6
              I've never done that, but I would think it would be that simple.
              • 4. Re: Add levels to a quiz?
                Handycam Level 1
                quote:

                Originally posted by: Greg Lafrance
                I've never done that, but I would think it would be that simple.


                Do you recommend a different way? Just curious.
                • 5. Re: Add levels to a quiz?
                  Gregory Lafrance Level 6
                  I think that is how I would do it. It might be possible to have a method called when the threshold score is reached, something like getNextLevel(nextLevelNumber);

                  That function could use the arg nextLevelNumber to create a file name quiz1Level1.xml ---> quiz1Level2.xml, assign that to the HTTPService url property, call send(), and then have the createQuestions function recreate the UI.

                  Sounds like a cool app you are creating!
                  • 6. Re: Add levels to a quiz?
                    John Hall Level 4
                    You can also create your XML to have nodes with a level node built in, if you want to keep everything in one cell. If I were doing this with a database, I'd probably have a table for questions with degreeOfDifficulty or level or something and another table with distracters with the questionID associated with them. Bottom line is you're doing exactly what you should be doing, thinking about alternatives and then just picking one that doesn't preclude changing the data structure or provider later on, as long as you know you can count on a collection coming in to the app.

                    I've done a few apps like this and tried several techniques. Go figure; they can all work as long as you brainstorm all the use cases ahead of time and make sure nothing in Flex precludes adding features later.