home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / pc / tutorial / devglry / maricopa / source / quizzer.dir / 00002.ls < prev    next >
Encoding:
Text File  |  1996-04-18  |  4.5 KB  |  129 lines

  1. on startMovie
  2.   global gAnimDirection, gURL
  3.   set gAnimDirection to 1
  4.   puppetSprite(11, 1)
  5.   set gURL to "http://www.mcli.dist.maricopa.edu/alan/nojava/quiz/"
  6. end
  7.  
  8. on makeQuiz
  9.   global gTotQuiz, gQuizList, gQuizOrder, gScore, gMissed, gPassingScore
  10.   set gScore to 0
  11.   set gMissed to []
  12.   set gTotQuiz to numberOfQuestions()
  13.   set gPassingScore to setPassingScore()
  14.   set gQuizList to []
  15.   repeat with i = 1 to gTotQuiz
  16.     add(gQuizList, birth(script "quizMother", i))
  17.   end repeat
  18.   set gQuizOrder to birth(script "randmother", gTotQuiz)
  19. end
  20.  
  21. on newQuiz
  22.   global gTotQuiz, gQuizOrder, gFirstAnswer
  23.   updateItemCounter(gQuizOrder)
  24.   set gFirstAnswer to 1
  25.   set the locV of sprite 6 to 500
  26.   put the currentItem of gQuizOrder && "of" && gTotQuiz into field "counter"
  27.   if the currentItem of gQuizOrder > gTotQuiz then
  28.     goResults()
  29.   else
  30.     put getaProp(currQuestionInfo(), #ans1) into field "ans1"
  31.     put getaProp(currQuestionInfo(), #ans2) into field "ans2"
  32.     put getaProp(currQuestionInfo(), #ans3) into field "ans3"
  33.     put getaProp(currQuestionInfo(), #ans4) into field "ans4"
  34.     put getaProp(currQuestionInfo(), #question) into field "question"
  35.     put getaProp(currQuestionInfo(), #topic) into field "topic"
  36.     set the locH of sprite 10 to -500
  37.     shuffleAnswers()
  38.     updateStage()
  39.   end if
  40. end
  41.  
  42. on checkAnswer
  43.   global gTotQuiz, gQuizList, gQuizOrder, gFirstAnswer, gScore, gMissed
  44.   set clickedAnswer to char 4 of the name of cast the castNum of sprite the clickOn
  45.   do("put getaprop( currQuestionInfo(), #fb" & value(clickedAnswer) & ")       into field" && QUOTE & "feedback" & QUOTE)
  46.   set the locH of sprite 10 to 265
  47.   updateStage()
  48.   if gFirstAnswer then
  49.     if clickedAnswer = getaProp(currQuestionInfo(), #correct) then
  50.       set gScore to gScore + 1
  51.     else
  52.       if getOne(gMissed, getaProp(currQuestionInfo(), #topic)) = 0 then
  53.         add(gMissed, getaProp(currQuestionInfo(), #topic))
  54.       end if
  55.     end if
  56.     set gFirstAnswer to 0
  57.     set the locV of sprite 6 to 223
  58.     updateStage()
  59.   end if
  60. end
  61.  
  62. on goResults
  63.   global gScore, gMissed, gTotQuiz, gPassingScore
  64.   set cursor to 4
  65.   repeat with i = 2 to 6
  66.     puppetSprite(i, 0)
  67.   end repeat
  68.   puppetSprite(10, 0)
  69.   set userScore to integer(gScore * 100 / gTotQuiz)
  70.   put " " into field "results"
  71.   put "You scored" && gScore && "correct on the first try" && "out of a total of" && gTotQuiz && "questions, or" && userScore & "%." & RETURN & RETURN into field "results"
  72.   if userScore >= gPassingScore then
  73.     put "Since you exceeded " & gPassingScore & "%, you have passed the requirements" && "for this quiz." & RETURN & RETURN & "CONGRATULATIONS!" & RETURN & RETURN & "Are you ready to receive your certificate?" after field "results"
  74.   else
  75.     put "Since you scored less than " & gPassingScore & "%, you should review the information" && "for this unit. You may now redo the self check (click on the arrow button)" & RETURN & "----------------" & RETURN & "TOPICS to REVIEW" & RETURN & "(You may wish to write down the topics you missed)" & RETURN & RETURN after field "results"
  76.     repeat with i in gMissed
  77.       put "  *" && i & RETURN after field "results"
  78.     end repeat
  79.   end if
  80.   put EMPTY before line 1 of field "results"
  81.   set cursor to -1
  82.   go("results")
  83. end
  84.  
  85. on shuffleAnswers
  86.   set answerOrder to the randomList of birth(script "randmother", 4)
  87.   repeat with i = 1 to 4
  88.     set the locH of sprite (getAt(answerOrder, i) + 1) to 5
  89.     set the locV of sprite (getAt(answerOrder, i) + 1) to 70 + (30 * value(i))
  90.   end repeat
  91. end
  92.  
  93. on animQuestionMark spriteNum, firstCast, lastCast, hOffset
  94.   global gAnimDirection
  95.   if the castNum of sprite spriteNum = lastCast then
  96.     set gAnimDirection to -1
  97.   else
  98.     if the castNum of sprite spriteNum = firstCast then
  99.       set gAnimDirection to 1
  100.     end if
  101.   end if
  102.   set the castNum of sprite spriteNum to the castNum of sprite spriteNum + gAnimDirection
  103.   set the locH of sprite spriteNum to the locH of sprite spriteNum + hOffset
  104.   if the locH of sprite spriteNum > 500 then
  105.     set the locH of sprite spriteNum to -100
  106.   end if
  107.   set the locV of sprite spriteNum to 150 + integer(50 * sin(the locH of sprite spriteNum * PI / 112))
  108.   set the foreColor of sprite spriteNum to random(256)
  109.   updateStage()
  110. end
  111.  
  112. on currQuestionInfo
  113.   global gQuizList
  114.   return the quizParam of getAt(gQuizList, currQuestionNumber())
  115. end
  116.  
  117. on currQuestionNumber
  118.   global gQuizOrder
  119.   return getAt(the randomList of gQuizOrder, the currentItem of gQuizOrder)
  120. end
  121.  
  122. on numberOfQuestions
  123.   return value(item 1 of line 1 of field "qText")
  124. end
  125.  
  126. on setPassingScore
  127.   return value(item 2 of line 1 of field "qText")
  128. end
  129.