14 Replies Latest reply on Mar 16, 2009 11:32 PM by Newsgroup_User

    Quiz answer sheet

    instructorTek
      Hi good day I'm creating a multiple choice quiz answer sheet it is numbered 1 to 60 and letters A to D for each answer. Can you give me a simple way in which I could display a shading over a letter when the user clicks it to indicate an answer. The user can only make one selection per question. Any help will be appreciated, thanks. eg layout:
      1 A B C D
      2 A B C D
      3 A B C D
      etc
        • 1. Re: Quiz answer sheet
          James Newton, ACP Level 3
          Please see the answers to this cross-post on the Director Online forum.
          • 2. Re: Quiz answer sheet
            Level 7
            Attach this behavior to text sprite (watch for unintended line breaks
            induced by your newsreader or web page)

            ---------------------------------------------------------------
            property spriteNum, pNumQuestions, pNumChoices, pTabStops,
            pDefaultColor, pHighlightColor, pAnswerList

            on beginSprite me

            sprite(spriteNum).member.color = value(pDefaultColor)

            tabList = []
            repeat with k = 1 to pNumChoices
            tabList.add([#type: #left, #position: k * pTabStops])
            end repeat
            sprite(spriteNum).member.tabs = tabList

            myText = ""
            repeat with k = 1 to pNumQuestions
            currentLine = string(k)
            repeat with n = 1 to pNumChoices
            currentLine = currentLine & TAB & numToChar(n + 64)
            end repeat
            put currentLine into line k of myText
            end repeat
            sprite(spriteNum).member.text = myText

            pAnswerList = []
            repeat with k = 1 to pNumQuestions
            pAnswerList[k] = ""
            end repeat

            end

            on mouseDown me
            wordNum = sprite(spriteNum).pointToWord(the clickLoc)
            lineNum = sprite(spriteNum).pointToLine(the clickLoc)
            if wordNum mod (pNumChoices + 1) <> 1 then
            sprite(spriteNum).member.line[lineNum].color = value(pDefaultColor)
            sprite(spriteNum).member.word[wordNum].color = value(pHighlightColor)
            pAnswerList[lineNum] = sprite(spriteNum).member.word[wordNum]
            end if
            end


            on getPropertyDescriptionList
            description = [:]
            addProp description,#pNumQuestions, [#default:60, #format:#integer,
            #comment:"Number of Quiz Questions"]
            addProp description,#pNumChoices, [#default:4, #format:#integer,
            #comment:"Number of Question choices"]
            addProp description,#pTabStops, [#default:40, #format:#integer,
            #comment:"Tab stop width in pixels"]
            addProp description,#pDefaultColor, [#default:"rgb(0,0,0)",
            #format:#string, #comment:"Default color rgb(x,x,x)"]
            addProp description,#pHighlightColor, [#default:"rgb(255,0,0)",
            #format:#string, #comment:"Hightlight color rgb(x,x,x)"]
            return description
            end
            ---------------------------------------------------------------
            • 3. Re: Quiz answer sheet
              Level 7
              Use this instead. The previous behavior did some unnecessary repeat loops.

              -----------------------------------------------------------------
              property spriteNum, pNumQuestions, pNumChoices, pTabStops,
              pDefaultColor, pHighlightColor, pAnswerList

              on beginSprite me

              sprite(spriteNum).member.color = value(pDefaultColor)

              tabList = []
              repeat with k = 1 to pNumChoices
              tabList.add([#type: #left, #position: k * pTabStops])
              end repeat

              sprite(spriteNum).member.tabs = tabList

              addText = ""
              repeat with n = 1 to pNumChoices
              addText = addText & TAB & numToChar(n + 64)
              end repeat

              myText = ""
              repeat with k = 1 to pNumQuestions
              put string(k) & addText into line k of myText
              end repeat

              sprite(spriteNum).member.text = myText

              pAnswerList = []
              repeat with k = 1 to pNumQuestions
              pAnswerList[k] = ""
              end repeat

              end

              on mouseDown me
              wordNum = sprite(spriteNum).pointToWord(the clickLoc)
              lineNum = sprite(spriteNum).pointToLine(the clickLoc)
              if wordNum mod (pNumChoices + 1) <> 1 then
              sprite(spriteNum).member.line[lineNum].color = value(pDefaultColor)
              sprite(spriteNum).member.word[wordNum].color = value(pHighlightColor)
              pAnswerList[lineNum] = sprite(spriteNum).member.word[wordNum]
              end if
              end


              on getPropertyDescriptionList
              description = [:]
              addProp description,#pNumQuestions, [#default:60, #format:#integer,
              #comment:"Number of Quiz Questions"]
              addProp description,#pNumChoices, [#default:4, #format:#integer,
              #comment:"Number of Question choices"]
              addProp description,#pTabStops, [#default:40, #format:#integer,
              #comment:"Tab stop width in pixels"]
              addProp description,#pDefaultColor, [#default:"rgb(0,0,0)",
              #format:#string, #comment:"Default color rgb(x,x,x)"]
              addProp description,#pHighlightColor, [#default:"rgb(255,0,0)",
              #format:#string, #comment:"Hightlight color rgb(x,x,x)"]
              return description
              end
              ------------------------------------------------------------
              • 4. Re: Quiz answer sheet
                Level 7
                Here is a one sprite, imaging lingo solution with many adjustable
                parameters.

                [bellsouthpwp2.net]
                • 5. Re: Quiz answer sheet
                  Level 7
                  http://bellsouthpwp2.net/d/g/dgcraddock/bubbleTest.zip


                  Dave C wrote:
                  > Here is a one sprite, imaging lingo solution with many adjustable
                  > parameters.
                  >
                  > [bellsouthpwp2.net]
                  • 6. Re: Quiz answer sheet
                    Level 7
                    Here is an improved version of my bubble test behavior. It has the same
                    set of parameters, but the imaging lingo was optimized to improve the
                    execution speed. Previously, the entire image was being recreated every
                    time a bubble was selected. The code now has intelligence to figure out
                    just which area within the image needs changing.

                    http://bellsouthpwp2.net/d/g/dgcraddock/ImprovedBubbleTest.zip
                    • 7. Re: Quiz answer sheet
                      Level 7
                      For anyone else interested, here is an updated version of my Bubble Test
                      behavior. It includes handlers (i.e. public functions) that can be used
                      to extract results of the test, such as questions missed, percent
                      correct, etc.

                      http://bellsouthpwp2.net/d/g/dgcraddock/BubbleTestWithResults.zip


                      Dave C wrote:
                      > Here is an improved version of my bubble test behavior. It has the same
                      > set of parameters, but the imaging lingo was optimized to improve the
                      > execution speed. Previously, the entire image was being recreated every
                      > time a bubble was selected. The code now has intelligence to figure out
                      > just which area within the image needs changing.
                      >
                      > http://bellsouthpwp2.net/d/g/dgcraddock/ImprovedBubbleTest.zip
                      • 8. Re: Quiz answer sheet
                        Production Monkey
                        Dave,

                        I took a quick look at this and it reminds me of why I love imaging Lingo. With a relatively small amount of code you were able to create a kool little component. Nice.

                        One of my frustrations with D11 was the complete lack of new imaging lingo. Imaging lingo - in the distant past - was one of the really powerful capabilities of Director that used to set it apart. Now?.... It has not been enhanced since its incarnation back around 2000 and D8, I believe.

                        It's sad. If you want to add a bevel to an image object you have to use Flash and AS2. Shameful Adobe!

                        If you are still working on your open source component, I have a few thoughts.

                        The circles look ugly. I would use a vector shape to draw any circle images. It will be antialiased, and well, look sweet.

                        I noticed that you are using Strings for the color properties in your getPropertyDescriptionList() handler. If you use #Color, then in the property inspector you can use a color picker which is much nicer.

                        I also feel it is better to add a Range to any Integer inputs; Two reasons: The user can not input garbage, and you can restrict them to a range of values that make sense.

                        Just some tweaky thoughts.

                        Randal.
                        • 9. Re: Quiz answer sheet
                          Level 7
                          Production Monkey wrote:

                          > It's sad. If you want to add a bevel to an image object you have to use Flash
                          > and AS2. Shameful Adobe!

                          As an aside here, you know that with D11, you can do all the same bitmap
                          filters that Flash has (Bevel, Glow, Drop Shadow, Blur, etc). They can
                          be done through the Director IDE or Lingo.

                          In fact, even earlier than that, the latest release of D10 (10.1.1)
                          could do all these things through the Flash Asset Xtra with the
                          convert() method. All in Lingo.
                          • 10. Re: Quiz answer sheet
                            Production Monkey Level 3
                            When I said, "If you want to add a bevel to an image object you have to use Flash and AS2." I meant use convert() and the Flash Asset Xtra. That is not using Lingo. That is using Flash to do a job Lingo should be able to do in 2009 all by itself.

                            Correct me if I am wrong, but during my few painful hours about a year ago trying out D11, I could find no way of applying an image filter to an image object. In pseudo code, something like:

                            NewImage = image(500,500,32)
                            BevelFilter = new(#BevelFilter)
                            NewImage.applyFilter(BevelFilter)

                            If you can do something like that in D11 without some hack or using an xtra then I would like to be informed.
                            • 11. Re: Quiz answer sheet
                              Level 7
                              Hey thanks Randal. I was just about to post an update to the behavior
                              because of the ugly circles. The update allows you to choose between
                              using the ugly circles, or specifying a bitmap cast member which can be
                              a nice polished looking graphic. It required very minimal changes to the
                              imaging lingo. Imaging lingo is awesome.

                              Good idea on the vectors and the integer ranges. I think I will put that
                              in before post the update.

                              It seems the #color format is not supported in my poor, broke down old
                              version of 8.5. Maybe Adobe will give me a free upgrade in exchange for
                              the free support I am giving ;-)

                              Thanks for the input.


                              Production Monkey wrote:
                              > Dave,
                              >
                              > I took a quick look at this and it reminds me of why I love imaging Lingo.
                              > With a relatively small amount of code you were able to create a kool little
                              > component. Nice.
                              >
                              > One of my frustrations with D11 was the complete lack of new imaging lingo.
                              > Imaging lingo - in the distant past - was one of the really powerful
                              > capabilities of Director that used to set it apart. Now?.... It has not been
                              > enhanced since its incarnation back around 2000 and D8, I believe.
                              >
                              > It's sad. If you want to add a bevel to an image object you have to use Flash
                              > and AS2. Shameful Adobe!
                              >
                              > If you are still working on your open source component, I have a few thoughts.
                              >
                              > The circles look ugly. I would use a vector shape to draw any circle images.
                              > It will be antialiased, and well, look sweet.
                              >
                              > I noticed that you are using Strings for the color properties in your
                              > getPropertyDescriptionList() handler. If you use #Color, then in the property
                              > inspector you can use a color picker which is much nicer.
                              >
                              > I also feel it is better to add a Range to any Integer inputs; Two reasons:
                              > The user can not input garbage, and you can restrict them to a range of values
                              > that make sense.
                              >
                              > Just some tweaky thoughts.
                              >
                              > Randal.
                              >
                              • 12. Re: Quiz answer sheet
                                Level 7
                                Well the bevelFilter is for sprites. not image objects, but I suppose
                                you could place a #bitmap member sprite offstage and do the bevel then
                                get it's image. Not as straightforward as you may like, but I think it
                                should work

                                Though I do not know what the issue is with using the Flash xtra. It is
                                built into Director, and using it's functions are as much Lingo as any
                                other built in xtra... like the bitmap asset or any other.
                                • 13. Re: Quiz answer sheet
                                  Production Monkey Level 3
                                  My primary complaint is that something as simple and basic as applying filters to image objects is still not native to Lingo.

                                  For that matter, something as trivial to program as being able to save an image object out as a jpg or png is not native.

                                  And..... the list goes on, and on, so screw it.

                                  My issue with using Flash/AS2 is simply speed.

                                  You have to use the "convert()" function twice, which means two unnecessary copy operations of the image data in memory. That would not be necessary if filters were native to Lingo. Copying all that data is a huge performance loss.
                                  • 14. Re: Quiz answer sheet
                                    Level 7
                                    Here is final (maybe) version of the behavior. It allows for nicer
                                    looking bubbles (either vector shape or bitmap cast members) or the
                                    plain old ugly drawn bubbles. Hope you find it useful.

                                    http://bellsouthpwp2.net/d/g/dgcraddock/OneSpriteBubbleTest.zip


                                    instructorTek wrote:
                                    > Hi good day I'm creating a multiple choice quiz answer sheet it is numbered 1
                                    > to 60 and letters A to D for each answer. Can you give me a simple way in which
                                    > I could display a shading over a letter when the user clicks it to indicate an
                                    > answer. The user can only make one selection per question. Any help will be
                                    > appreciated, thanks. eg layout:
                                    > 1 A B C D
                                    > 2 A B C D
                                    > 3 A B C D
                                    > etc
                                    >
                                    >