5 Replies Latest reply on Apr 27, 2014 1:44 PM by jackblackweb

    Randomise questions for quiz using Director

    ks_17

      Hi everyone,

       

      I'm currently trying to make a quiz using Director. Fairly simple, linear stuff as it's just a prototype. Basically, it will be multiple choice questions and I have used basic lingo so far such as mousedown, mousewithin, goframe, set the blend etc.  I have created 10 questions with their backgrounds in Photoshop and saved them as png files, which I've imported into the Cast on Director along with the buttons, which I also created in Photoshop and imported into the Cast.  The user will need to answer 5 questions out of the 10 and I want it that director will pick them randomly.  It will be a linear game where the user will answer the first question before going onto the next and so on.  But I want Director to pick them randomly because if not then it will just keep displaying the same questions in a row.  Does anyone know how I could do this and what lingo I would need.  Have Googled it but not found anything that makes sense to me anyway.

       

      Thanks

        • 1. Re: Randomise questions for quiz using Director
          jackblackweb Level 1

          ks-17

           

          In message window.

           

          put random(10)

          -- 6

          -- 4

          -- 10

          -- 6

          -- 5

           

          More if needed.

          Jack

          • 2. Re: Randomise questions for quiz using Director
            Sean_Wilson Adobe Community Professional

            If you have your questions stored in a linear list, the simplest option might be something like:

            on mGetQuestion
              tIndex = random( count(lQuestionList) )
              tQuestion = lQuestionList[tIndex]
              lQuestionList.deleteAt(tIndex)
              return tQuestion
            end
            
            • 3. Re: Randomise questions for quiz using Director
              ks_17 Level 1

              Hi Sean_Wilson and jackblackweb,

               

              Thank you both very much for your help.  I've tried it out but am still having problems and it's definitely something to do with what I've done.  I must apologise because I am just starting out with Director, which is why I'm probably asking really stupid questions. I've tried putting both of those in but they don't seem to work or they come out with error messages.  Let me explain further exactly what I am trying to do so that I can make it as easy as possible for me to do this.  I know there are lots of ways to do the same thing but I'm trying to find the most straighforward and easiest way possible. 

               

              So I've imported my 10 questions into DIrector as png files and I have put them on the score.  So question 1 is at frame 10 as sprite 1, question 2 at frame 20 as sprite 2 etc. I've set a frame script at the top so it stays within those frames until the user chooses an answer.  If they are correct it goes to frame 110 as this is where I have my correct image.  I have added all my buttons, drag and drop and input text boxes in so the game in one sense is actually ready to play but it is just that it is progressing in that linear manner, one question after the other. 

               

              Basically, I want it to choose 5 out of 10 random questions.  So I'm wondering if there is some way at the start of the movie it will go to a random question.  Or maybe it will be easier if I create a button and they press it, which then takes them to a random question?  And when the correct screen appears I'll have to set it to go back to that button but then how could I make sure that that question isn't repeated?  The more I think about it the more complicated I can see it's going to be because then I also need to get it to understand that it only asks five questions before going to a screen that I'll need to make, which says the game is over.

               

              Sorry to be so simple but it's driving me mad .  AAHHH!!!

              • 4. Re: Randomise questions for quiz using Director
                ks_17 Level 1

                Sorry me again,

                 

                I just thought I'd explain the picture I have in my head about how it could possibly work because I know how beginner my use of the technical language is lol.

                 

                So I guess one possibility I have in my head is that there is a button which starts the game and instantly chooses a random question out of the 10 that are there on the score by going to the start of one of the frames (like I explained above).  Then if they get it right or wrong it will either way display that relevant image and then go back to that button (I know how to do this bit just by using the basic on mousedown and go frame lingo).  They will then press the button again and it will repick another random question but I don't want it to pick the same one.  I want it to do that 5 times before displaying a screen saying game completed.

                 

                So that's one image I have in my head and the other image is the use of frame scripts.  So I have some kind of lingo at the first frame instructing it to choose from a number of random frames e.g. frame 10, 20, 30 erc.  Then it goes there and the user answers the question, then once that is done it goes back to that frame and then picks another random frame but not the same one and it does this five times.

                 

                I hope I'm talking sense and I'm really grateful for your help so far .

                • 5. Re: Randomise questions for quiz using Director
                  jackblackweb Level 1

                  ks_17

                   

                  There are various ways to do this, here's one.

                  In compliance with my understanding of how the movie is set-up

                  use the Director list object as Sean displayed [].

                   

                  ------------------------------------------------------------------------------------

                  -- at the start of the movie

                   

                  -- create a global list of the 10 frame numbers

                  global listOfQuestionFrameNumbers

                  listOfQuestionFrameNumbers = [10,20,30,40,50,60,70,80,90,100]

                   

                  -- select an item randomly from list

                  theItemNumber = random(count(listOfQuestionFrameNumbers))

                   

                  -- set a local variable representing the next frame number to go to

                  theNextQuestionFrameNumber = listOfQuestionFrameNumbers[theItemNumber]

                   

                  -- remove that frame number from the list

                  listOfQuestionFrameNumbers.deleteAt(theItemNumber)

                   

                  -- use movie method to go to randomly selected frame

                  _movie.go(theNextQuestionFrameNumber)

                   

                  ------------------------------------------------------------------------------------

                   

                   

                  ------------------------------------------------------------------------------------

                  -- in the correct frame 110

                   

                  --  with next question  button

                   

                  -- declare the global variable set at start

                  global listOfQuestionFrameNumbers

                   

                  -- set a condition to allow only 5 questions

                  if count(listOfQuestionFrameNumbers) > 5 then

                   

                  -- select an item randomly from list

                  theItemNumber = random(count(listOfQuestionFrameNumbers))

                   

                  -- get a frame number from list using the randomly selected item number

                  theNextQuestionFrameNumber = listOfQuestionFrameNumbers[theItemNumber]

                   

                  -- remove that frame number from the list

                  listOfQuestionFrameNumbers.deleteAt(theItemNumber)

                   

                  -- go to randomly selected frame

                  _movie.go(theNextQuestionFrameNumber)

                   

                  end if

                   

                  ------------------------------------------------------------------------------------