Ask a Question related to Macromedia Director Lingo, Design and Development.
-
mazzamazza webforumsuser@macromedia.com #1
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
-
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). ... -
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. -
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... -
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... -
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... -
Mark A. Boyd #2
Re: multiple choice quiz amendment
On 23 Oct 2003, "mazzamazza" [email]webforumsuser@macromedia.com[/email] wrote:
I just glanced at the code, but found something that /may/ be the> 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?
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
-
mazzamazza webforumsuser@macromedia.com #3
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
-
mazzamazza webforumsuser@macromedia.com #4
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
-
Mark A. Boyd #5
Re: multiple choice quiz amendment
On 24 Oct 2003, "mazzamazza" [email]webforumsuser@macromedia.com[/email] wrote:
You lost me with this one. Are you saying that you want field> 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?
("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
-
mazzamazza webforumsuser@macromedia.com #6
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
-
Mark A. Boyd #7
Re: multiple choice quiz amendment
On 28 Oct 2003, "mazzamazza" [email]webforumsuser@macromedia.com[/email] wrote:
Cool. I expect so if there was a situation where> yes, that seems to be the cure.
percentCorrect <> percentCorrect.integer
--
Mark A. Boyd
Keep-On-Learnin' :)
Mark A. Boyd Guest



Reply With Quote

