2 Replies Latest reply on Feb 21, 2010 5:24 PM by aliandri

    how to make multiple choice with random question ?

    aliandri

      Hi everybody....

      i'm introduce that my name Ali and i have problem on lingo...

      i try to make question with multiple choice but i want to make random question any time who access that so any time can be different number question...

       

      i try make code with instruction random() but sometimes that question are same...

       

      i try this code :

       

      global rad

       

      on mouseUp me

        rad=random(11)

        case rad of

          1: _movie.go("1")

          2: _movie.go("2")

          3: _movie.go("3")  

          4: _movie.go("4")  

          5: _movie.go("5")

          6: _movie.go("6")

          7: _movie.go("7")  

          8: _movie.go("8")  

          9: _movie.go("9")

          10: _movie.go("10")

          11: _movie.go("11")  

        end case

       

      end

       

      any body help me?

      if not exception can send by email to aandrie77@yahoo.com

      thank you....

        • 1. Re: how to make multiple choice with random question ?
          James Newton, ACP Level 3

          If I understand correctly, you have 11 questions and you want to ask them once each in a random order.  To do this, you could create a randomized list, and use-and-remove one item at a time.  Here's a simple demo:

           

          1) Create a new movie

          2) Create a graphic member of some type and drag it onto the Stage

          3) Create a movie script

          4) Paste the scriptText below into the movie script

          5) Run your movie

          6) Open the Score window

          7) Click on the Stage several times and watch how the playback head jumps about in the Score window

           

           

           

          -- RANDOM FRAME--

          -- Movie script

           

          global gFrameList

           

           

          on exitFrame

            go the frame

          end

           

           

           

          on startMovie()

            -- Create an ordered list

            gFrameList = []

            vCount = 11

            repeat with ii = 1 to vCount

              gFrameList[ii] = ii -- use QUOTE&ii&QUOTE if you want marker names

            end repeat

           

            -- Shuffle the list

            ii = vCount

            repeat while ii -- repeat until ii becomes zero

              -- Choose a random item...

              vRandom = random(ii)

              vItem = gFrameList[vRandom]

              -- ... and move it to the end

              gFrameList.deleteAt(vRandom)

              gFrameList.append(vItem)

           

              ii = ii - 1

            end repeat

           

            put gFrameList -- look in the Message window

          end startMovie

           

           

           

          on mouseUp()

            if gFrameList.count then

              -- Use and lose the first item in the list

              vFrame = gFrameList[1]

              gFrameList.deleteAt(1)

              go vFrame

           

            else

              alert "gFrameList is now empty"

              halt

            end if

          end mouseUp

          • 2. Re: how to make multiple choice with random question ?
            aliandri Level 1

            Thank you sir,

            it's work but i change list about on mouseUp with another name procedure for call that procedure on another behavior script... so this list with my modification (on bold font) :

             

            -- RANDOM FRAME--

            -- Movie script

             

            global gFrameList

             

             

            on exitFrame

              go the frame

            end

             

             

             

            on startMovie()

              -- Create an ordered list

              gFrameList = []

              vCount = 11

              repeat with ii = 1 to vCount

                gFrameList[ii] = ii -- use QUOTE&ii&QUOTE if you want marker names

              end repeat

             

              -- Shuffle the list

              ii = vCount

              repeat while ii -- repeat until ii becomes zero

                -- Choose a random item...

                vRandom = random(ii)

                vItem = gFrameList[vRandom]

                -- ... and move it to the end

                gFrameList.deleteAt(vRandom)

                gFrameList.append(vItem)

             

                ii = ii - 1

              end repeat

             

              put gFrameList -- look in the Message window

            end startMovie

             

             

             

            on actionbutton() -- mouseUp ()

              if gFrameList.count then

                -- Use and lose the first item in the list

                vFrame = gFrameList[1]

                gFrameList.deleteAt(1)

                go vFrame

             

              else

                alert "gFrameList is now empty"

                halt

              end if

            end actionbutton --mouseUp