script

Define quiz_type = 'Black History'
Define questions                  ;used to get number of questions
Define count                      ;used in 'for' loops to count
Define ask                        ;displays the question
Define actual                     ;displays possible answer
Define choices                    ;
Define answer = '1'
Define check
Array choice
Define pick
Define look
Define number_of_choices = '3'	;max number of choices
Define right = 0
Define missed = 0
Define correct = 0
Define compare
Define theirs
Define dummy
Define path = 'd:\menus_80\'
Define quest = 'quest.txt'     ;file where the questions are kept
Define pos_ans = 'choices.txt' ;here are the possible answers
Define good = 'correct.txt'    ;here are the correct answers
Define results = 'results.txt' ;results of the test go here
Define taker = &01             ;taker of the test
Define send_it                  ;used to concatenate strings
Define good_ansr               ;an array holding the correct answers
Define users                   ;
Define taken = 'taken.txt'
Define previous_takers
Define temp



Clear screen
print 'The following is a quiz on [quiz_type], would you like to take it ? '
input dummy 1 noreturn
if dummy = 'n' then
 exit
endif
CLEAR SCREEN

previous_takers = table_load ('[path][taken]')

for count = 1 to previous_takers      ;check to see if it's already been
temp = table_get (count)              ;taken
 if [taker] = [temp] then
  BREAK
 endif
endfor 
if taker # temp then                  ;if their name wasn't found let them
  goto test                           ;take the test 
endif
printe 'You have already taken the test'  ;sorry, you can only take it once
exit


TEST:                                   ;let's begin

correct = table_load ('[path][good]')	;get the correct answers
array_clear (good_ansr)

for count = 1 to correct
right = table_get (count)
array_put (good_ansr, count, right) ; fill array with all the correct
                                    ; answers
endfor


questions = table_load ('[path][quest]')

for count = 1 to questions         ;ask x amount of questions
  ask = table_get (count)          ;find out exactly how many questions
  printe '[ask]'                   ;ask the question 
  printe
   choices = table_load ('[path][pos_ans]')  ; get the possible answers

NEXT_answer:
      actual = table_get (answer)  ;answer is intialized as 1 at top of file
      printe 'actual'              ;show the choice, had to do it this way
       increase answer             ;nested for loops not allowed.
       increase check
        if check = number_of_choices then ;have we reached the maximum number
         check = 0                        ;of choices, if yes then back to 0
         print 'your answer ? ==>'        ;user input
         input pick 1 noreturn
         array_put (choice, count, pick)      ;save their answer
         right = array_get (good_ansr, COUNT) ;get the correct answer
         printe
         print 'The correct answer is [right]' ;and show it to them 
         printe
         printe
         printe
        goto reload                            ;get another question
       endif
 goto next_answer                              ;back to the top of the loop
                                               ;for more possible answers
Reload:
  questions = table_load ('[path][quest]')  ;load questions again
endfor


printe 'Checking answers .... one moment'


for compare = 1 to questions
 theirs = array_get (choice, compare)       ;get their answers
 correct = array_get (good_ansr, compare)   ;get correct answers

  if theirs # correct then                  ;if it's not correct
   increase missed                          ;add to their misses
   ef theirs = correct then                 ;if it's correct
   increase right                           ;give them credit
  endif

endfor

printe ' you got [right] correct and [missed] wrong ' ;tellem how many
                                                      ;they got
open ('[path][taken]',append)
fprint taker                                          ;add them to the list
close                                                 ;of the tested  
exit
