%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                      OPTION: 'Test' from main menu                   %
%                                                                      %
%               PURPOSE: This is a self-test after the tutorial        %
%                        has been finished.                            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

var row, row2, yi, yii, yiii, yiv, count, count2 : int
var xi, xii, xiii, xiv : int
% array variable containing test questions
var questions : array 1 .. 20 of string := init
    ("1. Who derived the word atom?", "2. Who reintroduced the Greek model?",
    "3. 'Chemical change is the _____ of atoms.'",
    "4. Who discovered the electron?",
    "5. Dalton's model is known as the ________ ____ model.",
    "6. J. J. Thomson worked with what kind of equipment?",
    "7. Dalton's model PREDICTS the Law of ________ ___________.",
    "8. What is the present model called?",
    "9. Planck's equation is 'E = h times what?'",
    "10. Who worked with the hydrogen atom?",
    "11. A positive area of high mass is called the _______."
    "12. Who developed wave mechanics?",
    "13. A region of space where an electron is likely to be found.",
    "14. Rutherford used this type of particle in his experiment.",
    "15. In Rutherford's experiment how many alpha particles bounced back?",
    "16. Thomson's model is known as the ____ _______ model.",
    "17. What are tiny pockets of energy called?",
    "18. If principal quantum number = 3, there are ___ orbitals.",
    "19. Electrons are far from nucleus = ____ potential energy."
    "20. A colour of light corresponds to a certain ____ and ____.")
% array variable containing test answers
var answers : array 1 .. 20 of string := init
    ("a. Bohr  b. Dalton  c. Greeks",
    "a. Thomson  b. Dalton  c. Rutherford",
    "a. separation  b. destruction  c. union",
    "a. Thomson  b. Dalton  c. Planck",
    "a. bowling ball  b. billiard ball  c. none of the others",
    "a. gold foil  b. radioactive elements  c. discharge tubes",
    "a. Multiple Proportions  b. Conservation of Mass  c. neither",
    "a. Wave Mechanical  b. Nuclear Model  c. Chemical Model",
    "a. energy  b. frequency  c. constant",
    "a. Thomson  b. Schroedinger  c. Bohr",
    "a. centre  b. nucleus  c. middle",
    "a. Schroedinger  b. Rutherford  c. Bohr",
    "a. nodal surface  b. orbital  c. orbit",
    "a. beta  b. alpha  c. gamma",
    "a. many  b. few  c. one in ten thousand",
    "a. plum pudding  b. raisin bread  c. layer cake",
    "a. quanta  b. quantum  c. quantized",
    "a. three  b. six  c. nine",
    "a. high  b. low  c. constant",
    "a. mass & size  b. energy & frequency  c. time & space")
% array variables containing the multiple choice letter coresponding to answer
var letters : array 1 .. 20 of string := init ("c", "b", "c", "a", "b", "c",
    "a", "a", "b", "c", "b", "a", "b", "b", "c", "a", "a", "c", "a", "b")
var letters2 : array 1 .. 20 of string := init ("C", "B", "C", "A", "B", "C",
    "A", "A", "B", "C", "B", "A", "B", "B", "C", "A", "A", "C", "A", "B")

