home *** CD-ROM | disk | FTP | other *** search
/ Painter Bear's Language Bridge — Italian / Bridge_ponte_itialian.iso / pc / helpers / open.dxr / 00003_Q&A.ls < prev    next >
Encoding:
Text File  |  2001-02-22  |  16.6 KB  |  497 lines

  1. on goToQuiz whichBtn
  2.   global gBridgeParts, gAnswered, gCat, gWhichBridge, gCatTitle, gBridgeMonitor
  3.   cursor(4)
  4.   set gAnswered to 0
  5.   repeat while gWhichBridge = VOID
  6.     set whichBridge to random(10)
  7.     if (count(gBridgeLst) <> 10) and (count(gBridgeLst) <> 0) then
  8.       if getPos(gBridgeLst, whichBridge) = 0 then
  9.         set gWhichBridge to whichBridge
  10.       end if
  11.       next repeat
  12.     end if
  13.     set gWhichBridge to whichBridge
  14.   end repeat
  15.   set gCatTitle to word 1 of the name of member the memberNum of sprite whichBtn of castLib "chooser"
  16.   set gCat to word 1 of the name of member the memberNum of sprite whichBtn of castLib "chooser"
  17.   InitializeTracking(gCat)
  18.   clearSndList()
  19.   clearAnimalist()
  20.   go("quiz")
  21.   doMusicBtn()
  22.   set the memberNum of sprite gBridgeMonitor to the number of member ("bridge " & gBridgeParts)
  23.   putUpQuestion()
  24.   cursor(-1)
  25. end
  26.  
  27. on putUpQuestion
  28.   global gLangSelect, gWhichQuest, gLangName, gQuestion, gAnswer, gCat, gLangDirect, gAnsSndLst, gAnswered, gStampSpt, gQuestSndLst, gCatTitle
  29.   cursor(4)
  30.   set the visible of sprite 1 to 0
  31.   set the visible of sprite 1 to 1
  32.   updateStage()
  33.   set gAnswered to 0
  34.   set tempLst to []
  35.   set gAnsSndLst to []
  36.   set gQuestSndLst to []
  37.   if (gCatTitle = "allw") or (gCatTitle = "all") then
  38.     findgCat()
  39.   end if
  40.   chooseQuestionNum()
  41.   if gLangDirect = 1 then
  42.     set gQuestSndLst to askQuestionInEnglish(tempLst)
  43.     makeEnglishAnswerLst()
  44.   else
  45.     set gQuestSndLst to askForeignQuestion(tempLst)
  46.     makeForiegnAnswerLst()
  47.   end if
  48.   set text to gQuestion
  49.   set letterLst to []
  50.   setboxSize("questBox")
  51.   set letterLst to countAndCenterText(text, "whi", "center")
  52.   stampOutTxt(letterLst, gStampSpt, "1")
  53.   repeat with X = 1 to 4
  54.     set text to getAt(gAnswerLst, X)
  55.     set letterLst to []
  56.     setboxSize("ans" & X)
  57.     set letterLst to countAndCenterText(text, "whi", "center")
  58.     stampOutTxt(letterLst, gStampSpt, "1")
  59.   end repeat
  60.   set the itemDelimiter to ","
  61.   repeat with X = 1 to count(gAnsSndLst)
  62.     add(tempLst, getAt(gAnsSndLst, X))
  63.   end repeat
  64.   startSndList(gQuestSndLst)
  65.   cursor(-1)
  66. end
  67.  
  68. on askQuestionInEnglish sndLst
  69.   global gLangSelect, gWhichQuest, gLangName, gQuestion, gAnswer, gCat, gLangDirect, gQuestSndLst, gSndPath, gFileDelimiter, gAnsSndLst, gCatTitle
  70.   set the itemDelimiter to "*"
  71.   set aWord to item 2 of line gWhichQuest of field ("e " & gCat)
  72.   set gAnswer to item 3 of line gWhichQuest of field (gLangSelect && gCat) of castLib (gLangSelect & "Cst")
  73.   set gQuestion to "What is " & gLangName & " for " & line 1 of field "quote" & aWord & line 1 of field "quote" & "?"
  74.   set engPath to gSndPath & "e" & gFileDelimiter
  75.   add(sndLst, engPath & "eQuest" & gLangSelect & ".aif")
  76.   if (gCat = "tphr") and (gWhichQuest = 109) then
  77.     set aSent to "How do you say 'notebook' in " & gLangName & "?"
  78.     set gQuestion to "What is " & gLangName & " for " & line 1 of field "quote" & aSent & line 1 of field "quote" & "?"
  79.     add(sndLst, gSndPath & "e" & gFileDelimiter & gCat & gFileDelimiter & gLangSelect & gCat & gWhichQuest & ".aif")
  80.     add(gAnsSndLst, gSndPath & gLangSelect & gFileDelimiter & gCat & gFileDelimiter & gCat & gWhichQuest & ".aif")
  81.   else
  82.     if (gCat = "tphr") and (gWhichQuest = 7) then
  83.       set aSent to "My " & gLangName & " is not very good."
  84.       set gQuestion to "What is " & gLangName & " for " & line 1 of field "quote" & aSent & line 1 of field "quote" & "?"
  85.       add(sndLst, gSndPath & "e" & gFileDelimiter & gCat & gFileDelimiter & gLangSelect & gCat & gWhichQuest & ".aif")
  86.       add(gAnsSndLst, gSndPath & gLangSelect & gFileDelimiter & gCat & gFileDelimiter & gCat & gWhichQuest & ".aif")
  87.     else
  88.       add(sndLst, engPath & gCat & gFileDelimiter & gCat & gWhichQuest & ".aif")
  89.       add(gAnsSndLst, gSndPath & gLangSelect & gFileDelimiter & gCat & gFileDelimiter & gCat & gWhichQuest & ".aif")
  90.     end if
  91.   end if
  92.   return sndLst
  93. end
  94.  
  95. on makeEnglishAnswerLst
  96.   global gAnswerLst, gAnswer, gLangName, gLangSelect, gCat, gAnsSndLst, gSndPath, gFileDelimiter
  97.   set gAnswerLst to []
  98.   add(gAnswerLst, gAnswer)
  99.   set langPath to gSndPath & gLangSelect & gFileDelimiter
  100.   set the itemDelimiter to "*"
  101.   repeat while count(gAnswerLst) < 4
  102.     set whichField to gLangSelect && gCat
  103.     set whichLine to random(the number of lines in field whichField)
  104.     set aLine to line whichLine of field whichField
  105.     set aAnswer to item 3 of aLine
  106.     if aAnswer = EMPTY then
  107.       beep()
  108.     end if
  109.     set reasonNotTo to checkPossQwest(whichLine, 1, "A")
  110.     if (getPos(gAnswerLst, aAnswer) = 0) and (reasonNotTo = 0) then
  111.       add(gAnswerLst, aAnswer)
  112.       add(gAnsSndLst, langPath & gCat & gFileDelimiter & gCat & whichLine & ".aif")
  113.     end if
  114.   end repeat
  115.   set the itemDelimiter to ","
  116.   mixUpAnswerLst()
  117. end
  118.  
  119. on askForeignQuestion sndLst
  120.   global gLangSelect, gWhichQuest, gLangName, gQuestion, gAnswer, gCat, gLangDirect, gFileDelimiter, gSndPath, gAnsSndLst, gCatTitle
  121.   set the itemDelimiter to "*"
  122.   set aWord to item 3 of line gWhichQuest of field (gLangSelect && gCat) of castLib (gLangSelect & "Cst")
  123.   if gLangSelect = "f" then
  124.     set gQuestion to "Comment dit-on " & line 1 of field "quote" & aWord & line 1 of field "quote" & " en anglais?"
  125.   else
  126.     if gLangSelect = "s" then
  127.       set gQuestion to "¬øC√≥mo se dice " & line 1 of field "quote" & aWord & line 1 of field "quote" & " en ingl√©s?"
  128.     else
  129.       if gLangSelect = "I" then
  130.         set gQuestion to "Cos'√® l'inglese per " & line 1 of field "quote" & aWord & line 1 of field "quote" & "?"
  131.       else
  132.         if gLangSelect = "g" then
  133.           set gQuestion to "Was ist " & line 1 of field "quote" & aWord & line 1 of field "quote" & " auf englisch?"
  134.         end if
  135.       end if
  136.     end if
  137.   end if
  138.   set engPath to gSndPath & gLangSelect & gFileDelimiter
  139.   add(sndLst, engPath & gLangSelect & "quest.aif")
  140.   add(sndLst, engPath & gCat & gFileDelimiter & gCat & gWhichQuest & ".aif")
  141.   if (gLangSelect = "g") or (gLangSelect = "f") or (gLangSelect = "s") then
  142.     add(sndLst, engPath & gLangSelect & "quest2.aif")
  143.   end if
  144.   if (gCat = "tphr") and (gWhichQuest = 109) then
  145.     set gAnswer to "How do you say 'notebook' in " & gLangName & "?"
  146.     add(gAnsSndLst, gSndPath & "e" & gFileDelimiter & gCat & gFileDelimiter & gLangSelect & gCat & gWhichQuest & ".aif")
  147.   else
  148.     if (gCat = "tphr") and (gWhichQuest = 7) then
  149.       set gAnswer to "My " & gLangName & " is not very good."
  150.       add(gAnsSndLst, gSndPath & "e" & gFileDelimiter & gCat & gFileDelimiter & gLangSelect & gCat & gWhichQuest & ".aif")
  151.     else
  152.       set gAnswer to item 2 of line gWhichQuest of field ("e " & gCat)
  153.       add(gAnsSndLst, gSndPath & "e" & gFileDelimiter & gCat & gFileDelimiter & gCat & gWhichQuest & ".aif")
  154.     end if
  155.   end if
  156.   return sndLst
  157. end
  158.  
  159. on makeForiegnAnswerLst
  160.   global gAnswerLst, gAnswer, gLangName, gLangSelect, gSndPath, gCat, gFileDelimiter, gAnsSndLst
  161.   set gAnswerLst to []
  162.   add(gAnswerLst, gAnswer)
  163.   set langPath to gSndPath & "e" & gFileDelimiter
  164.   set the itemDelimiter to "*"
  165.   repeat while count(gAnswerLst) < 4
  166.     set whichField to "e" && gCat
  167.     set whichLine to random(the number of lines in field whichField)
  168.     set aLine to line whichLine of field whichField
  169.     set aAnswer to item 2 of aLine
  170.     set reasonNotTo to checkPossQwest(whichLine, 0, "A")
  171.     if (getPos(gAnswerLst, aAnswer) = 0) and (reasonNotTo = 0) then
  172.       add(gAnswerLst, aAnswer)
  173.       add(gAnsSndLst, langPath & gCat & gFileDelimiter & gCat & whichLine & ".aif")
  174.     end if
  175.   end repeat
  176.   set the itemDelimiter to ","
  177.   mixUpAnswerLst()
  178. end
  179.  
  180. on mixUpAnswerLst
  181.   global gAnswerLst, gAnswerSpt, gAnswer, gAnsSndLst, gSndPath
  182.   set tempLst to []
  183.   set tempSndLst to []
  184.   repeat while count(tempLst) < 4
  185.     set aAnswer to random(count(gAnswerLst))
  186.     add(tempLst, getAt(gAnswerLst, aAnswer))
  187.     add(tempSndLst, getAt(gAnsSndLst, aAnswer))
  188.     if getAt(gAnswerLst, aAnswer) = gAnswer then
  189.       set gAnswerSpt to count(tempLst)
  190.     end if
  191.     deleteAt(gAnswerLst, aAnswer)
  192.     deleteAt(gAnsSndLst, aAnswer)
  193.   end repeat
  194.   set gAnswerLst to tempLst
  195.   set gAnsSndLst to []
  196.   repeat with X = 1 to count(tempSndLst)
  197.     add(gAnsSndLst, getAt(tempSndLst, X))
  198.     add(gAnsSndLst, gSndPath & "noSnd.aif")
  199.   end repeat
  200. end
  201.  
  202. on enterAnswer whichBtn
  203.   global gAnswerRight, gAnswerSpt, gAnswered, gAnswerLinesBox, gfstLftArr, gLstRtArr, gClickNote, gBridgeMonitor, gBridgeParts, gRightTag, gStampSpt, gEyeSprite, gSwitchSpt, gLangDirect, gLangSelect
  204.   if gAnswered <> 1 then
  205.     set gAnswered to 1
  206.     set the memberNum of sprite gAnswerLinesBox to the number of member "answerarea gray"
  207.     repeat with X = gfstLftArr to gLstRtArr
  208.       if (X <> (gfstLftArr + 1)) and (X <> (gfstLftArr + 4)) and (X <> (gfstLftArr + 7)) and (X <> (gfstLftArr + 10)) then
  209.         set foo to the name of member the memberNum of sprite X of castLib "quiz"
  210.         put "gray" into word the number of words in foo of foo
  211.         set the memberNum of sprite X to the number of member foo
  212.       end if
  213.     end repeat
  214.     set the memberNum of sprite gEyeSprite to the number of member "eye gray"
  215.     set the memberNum of sprite gSwitchSpt to the number of member "switch gray"
  216.     if gLangDirect = 1 then
  217.       set the memberNum of sprite gClickNote to the number of member "e click up"
  218.     else
  219.       set the memberNum of sprite gClickNote to the number of member (gLangSelect & " click up")
  220.     end if
  221.     clearSndList()
  222.     set foo to the name of member the memberNum of sprite whichBtn of castLib "quiz"
  223.     set foo to value(word 1 of foo)
  224.     repeat with X = 1 to 4
  225.       set text to getAt(gAnswerLst, X)
  226.       set letterLst to []
  227.       setboxSize("ans" & X)
  228.       if X = gAnswerSpt then
  229.         set whichColor to "grn"
  230.       else
  231.         if (X = foo) and (foo <> gAnswerSpt) then
  232.           set whichColor to "red"
  233.         else
  234.           set whichColor to "whi"
  235.         end if
  236.       end if
  237.       set letterLst to countAndCenterText(text, whichColor, "center")
  238.       stampOutTxt(letterLst, gStampSpt, "1")
  239.     end repeat
  240.     if gAnswerSpt = foo then
  241.       set gAnswerRight to 1
  242.       set gBridgeParts to gBridgeParts + 1
  243.       set the memberNum of sprite gBridgeMonitor to the number of member ("bridge " & gBridgeParts)
  244.       if gLangDirect = 1 then
  245.         set the memberNum of sprite gRightTag to the number of member "e correct"
  246.       else
  247.         set the memberNum of sprite gRightTag to the number of member (gLangSelect & " correct")
  248.       end if
  249.       puppetSound(1, "yes")
  250.     else
  251.       if gLangDirect = 1 then
  252.         set the memberNum of sprite gRightTag to the number of member "e incorrect"
  253.       else
  254.         set the memberNum of sprite gRightTag to the number of member (gLangSelect & " incorrect")
  255.       end if
  256.       set gAnswerRight to 0
  257.       puppetSound(1, "no")
  258.     end if
  259.     TrackAnswer(gAnswerRight, getAt(gAnswerLst, gAnswerSpt), getAt(gAnswerLst, foo))
  260.     doFeedBack()
  261.   end if
  262. end
  263.  
  264. on resetQwest
  265.   global gAnswerLinesBox, gfstLftArr, gLstRtArr, gClickNote, gBridgeParts, gRightTag, gWhichBridge, gBridgeLst, gEyeSprite, gSwitchSpt
  266.   set gAnswered to 0
  267.   clearSndList()
  268.   clearAnimalist()
  269.   if gBridgeParts <> 10 then
  270.     set the memberNum of sprite gAnswerLinesBox to the number of member "answerarea"
  271.     repeat with X = gfstLftArr to gLstRtArr
  272.       if (X <> (gfstLftArr + 1)) and (X <> (gfstLftArr + 4)) and (X <> (gfstLftArr + 7)) and (X <> (gfstLftArr + 10)) then
  273.         set foo to the name of member the memberNum of sprite X of castLib "quiz"
  274.         put "up" into word the number of words in foo of foo
  275.         set the memberNum of sprite X to the number of member foo
  276.       end if
  277.     end repeat
  278.     set the memberNum of sprite gEyeSprite to the number of member "eye up"
  279.     set the memberNum of sprite gSwitchSpt to the number of member "switch up"
  280.     set the memberNum of sprite gClickNote to the number of member "click gray"
  281.     set the memberNum of sprite gRightTag to the number of member "e 2 correct"
  282.     putUpQuestion()
  283.   else
  284.     cursor(4)
  285.     if getPos(gBridgeLst, gWhichBridge) = 0 then
  286.       add(gBridgeLst, gWhichBridge)
  287.     end if
  288.     viewBridge()
  289.     cursor(-1)
  290.   end if
  291. end
  292.  
  293. on setLangSelect whichBtn
  294.   global gLangSelect, gLangName, gLangDirect
  295.   set foo to the name of member the memberNum of sprite whichBtn of castLib "chooser"
  296.   set gLangSelect to word 1 of foo
  297.   case gLangSelect of
  298.     "g":
  299.       set gLangName to "German"
  300.     "i":
  301.       set gLangName to "Italian"
  302.     "s":
  303.       set gLangName to "Spanish"
  304.     "f":
  305.       set gLangName to "French"
  306.     "L":
  307.       set gLangName to "Latin"
  308.     "P":
  309.       set gLangName to "Portuguese"
  310.   end case
  311.   if gLangDirect = 1 then
  312.     put "English to " & gLangName into field "direction"
  313.   else
  314.     put gLangName & " to English" into field "direction"
  315.   end if
  316. end
  317.  
  318. on switchLangDir
  319.   global gLangDirect, gLangName
  320.   cursor(4)
  321.   if the frameLabel = "find" then
  322.     put EMPTY into field "possWords"
  323.     put EMPTY into field "wordFound"
  324.     put EMPTY into field "wordFind"
  325.   end if
  326.   if gLangDirect = 1 then
  327.     set gLangDirect to 0
  328.     put gLangName & " to English" into field "direction"
  329.   else
  330.     set gLangDirect to 1
  331.     put "English to " & gLangName into field "direction"
  332.   end if
  333.   if the frameLabel = "quiz" then
  334.     putUpQuestion()
  335.   else
  336.     if the frameLabel = "find" then
  337.       prepWdFind()
  338.     else
  339.       if the frameLabel = "chooser" then
  340.         prepChooser()
  341.       end if
  342.     end if
  343.   end if
  344.   cursor(4)
  345.   updateStage()
  346.   cursor(-1)
  347. end
  348.  
  349. on chooseQuestionNum
  350.   global gWhichQuest, gPastQwestLst, gCat
  351.   set gWhichQuest to VOID
  352.   repeat while gWhichQuest = VOID
  353.     set whichQwest to random(the number of lines in field ("e " & gCat))
  354.     set reasonNotTo to checkPossQwest(whichQwest, 1, "Q")
  355.     if (getPos(gPastQwestLst, whichQwest) = 0) and (reasonNotTo = 0) then
  356.       add(gPastQwestLst, whichQwest)
  357.       set gWhichQuest to whichQwest
  358.     end if
  359.   end repeat
  360.   if count(gPastQwestLst) >= 8 then
  361.     deleteAt(gPastQwestLst, 1)
  362.   end if
  363. end
  364.  
  365. on checkPossQwest whichQwest, whichDirect, QorA
  366.   global gLangDirect, gLangSelect, gCat, gWhichQuest
  367.   set foo to 0
  368.   if gLangDirect = whichDirect then
  369.     if gCat = "mphr" then
  370.       case gLangSelect of
  371.         "g":
  372.           if (whichQwest = 34) or (whichQwest = 48) then
  373.             set foo to 1
  374.           end if
  375.         "f":
  376.           if (whichQwest = 33) or (whichQwest = 48) or (whichQwest = 98) then
  377.             set foo to 1
  378.           end if
  379.         "s":
  380.           if whichQwest = 48 then
  381.             set foo to 1
  382.           end if
  383.       end case
  384.     else
  385.       if gCat = "tphr" then
  386.         case gLangSelect of
  387.           "g":
  388.             if (whichQwest = 65) or (whichQwest = 92) or (whichQwest = 124) then
  389.               set foo to 1
  390.             end if
  391.           "i":
  392.             if (whichQwest = 83) or (whichQwest = 92) then
  393.               set foo to 1
  394.             end if
  395.           "f":
  396.             if (whichQwest = 27) or (whichQwest = 64) or (whichQwest = 65) or (whichQwest = 66) or (whichQwest = 92) or (whichQwest = 108) then
  397.               set foo to 1
  398.             end if
  399.         end case
  400.       else
  401.         if gCat = "geog" then
  402.           if QorA = "a" then
  403.             if (gWhichQuest = 8) or (gWhichQuest = 9) or (gWhichQuest = 10) then
  404.               if (whichQwest = 8) or (whichQwest = 9) or (whichQwest = 10) then
  405.                 set foo to 1
  406.               end if
  407.             end if
  408.           end if
  409.         else
  410.           if gCat = "bath" then
  411.             if QorA = "a" then
  412.               if (gWhichQuest = 5) or (gWhichQuest = 6) then
  413.                 if (whichQwest = 5) or (whichQwest = 6) then
  414.                   set foo to 1
  415.                 end if
  416.               end if
  417.             end if
  418.           end if
  419.         end if
  420.       end if
  421.     end if
  422.   end if
  423.   return foo
  424. end
  425.  
  426. on findgCat
  427.   global gCatTitle, gCat
  428.   if gCatTitle = "allw" then
  429.     set fooNum to random(27)
  430.   else
  431.     if gCatTitle = "all" then
  432.       set fooNum to random(31)
  433.     end if
  434.   end if
  435.   case fooNum of
  436.     "1":
  437.       set gCat to "rltv"
  438.     "2":
  439.       set gCat to "advb"
  440.     "3":
  441.       set gCat to "adjv"
  442.     "4":
  443.       set gCat to "verb"
  444.     "5":
  445.       set gCat to "schl"
  446.     "6":
  447.       set gCat to "tran"
  448.     "7":
  449.       set gCat to "colr"
  450.     "8":
  451.       set gCat to "dirc"
  452.     "9":
  453.       set gCat to "spor"
  454.     "10":
  455.       set gCat to "occp"
  456.     "11":
  457.       set gCat to "anml"
  458.     "12":
  459.       set gCat to "food"
  460.     "13":
  461.       set gCat to "trvl"
  462.     "14":
  463.       set gCat to "body"
  464.     "15":
  465.       set gCat to "buil"
  466.     "16":
  467.       set gCat to "city"
  468.     "17":
  469.       set gCat to "hous"
  470.     "18":
  471.       set gCat to "furn"
  472.     "19":
  473.       set gCat to "weat"
  474.     "20":
  475.       set gCat to "conj"
  476.     "21":
  477.       set gCat to "numb"
  478.     "22":
  479.       set gCat to "bath"
  480.     "23":
  481.       set gCat to "kitc"
  482.     "24":
  483.       set gCat to "time"
  484.     "25":
  485.       set gCat to "geog"
  486.     "26":
  487.       set gCat to "clth"
  488.     "27":
  489.       set gCat to "stor"
  490.     "28", "30":
  491.       set gCat to "tphr"
  492.     "29", "31":
  493.       set gCat to "mphr"
  494.   end case
  495.   return(foo)
  496. end
  497.