10 Replies Latest reply on Jul 3, 2007 6:13 PM by McFazstp

    Interactive Missing word(s) Test

    wgb14 Level 1
      Hi all,

      I would like to create an interactive test where my user will be asked to fill in the missing word from a sentance. Something like: The name of the ancient cite of Sparta was _________. For each correct answer I want to give 5 points and for wrong answers 0 points. In addition, I have sentances with two missing words (e.g., The icon in the church is a ____ because the original one was ___) in which I would like to give 2,5 points for each correct answer. Finally the code should calcluate the total score and write it in a file. The steps to solve this I guess should be something like:

      1) Load each question in a field on the stage (done that)
      2) Allow the user to type the answer in a field on the stage + instruct him to use commas for double words (done that)
      3) Have a next button that loads the next question on the stage and:
      a) Write the question and answer in the text file using Buddy API (done that)
      b) Give a grade for each question ( 5 for single correct answers, 2,5 for each of the double words, and 0 for wrong)
      c) Calculate a total score and write it in the same file!

      As you understand from the above my problems are with steps b) and c). Any ideas will be much appreciated!

      Many thanks
        • 1. Interactive Missing word(s) Test
          wgb14 Level 1
          OK, I have managed to solve half of the problem, the b part (Give a grade for each question ( 5 for single correct answers, 2,5 for each of the double words, and 0 for wrong) as follows:

          on checkanswer

          answer = member("answer").text

          correct1 = ["one","two","three,four"] -- correct answers worth full 5 points
          correct2 = ["three"] -- correct answers worth half (2.5) points

          CASE TRUE OF

          (correct1.getPos(member("answer").text) <> 0):
          grade = 1

          (correct2.getPos(member("test").text) <> 0):
          grade = (0.5).float
          the floatPrecision = 1

          otherwise:

          grade = 0

          end case
          put grade & RETURN after field "test2" -- this is where I record the grades for each question so i can later add them. Any ideas how to do that? I mean how to add up integers and floating numbers stored in a field?
          • 2. Re: Interactive Missing word(s) Test
            wgb14 Level 1
            Anyone? I guess what i am asking should be trivial but i can not find a way to make it work!
            • 3. Interactive Missing word(s) Test
              wgb14 Level 1
              OK This is the format of my field member:

              5
              5
              2.5

              I tried this code below, but I got compeltely irrelevant results.

              tText = member("answer").text

              maxLines = tText.line.count
              repeat with i = 1 to maxLines
              total = integer(tText.line[1] + tText.line[maxLines])
              end repeat

              alert string(total)

              end

              • 4. Re: Interactive Missing word(s) Test
                McFazstp Level 1
                I'd probably go for some form of global list to keep track of the answers then add up the results from the list.

                global g_test_answers

                g_test_answers = [:]
                test_answer = [:]
                test_answer.addProp( #question_num, 1 )
                test_answer.addProp( #answers, ["Lacedaemon", "replica", "destroyed"] )
                test_answer.addProp( #score, 5 )
                g_test_answers.addProp( 1, test_answer )

                total_score = 0
                repeat with answer in g_test_answers
                total_score = total_score + answer[#score]
                end repeat

                • 5. Re: Interactive Missing word(s) Test
                  wgb14 Level 1
                  Hi

                  thanks for your reply, is it possible to help me a bit more with your script please? I am a bit confused on that properties that you have used in your list. Also, I am not sure from where do you read the contents of the answer field in which the user types in his answer.
                  • 6. Re: Interactive Missing word(s) Test
                    wgb14 Level 1
                    As I haven't used any property lists before, I find it extremely hard to figure out what is going on. Please either provide me with a more complete example or help me to understand your code. Many thanks for all your help so far!
                    • 7. Interactive Missing word(s) Test
                      wgb14 Level 1
                      As I am not sure how to make the script suggested by McFazstp to work can someone please suggest me a solution on what I Have implemented? Add the integers and floating numbers in a field member?
                      • 8. Re: Interactive Missing word(s) Test
                        Level 7
                        the plus-sign adds numbers.
                        a textmember or fieldmember contains string

                        you have to convert the lines in the field, which are the operands of
                        the sum, to a number (be it float or integer) and then add up. Not the
                        other way around like you have now.

                        Though it's hard to judge from here, I'd brush up on (property)lists and
                        go with something McFazstp suggest. In the end it's way more flexible
                        then most or any other solution(s).

                        Take a look at Dean Utian's tutorials
                        ( http://www.fbe.unsw.edu.au/Learning/Director/) or director-online.com's
                        article database for the better learning experience :)


                        wgb14 wrote:
                        > As I am not sure ho wto make the script suggested by McFazstp to work can someone please suggest me a solution on what I Have implemented? Add the integers and floating numbers in a field member?

                        --
                        ----------
                        Manno Bult
                        http://www.aloft.nl
                        • 9. Interactive Missing word(s) Test
                          wgb14 Level 1
                          Here is the answer for anyone that may need it:
                          • 10. Re: Interactive Missing word(s) Test
                            McFazstp Level 1
                            Hi wgb, my post was just a suggestion, sorry if the details were a bit confusing.

                            Basically I was creating a property list of property lists. The sub lists contain the answers to a particular question. For example if you wanted to check their answers for question 1.

                            put getAnswer( 1 )
                            -- ["Lacedaemon", "replica", "destroyed"]

                            put getAnswer( 2 )
                            -- <Void>

                            global g_test_answers

                            on getAnswer( answer_num )
                            answer = g_test_answers.getAProp( answer_num )
                            if NOT ( answer.ilk = #propList ) then
                            return VOID
                            end if
                            return answer[#answers]
                            end