multiple choice quiz amendment

Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default multiple choice quiz amendment

    Hi I'm trying to add an additional script to the Lesson Builder template so that if the user gets over 75% in the quiz, they go to a certificate page. For some reason, my script doesn't give the correct result. At the moment, even if the user gets over 80%, the text i've written says that the user has failed. Any clues?


    on fillVariablesInText me

    -- Calculate scores
    oldFloatPrecision = the floatPrecision
    the floatPrecision = 2


    totalQuestions = 0
    totalCorrect = 0
    totalWrong = 0
    percentCorrect = 0
    percentWrong = 0
    totalPoints = 0
    pointsEarned = 0
    pointsMissed = 0
    percentPointsEarned = 0
    percentPointsMissed = 0
    passingScore = 75



    repeat with thisPage in gTrackingList
    if not(voidP(thisPage[#pageType])) then
    if thisPage.pageType = "interaction" then
    if not(voidP(thisPage[#knowledgeTrack])) then
    if thisPage.knowledgeTrack then
    totalQuestions = totalQuestions + 1
    if not(voidP(thisPage[#weighting])) then
    weighting = thisPage.weighting
    if weighting <= 0 or stringP(weighting) then
    weighting = 1
    end if
    else
    weighting = 1
    end if
    totalPoints = totalPoints + weighting
    if not(voidP(thisPage[#result])) then
    if thisPage.result = "C" then
    totalCorrect = totalCorrect + 1
    pointsEarned = pointsEarned + weighting
    else if thisPage.result = "W" then
    totalWrong = totalWrong + 1
    pointsMissed = pointsMissed + weighting
    end if
    end if
    end if
    end if
    end if
    end if
    end repeat

    if gTotalNumberOfTrackedQuestions <> -1 then
    totalQuestions = gTotalNumberOfTrackedQuestions
    end if

    if totalQuestions > 0 then
    percentCorrect = 100.0 * totalCorrect / totalQuestions
    if percentCorrect = percentCorrect.integer then
    percentCorrect = percentCorrect.integer
    if percentCorrect < passingScore then put "Unfortunately you haven't passed. Please select the 'MENU' button to return to the MAIN MENU where you can either watch the videos or retake the test." into field("TestResult")
    else put "Congratulations you have passed. Your certification code is **********. Please click on the next button and enter this number in the certification box." into field("TestResult")
    end if
    percentWrong = 100.0 * totalWrong / totalQuestions
    if percentWrong = percentWrong.integer then
    percentWrong = percentWrong.integer
    end if
    else
    percentCorrect = 0
    percentWrong = 0
    end if

    if gTotalPointsPossibleForTrackedQuestions <> -1 then
    totalPoints = gTotalPointsPossibleForTrackedQuestions
    end if

    if totalPoints > 0 then
    percentPointsEarned = 100.0 * pointsEarned / totalPoints
    if percentPointsEarned = percentPointsEarned.integer then
    percentPointsEarned = percentPointsEarned.integer
    end if
    percentPointsMissed = 100.0 * pointsMissed / totalPoints
    if percentPointsMissed = percentPointsMissed.integer then
    percentPointsMissed = percentPointsMissed.integer
    end if
    else
    percentPointsEarned = 0
    percentPointsMissed = 0
    end if

    repeat with i = 1 to pResultsVariables.count
    whichVariable = pResultsVariables.getPropAt(i)
    whichString = whichVariable.string
    do("pResultsVariables." & whichString & " = " & whichString)
    if whichVariable.symbolP then put "#" before whichString
    numOfChars = whichString.char.count
    stringOffset = offset(whichString, pMember.text)
    if stringOffset then
    replacementString = pResultsVariables[whichVariable].string
    if whichString contains "percent" then
    put "%" after replacementString
    end if
    put replacementString into pMember.char[stringOffset..(stringOffset + numOfChars - 1)]
    end if
    end repeat

    the floatPrecision = oldFloatPrecision

    end fillVariablesInText


    mazzamazza webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. Multiple choice checkboxes in PDF forms
      Hi, I tried searching on this and couldn't find anything! I want to be able to add a checkbox with 3 states, (blank, ticked and crossed). ...
    2. FLASH multiple choice quiz
      I know this is late in the day but answer to to use the right click copy and paste on your mouse.
    3. Multiple choice menu?
      Hi, what feature am I looking for when I need to get user input for selecting any combination of 12 values? The FMP6 solution will be a single...
    4. display results in a multple choice quiz, help ^_^
      hi all i currently have a multiple choice quiz that i intend to run over my companies intranet, the quiz reads from an XML file and randomises both...
    5. OT: grading multiple choice
      I have to grade 200 multiple choice exams, and rather than reinventing the wheel, I figured it'd be best to quickly ask: does anyone have a tool to...
  3. #2

    Default Re: multiple choice quiz amendment

    On 23 Oct 2003, "mazzamazza" [email]webforumsuser@macromedia.com[/email] wrote:
    > For some reason, my script doesn't give the correct result. At the
    > moment, even if the user gets over 80%, the text i've written says
    > that the user has failed. Any clues?
    I just glanced at the code, but found something that /may/ be the
    problem. When you include the commands to execute on the same line as the
    conditional statement, the 'end if' is automatically applied, thus an
    'else' will not likely function.

    This may not work as you expect:
    on someEvent
    if this then do that
    else do other
    end

    But this will:
    on someEvent
    if this then
    do that
    else
    do other
    end if
    end

    I've modified the snippet of the code where I happened to spot this
    (strings shortened to avoid word wrap in the newsreader). You may want to
    double check that I haven't altered the conditions you want here.

    if totalQuestions > 0 then
    percentCorrect = 100.0 * totalCorrect / totalQuestions
    if percentCorrect = percentCorrect.integer then
    percentCorrect = percentCorrect.integer
    if percentCorrect < passingScore then
    put "Unfortunately you haven't..." into field("TestResult")
    else
    put "Congratulations you have passed..." into field("TestResult")
    end if
    end if
    percentWrong = 100.0 * totalWrong / totalQuestions
    if percentWrong = percentWrong.integer then
    percentWrong = percentWrong.integer
    end if
    else
    percentCorrect = 0
    percentWrong = 0
    end if


    HTH


    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd Guest

  4. #3

    Default Re: multiple choice quiz amendment

    thanks Mark,
    i'll give that a go and let you know how i get on


    mazzamazza webforumsuser@macromedia.com Guest

  5. #4

    Default Re: multiple choice quiz amendment

    ok i've given that a whirl and it seemed to work for a bit, which is odd in itself then I thought I had to put in a clear field command otherwise when the user goes back in to try again, the old text will still be written.
    that's where i came up against another stumbling block cos yes, it cleared it, but nothing was being written there at all!
    Now i'm really confused. Where do I need to add the clear field command?


    if gTotalNumberOfTrackedQuestions <> -1 then
    totalQuestions = gTotalNumberOfTrackedQuestions
    end if
    if totalQuestions > 0 then
    percentCorrect = 100.0 * totalCorrect / totalQuestions
    if percentCorrect = percentCorrect.integer then
    percentCorrect = percentCorrect.integer
    if percentCorrect > passingScore then
    put "Congratulations you have passed..."into field("TestResult")
    else
    put "Unfortunately you haven't passed."into field("TestResult")
    end if
    end if
    percentWrong = 100.0 * totalWrong / totalQuestions
    if percentWrong = percentWrong.integer then
    percentWrong = percentWrong.integer
    end if
    else
    percentCorrect = 0
    percentWrong = 0
    end if


    mazzamazza webforumsuser@macromedia.com Guest

  6. #5

    Default Re: multiple choice quiz amendment

    On 24 Oct 2003, "mazzamazza" [email]webforumsuser@macromedia.com[/email] wrote:
    > ok i've given that a whirl and it seemed to work for a bit, which is
    > odd in itself then I thought I had to put in a clear field command
    > otherwise when the user goes back in to try again, the old text will
    > still be written. that's where i came up against another stumbling
    > block cos yes, it cleared it, but nothing was being written there at
    > all! Now i'm really confused. Where do I need to add the clear field
    > command?
    You lost me with this one. Are you saying that you want field
    ("TestResult") to have no text at some point? If so, then you can set
    the text to "" anytime you need to. A beginSprite or endSprite event in a
    behavior on the sprite might be a good place.

    on beginSprite me
    sprite(me.spriteNum).member.text = ""
    end

    "Nothing is being written there at all." Does this mean that the text of
    member "TestResult" never says "Congratulations..." or
    "Unfortunately..."? If so, then there's a very good chance that
    percentCorrect is never = percentCorrect.integer. Have you put a debug
    break point there?

    I'm kind of curious why you're doing that anyway. It eliminates any
    fractions that could result from the
    percentCorrect = 100.0 * totalCorrect / totalQuestions equation. I
    assumed there might be a reason you're accepting only whole numbers like
    that. The following illustrates a situation where percentCorrect is not
    equal to percentCorrect.integer, so it skips on down to the percentWrong
    portion of the code.

    totalCorrect = 13
    totalQuestions = 15
    put 100.0 * totalCorrect / totalQuestions
    -- 86.6667
    put percentCorrect = 100.0 * totalCorrect / totalQuestions
    -- 0

    If you don't really mean to skip such scenarios by accepting only whole
    numbers, then perhaps you can set the result of the equation to an
    integer right away. Likewise for percentWrong, though I don't see where
    you're using the result for percentWrong. For that matter, percentWrong
    could be simplified, too.

    if totalQuestions > 0 then
    percentCorrect = integer((100.0 * totalCorrect) / totalQuestions)
    if percentCorrect < passingScore then
    put "Unfortunately you haven't..." into field("TestResult")
    else
    put "Congratulations you have..." into field("TestResult")
    end if
    percentWrong = 100 - percentCorrect
    else
    percentCorrect = 0
    percentWrong = 0
    end if

    But... If you go this route, you need to decide if you want to round up
    as the above snippet does, or not as shown here given the above scenario:

    totalCorrect = 13
    totalQuestions = 15
    put integer((100.0 * totalCorrect) / totalQuestions)
    -- 87
    put (100 * totalCorrect) / totalQuestions
    -- 86

    Does that help?


    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd Guest

  7. #6

    Default Re: multiple choice quiz amendment

    yes, that seems to be the cure. i'll do some Beta testing and let you know for definite if that's what the bug was.

    many thanks
    Mazzzzza



    mazzamazza webforumsuser@macromedia.com Guest

  8. #7

    Default Re: multiple choice quiz amendment

    On 28 Oct 2003, "mazzamazza" [email]webforumsuser@macromedia.com[/email] wrote:
    > yes, that seems to be the cure.
    Cool. I expect so if there was a situation where
    percentCorrect <> percentCorrect.integer


    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139