% Is the main procedure for the test option.  It outputs all questions in test
% gets answer from user, checks if  answer  is right and gives the user his or
% her mark on the test.
procedure test
    colorback (1)
    drawbox (0, 0, maxx, maxy, 2)
    color (15)
    locate (2, 16)
    put "A T O M I C   T H E O R Y   T E S T / R E V I E W"
    drawbox (60, 141, 580, 235, 2)
    drawbox (58, 139, 582, 237, 2)
    color (15)
    locate (10, 11)
    put "This test  will  judge  how  well  you  have  understood the"
    locate (11, 11)
    put "          information presented  in this tutorial.          "
    locate (12, 11)
    put "                         GOOD LUCK!                         "
    color (12)
    locate (14, 13)
    put "Note - ONCE YOU HAVE STARTED THE TEST YOU CANNOT EXIT!"

    drawbox (160, 10, 190, 32, 5)
    drawbox (163, 13, 187, 29, 13)
    drawfill (165, 14, 13, 13)
    color (14)
    % user's button
    locate (24, 28)
    put "Press any other key to begin test....."

    % main menu button
    drawbox (160, 52, 190, 74, 5)
    drawbox (163, 55, 187, 71, 13)
    drawfill (165, 56, 13, 13)
    locate (21, 28)
    put "Main Menu (M)"
    locate (1, 1)
    getch (reply)
    loop
	if reply = "M" or reply = "m" then
	    drawfill (165, 56, 0, 0)
	    drawbox (168, 59, 182, 65, 5)
	    drawfill (169, 60, 5, 5)
	    sound (500, 100)
	    delay (200)
	    drawfill (169, 60, 0, 0)
	    drawbox (163, 55, 187, 71, 13)
	    drawfill (164, 56, 13, 13)
	    exit
	else
	    drawfill (165, 14, 0, 0)
	    drawbox (168, 18, 182, 24, 5)
	    drawfill (169, 19, 5, 5)
	    sound (500, 100)
	    delay (200)
	    drawfill (169, 19, 0, 0)
	    drawbox (163, 13, 187, 29, 13)
	    drawfill (164, 14, 13, 13)
	    cls
	end if

	cls
	colorback (0)
	drawbox (0, 0, maxx, maxy, 4)
	color (10)
	locate (2, 10)
	put "PRESS ' ', ' ', OR ' ' TO RESPOND TO MULTIPLE CHOICE QUESTIONS."
	color (12)
	locate (2, 17)
	put "a"
	locate (2, 22)
	put "b"
	locate (2, 30)
	put "c"
	color (5)
	locate (4, 67)
	put "ANSWERS"

	row := 2
	row2 := 3
	flag := 0
	yi := 316
	yii := 310
	yiii := 310
	yiv := 330
	xi := 317
	xii := 310
	xiii := 317
	xiv := 310
	count := 0
	count2 := 0
	for i : 1 .. 20
	    count := count + 1
	    row := row + 3
	    row2 := row2 + 3
	    locate (row, 4)
	    color (2)
	    put questions (i) % display questions
	    locate (row2, 8)
	    color (5)
	    put answers (i) % display choice of answers
	    loop
		color (5)
		locate (row2, 70)
		setscreen ("echo")
		getch (reply)
		if reply = "a" or reply = "A" or reply = "b" or reply = "B"
			or reply = "c" or reply = "C" then
		    flag := 1
		    if reply = letters (i) or reply = letters2 (i) then
			% right checkmark
			count2 := count2 + 1
			play ("6eeg")
			yi := yi - 42
			yii := yii - 42
			yiii := yiii - 42
			yiv := yiv - 42
			xi := xi - 42
			xii := xii - 42
			xiii := xiii - 42
			xiv := xiv - 42
			drawline (578, yi, 583, yii, 4)
			drawline (583, yiii, 589, yiv, 4)
			flag := 1
		    else
			% wrong cross
			play ("6<<edc>>")
			yi := yi - 42
			yii := yii - 42
			yiii := yiii - 42
			yiv := yiv - 42
			xi := xi - 42
			xii := xii - 42
			xiii := xiii - 42
			xiv := xiv - 42
			drawline (576, xi, 583, xii, 4)
			drawline (583, xiii, 576, xiv, 4)
			color (4)
			locate (row2, 77)
			put letters (i)
			flag := 1
		    end if
		else
		    sound (100, 200)
		    locate (row2, 70)
		    put " "
		    flag := 0
		end if
		exit when flag = 1
	    end loop
	    if count = 6 then % start new page
		% user's button
		drawbox (160, 10, 190, 32, 4)
		drawbox (163, 13, 187, 29, 12)
		drawfill (165, 14, 12, 12)
		color (14)
		locate (24, 28)
		put "Press any key to go to next page..."
		setscreen ("noecho")
		locate (1, 1)
		getch (reply)

		drawfill (165, 14, 0, 0)
		drawbox (168, 18, 182, 24, 4)
		drawfill (169, 19, 4, 4)
		delay (200)
		drawfill (169, 19, 0, 0)
		drawbox (163, 13, 187, 29, 12)
		drawfill (164, 14, 12, 12)
		delay (100)
		cls
		setscreen ("echo")
		drawbox (0, 0, maxx, maxy, 4)
		color (10)
		locate (2, 10)
		put
		    "PRESS ' ', ' ', OR ' ' TO RESPOND TO MULTIPLE CHOICE QUESTIONS."
		color (12)
		locate (2, 17)
		put "a"
		locate (2, 22)
		put "b"
		locate (2, 30)
		put "c"
		color (5)
		locate (4, 67)
		put "ANSWERS"
		row := 2
		row2 := 3
		flag := 0
		yi := 316
		yii := 310
		yiii := 310
		yiv := 330
		xi := 317
		xii := 310
		xiii := 317
		xiv := 310
		count := 0
	    end if
	end for
	% user's button
	drawbox (160, 10, 190, 32, 4)
	drawbox (163, 13, 187, 29, 12)
	drawfill (165, 14, 12, 12)
	color (14)
	locate (24, 28)
	put "Press any key to see results..."
	setscreen ("noecho")
	locate (1, 1)
	getch (reply)

	drawfill (165, 14, 0, 0)
	drawbox (168, 18, 182, 24, 4)
	drawfill (169, 19, 4, 4)
	delay (200)
	drawfill (169, 19, 0, 0)
	drawbox (163, 13, 187, 29, 12)
	drawfill (164, 14, 12, 12)
	cls

	colorback (1)
	drawbox (0, 0, maxx, maxy, 2)
	color (15)
	locate (2, 16)
	put "A T O M I C   T H E O R Y   T E S T / R E V I E W"
	% rating
	color (10)
	if count2 >= 0 and count2 <= 9 then
	    locate (11, 23)
	    put "RATING - Better Study your material"
	    locate (12,23)
	    put "         a little more!"
	    locate (15, 23)
	    put "Final Score: ", count2, "/20"
	    color (12)
	    locate (15, 36)
	    put count2, "/20"
	    color (10)
	    locate (16, 23)
	    put "Percentage:  ", count2 * 5, "%"
	    color (12)
	    locate (16, 36)
	    put count2 * 5, "%"
	elsif count2 >= 10 and count2 <= 15 then
	    locate (11, 23)
	    put "RATING - Not bad.  But try to study"
	    locate (12, 23)
	    put "         a little more next time."
	    locate (14, 23)
	    put "Final Score: ", count2, "/20"
	    color (12)
	    locate (14, 36)
	    put count2, "/20"
	    color (10)
	    locate (15, 23)
	    put "Percentage:  ", count2 * 5, "%"
	    color (12)
	    locate (15, 36)
	    put count2 * 5, "%"
	elsif count2 >= 16 and count2 <= 18 then
	    locate (11, 23)
	    put "RATING - Wow! Your not to bad!"
	    locate (13, 23)
	    put "Final Score: "
	    locate (13, 36)
	    color (12)
	    put count2, "/20"
	    locate (14, 23)
	    color (10)
	    put "Percentage:  "
	    color (12)
	    locate (14, 36)
	    put count2 * 5, "%"
	    color (10)
	else
	    locate (11, 23)
	    put "RATING - Excellent!  I could use an"
	    locate (12, 23)
	    put "         assistant!"
	    locate (14, 23)
	    put "Final Score: ", count2, "/20"
	    locate (14, 36)
	    put count2, "/20"
	    color (10)
	    locate (15, 23)
	    put "Percentage:  ", count2 * 5, "%"
	    color (12)
	    locate (15, 36)
	    put count2 * 5, "%"
	end if
	% user's button
	drawbox (190, 10, 220, 32, 5)
	drawbox (193, 13, 217, 29, 13)
	drawfill (195, 14, 13, 13)
	color (14)
	locate (24, 31)
	put "Press any key to exit..."
	setscreen ("noecho")
	locate (1, 1)
	getch (reply)

	drawfill (195, 14, 0, 0)
	drawbox (198, 18, 212, 24, 5)
	drawfill (199, 19, 5, 5)
	sound (500, 100)
	delay (200)
	drawfill (199, 19, 0, 0)
	drawbox (193, 13, 217, 29, 13)
	drawfill (194, 14, 13, 13)
	delay (100)
	drawbox (0, 0, maxx, maxy, 2)
	exit
    end loop
end test
