home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / editors / hypsh40b.arj / HYPDEVEL.LZH / EXAM.HSL < prev    next >
Text File  |  1991-04-24  |  7KB  |  289 lines

  1. .REMARK
  2. include(hsl.def)
  3. .HEADER
  4. --- Question $Q -------------------------- $x -------
  5. .SCRIPT RESET
  6. setvar(T,0)
  7. setvar(C,0)
  8. setvar(W,0)
  9. setvar(O,0)
  10. setvar(Q,0)
  11. closein()
  12. .REMARK test
  13. test parentheses
  14. .NOTE Name
  15.  
  16.  Enter your name here
  17.  
  18.  Name: inputfield($a~W20,setvar(a,%s))~Q
  19.  
  20. .
  21. .SCRIPT SETUP
  22. setopt(2,0)
  23. setopt(*3,1)
  24. mapkey(F0,frame(Summary))
  25. note(Name)
  26. .SCRIPT Timing
  27. reseterr(timehun())
  28. setvar(R,getkey())
  29. setvar(T,timediff());setvar(O,=O+T)
  30. testvar(R,_parameter);goto(_notequal,WRONG)
  31. setvar(M,CORRECT - Well done~g)
  32. setvar(C,=C+1)
  33. goto(NEXT)
  34. label(WRONG)
  35. beep();setvar(W=W+1)
  36. setvar(M,Wrong)
  37. label(PMESS)
  38. setvar(M,$M - the answer was number _parameter~g)
  39. label(NEXT)
  40. toggle(1)
  41. .
  42. .SCRIPT OPEN
  43.    setvar(x,popdir(*.XAM,noext));ifcond(_noresult,quitscript())
  44.    setvar(b,_time)
  45.    reseterr();openin($x.XAM);goto(_error,FILERR)
  46. label(READ)
  47.    reseterr()
  48.    setvar(r,readrec())
  49.    goto(_error,FILERR)
  50.    setvar(p,upto(:,$r))
  51.    testvar(p,q);goto(_equal,QUESTION)
  52.    testvar(p,Q);goto(_equal,QUESTION)
  53.    goto(READ)
  54. label(FILERR)
  55. popmessage(Error reading file)
  56. quitscript()
  57. label(QUESTION)
  58. script(Next)
  59. .
  60. .SCRIPT Next
  61. -- set variables up
  62. setvar(j,);loadvar(j,1);loadvar(j,2);loadvar(j,3);loadvar(j,4);
  63. loadvar(j,5);loadvar(j,6)
  64. setvar(k,);setvar(l,);setvar(m,);setvar(n,0);setvar(c,0);setvar(q,1)
  65. testvar(r);goto(_equal,END)
  66. setvar(Q=Q+1)
  67. setvar(s,fromchar(:,$r))
  68. setvar(j,frompos(2,$s))
  69. label(GETLINE)
  70. setopt(*T)
  71. reseterr();setvar(h,readrec())
  72. goto(_error,EOX)
  73. setvar(i&N1$h)
  74. testvar(i,~);ifcond(_equal,O*T1)
  75. testvar(i,*);ifcond(_equal,O*T2)
  76. testvar(i,');goto(_equal,GETLINE)
  77. testvar(i);goto(_equal,GETLINE)
  78. goto(T,QUESTIONS)
  79. testvar(q,1);goto(_notequal,AFTER)
  80. setvar(n=n+1)
  81. goto($n)
  82. goto(GETLINE)
  83. label(1);setvar(k,$h);goto(GETLINE)
  84. label(2);setvar(l,$h);goto(GETLINE)
  85. label(3);setvar(m,$h);goto(GETLINE)
  86. label(QUESTIONS)
  87. setvar(s,flagval(T));testvar(s,2);ifcond(_equal,setvar(c=q))
  88. setvar(h,frompos(2,$h))
  89. lh$q;setvar(q=q+1)
  90. goto(GETLINE)
  91. label(AFTER)
  92. setvar(i,&U:$h)
  93. testvar(i,r);ifcond(_equal,setvar(g,frompos(3,$h)))
  94. testvar(i,R);ifcond(_equal,setvar(g,frompos(3,$h)))
  95. label(GETNEXT)
  96. setopt(*T;reseterr())
  97. setvar(h,readrec())
  98. goto(_error,EOX)
  99. setvar(i,upto(:,$h))
  100. testvar(i,q);ifcond(_equal,O*T4)
  101. testvar(i,Q);ifcond(_equal,O*T4)
  102. goto(T,NEXTF)
  103. goto(GETNEXT)
  104. label(NEXTF)
  105. setvar(r,$h)
  106. frame(Question)
  107. quitscript()
  108. label(EOX)
  109. setvar(r);setvar(h)
  110. frame(Question)
  111. quitscript()
  112. label(END)
  113. frame(Summary)
  114. .
  115. .SCRIPT Print
  116. setvar(x,@D*.XAM);ifcond(_noresult,quitscript())
  117. popmessage(Ready printer or <ESC> to cancel)
  118. setopt(5,1)
  119. setvar(b,$5)
  120. reseterr();openin($x.XAM);goto(_error,FILERR)
  121. output()
  122. output(Practice Test File:  $x)
  123. output()
  124. label(READ)
  125. reseterr()
  126. setvar(r,readrec())
  127. goto(_error,FILERR)
  128. setvar(p,upto(:,$r))
  129. testvar(p,q);goto(_equal,QUESTION)
  130. testvar(p,Q);goto(_equal,QUESTION)
  131. goto(READ)
  132. label(FILERR)
  133. display(Error reading file)
  134. quitscript()
  135. label(QUESTION)
  136. setvar(j);setvar(n,0);setvar(c,0);setvar(q,1);testvar(r);goto(_equal,END)
  137. setvar(Q=Q+1);setvar(s,fromchar(:,$r));setvar(j,frompos(2,$s))
  138. output(Question number $Q)
  139. output();output($j)
  140. label(GETLINE)
  141. setopt(*T)
  142. reseterr();setvar(h,readrec());goto(_error,EOX)
  143. setvar(i,&N1$h)
  144. testvar(i,~);ifcond(_equal,O*T1)
  145. testvar(i,*);ifcond(_equal,O*T2)
  146. testvar(i,');goto(_equal,GETLINE)
  147. testvar(i);goto(_equal,GETLINE)
  148. goto(T,QUESTIONS)
  149. testvar(q,1);goto(_notequal,AFTER)
  150. output($h)
  151. goto(GETLINE)
  152. label(QUESTIONS)
  153. setvar(cat(s,flagval(T)));testvar(s,2);ifcond(_equal,setvar(c=q))
  154. setvar(h,frompos(2,$h));testvar(q,1);ifcond(_equal,output())
  155. output(  ($q) $h)
  156. setvar(q=q+1)
  157. goto(GETLINE)
  158. label(AFTER)
  159. setvar(i,upto(:,$h))
  160. testvar(i,r);ifcond(_equal,setvar(g,frompos(3,$h)))
  161. testvar(i,R);ifcond(_equal,setvar(g,frompos(3,$h)))
  162. output()
  163. ifcond(R,output(  Reference [$g]));output()
  164. label(GETNEXT)
  165. setopt(*T);reseterr()
  166. setvar(h,readrec())
  167. goto(_error,EOX)
  168. setvar(i,upto(:,$h))
  169. testvar(i,q);ifcond(_equal,O*T4)
  170. testvar(i,Q);ifcond(_equal,O*T4)
  171. goto(T,NEXTF)
  172. goto(GETNEXT)
  173. label(NEXTF)
  174. setvar(r,$h)
  175. goto(QUESTION)
  176. label(EOX)
  177. label(END)
  178. output();closein();display(Print complete)
  179. setvar(T,0);setvar(C,0);setvar(W,0);setvar(O,0);setvar(Q,0)
  180. .
  181. .FRAME MENU
  182. .TITLE )Select Option
  183.  
  184.     ~DR  Examination - main menu ~DT
  185.  
  186.  
  187. [1]    frameref(Take exam,script(OPEN),1)
  188.  
  189. [2]    frameref(Print Questions (no refs),setopt(*R,);script(Print),2)
  190.  
  191. [3]    frameref(Print Questions (with refs),setopt(*R,1);script(Print),3)
  192.  
  193. [4]    frameref(Change name from ( $a ),note(Name);refresh(),4)
  194.  
  195. [q]    frameref(Quit,Quit(),q)
  196.  
  197. actionref(,script(RESET))~Q
  198. .
  199. .FRAME Question
  200. .TITLE Multiple choice selection
  201. ~DF
  202.      $j
  203.      $k
  204.      $l
  205.      $m
  206. ~DT
  207. [1]  $(1)
  208. [2]  $(2)
  209. [3]  $(3)
  210. [4]  $(4)
  211. [5]  $(5)
  212.  
  213. [6]   Do not know the answer
  214.  
  215. ~h1     $M
  216. ~h1     $g
  217. ~h1
  218. ~h1[n]       actionref(Press 'n' for next question,toggle(1,x);script(Next),n)
  219. ~h1[s]       actionref(--- or press 's' for summary ---,frame(Summary),s)
  220. actionref(,script(Timing($c)))~Q
  221. .
  222.  
  223. .FRAME Summary
  224. .TITLE )Timing report
  225.     ~DR     Test results for $a - Test $x     ~DT
  226.  
  227.     Number of questions    $Q
  228.  
  229.     Number correct        $C
  230.     Number wrong        $W
  231.  
  232.     $R
  233.  
  234.     Average response time    $A seconds
  235. actionref(,localscript(calc))~Q
  236.  
  237. [p]    actionref(Print summary sheet,localscript(Summary),p)
  238.  
  239. [m]    actionref(Press 'm' to return to main menu,frame(MENU),m)
  240. .
  241. .REMARK
  242. Calculate average response in seconds / hundredths
  243. .SCRIPT calc
  244. closein()
  245. setvar(A=O/Q)
  246. setvar(B=A/100)
  247. setvar(A=A-B*100)
  248. testvar(A,10);ifcond(_less,setvar(A,0$A))
  249. setvar(A,$B.$A)
  250. setvar(P=C*100/Q)
  251. testvar(P,25);goto(_less,BAD)
  252. testvar(P,50);goto(_less,AVERAGE)
  253. testvar(P,75);goto(_less,GOOD)
  254. setvar(G,Brilliant)
  255. goto(DISP)
  256. label(BAD)
  257. setvar(G,Pretty aweful)
  258. goto(DISP)
  259. label(AVERAGE)
  260. setvar(G,Average)
  261. goto(DISP)
  262. label(GOOD)
  263. setvar(G,Very good)
  264. label(DISP)
  265. setvar(R,You scored $P percent correct - That's $G)
  266. refresh()
  267. .
  268. .SCRIPT Summary
  269. popmessage(Ready printer or <ESC> to cancel)
  270. setopt(5,1)
  271. output("   Test File:      $x")
  272. output()
  273. output("   Name:           $a")
  274. output("   Date:           $4")
  275. output("   Test started:   $b")
  276. output()
  277. output("           --- Summary of results ---")
  278. output()
  279. output("   Number of questions    $Q")
  280. output("   Number correct         $C")
  281. output("   Number wrong           $W")
  282. output()
  283. output("   Percentage correct     $P")
  284. output()
  285. output("   Average response time  $A seconds")
  286. output()
  287. popmessage(Printout complete)
  288. .
  289.