Classic Computer Magazine Archive COMPUTE! ISSUE 52 / SEPTEMBER 1984 / PAGE 58

The Tester

Joseph Kattan

Multiple-choice tests have been standard for years. Now anyone who wants to create a multiple-choice test on his home computer can easily do so. Tests can be devised to teach youngsters anything from history to sports trivia. Just fill in the DATA statements with the questions and answers and the program will do the rest. Versions that work on the Commodore 64, VIC-20, PETs, Apples, Radio Shack Color Computer, Coleco Adam, IBMs and TI-99/4A are included.

One of the most frequently cited reasons for purchasing a personal computer is its great potential as an educational tool. The home computer is widely used to teach children to spell or perform simple arithmetic calculations and to drill adults on anything from foreign languages to organic chemistry. A well-designed instructional program can produce spectacular results in improving a student's command of a subject. A poorly designed program, on the other hand, will frustrate, rather than teach.

Computers, for better or worse, cannot yet think. If the programmer tells the computer that Washington is the capital of the United States, the program will be less than kind to the hapless user who responds that Washington, D.C., is the capital. If the programmer tells the computer that avoir means "to have," pity the French student who answers "to possess." These are, of course, soluble problems, but they illustrate one weakness in computerized instruction. No matter how well designed the program, there will always exist a correct answer to some question that the program will not recognize. You can instruct a program to accept Washington, Washington, D.C., and Washington, DC, as the answer to the capital question, but how do you cover all of the synonyms of a word like fantastic in a foreign language translation program?

No Ambiguity

There is one kind of testing that a computer handles exceptionally well, because it is not required to reason: multiple-choice. It takes little effort to insure that the answers to a multiple-choice test are free of ambiguity, which is why all of the standardized testing in our schools tends to be multiple-choice. These tests, moreover, require less effort on the part of the user than answer-oriented tests, and can be used together with the more rigorous answer-oriented tests to form a very effective instructional package.

Remembering To Answer

Designing an effective program for a multiple-choice test is no easy matter, however. A simple and commonly used algorithm selects a question from DATA statements at random and then reads four or five different answers from the DATA statement, together with a code that identifies the correct answer.

There are several deficiencies to this solution. For one, it consumes tremendous amounts of memory, as it gobbles up bytes both for the correct answer and for the dummy answers that have no use other than to serve as the incorrect choices. In addition, the program user is always presented with the same set of choices, and in the same order, for each question. The user may well get into the habit of remembering that the answer to a question is C without learning the answer itself.

A more elegant solution should present truly random choices for each question. The user should rarely, if ever, encounter the same choices for a given question. The program, moreover, will be more compact because every answer in its DATA statements will be a correct answer to some question. With this method, the program will select a question from a DATA statement at random, will read the answer to that question from the same DATA statement, and then read four more answers at random to present as false choices. This method insures that the same answer is not presented as two separate choices (since random selection could cause that result) and arranges the order of the answers at random The U.S. capital may be C on one run of the test but A or B or D on another.

Segregated Data

Even this method, however, has a potential pitfall, and the solution discussed here resolves it. Let's take a U.S. history test as an example. The answers to such a test may be George Washington, or Philadelphia, or 1776. Obviously, it would be quite absurd to present Philadelphia or 1776 as possible answers to a question calling for the name of the first president. The solution to this problem is to segregate the DATA statements containing the questions and answers into different areas of the program and to select answers to each question only from a valid area. For example, DATA statements between 1000 and 1999 could contain questions concerning names of persons; DATA statements between 2000 and 2999 could contain questions concerning places; and so forth. The program chooses an area at random and then stays in that area to present the incorrect answers. If the answer to the question selected is George Washington, the four incorrect answers will always be names of persons.

This solution has an added advantage. It allows for the inclusion of diverse subjects on a single test, with the testing either confined to a subject chosen by the user or mixed at random by the computer. This program is intended primarily for single-subject tests that require the segregation of answers by types, as in the U.S. history example above.

How It Works

The program relies on two arrays—Q, which stores the number of questions in each category, and T, which selects the answers at random. The variable N is used to store the group of questions and answers to be called. The question and answer are selected by the computer at line 300. Since answer groups are stored in DATA statements beginning with 1001, 2001, and so forth, the program adds that number to a random number from 1 to the number of questions for the appropriate group, as indicated in the Q array. For example, if the question and answer are to come from group 1, for which questions and answers are stored in lines 1001 through 1011, the program looks to the variable Q(1) to ascertain the range of random numbers to generate.

Once a question and answer have been read, the program uses the same random number formula to look up the incorrect answers. It stores the random numbers (data line numbers) in a T array (line 330) and makes sure that none of the numbers in that array is equal to the line number of the correct answer or to the number of another element in the array (line 335). At line 340, the program chooses where to place the correct answer, which can be any choice from one to five, and then proceeds to place all of the choices on the monitor or television screen. Once an answer is entered, the program indicates whether or not it was correct. In the case of a correct answer, the program waits for two seconds (lines 400 and 410) and then constructs a new screen. If the answer entered is incorrect, the program waits for the RETURN key to be pressed before moving on to the next screen.

Screening Keys

One other matter is the little subroutine beginning at line 800. The entire subroutine could be replaced with a single INPUT statement. The advantage of the subroutine is that it screens out unwanted keys (in this case, anything but a number) and maintains the integrity of the screen display. In addition, the subroutine does not attach a question mark to a prompt, allowing you to insert it where it is appropriate and omit it where it is not. Study the DATA statements beginning at line 1001 and you can see the flexibility afforded by the subroutine.

This program is obviously meant to be modified. When modifying it for your own use, pay special attention to the Q array. The array should be DIMensioned to the number of answer categories in the program. The same number should be placed in the variable SUBJ. The elements of the Q array should be equated to one more than the number of questions in the appropriate category. Finally, the questions and answers should be placed on the same DATA statement, and the DATA statements should be arranged in increments of one beginning with a line number of N*1000 + 1, N being the number of the group. Make sure that neither the questions nor the answers contain any commas, since the BASIC interpreter will take the commas to indicate the end of a string.

Microsoft And TI-99/4A Version Notes

Jeff Hamdani, Editorial Programmer

The Microsoft version of "The Tester" (Program 2) runs on the Commodore 64, the VIC-20, all PETs, the Apple II+, IIc, and IIe, the Radio Shack Color Computer, the Coleco Adam, and the IBM PC and PCjr. If you have a VIC without memory expansion, remove all REMs and spaces when typing in the program. With an IBM PC or PCjr, make the following minor changes:

Add line 100:


Change line 220 to:


Add line 225:

225 Z$ = INKEY$ : RD = RND : N = VAL (Z$) : IF Z$ = "" OR (N < 1 AND N > 4) THEN 225 ELSE PRINT N

Last, in Program 2, line 930 contains a statement to clear the screen. Replace this with the appropriate statement for your computer. For instance, on the Apple, line 930 would read:


The TI-99/4A version of The Tester (Program 3) will run in either Console or Extended BASIC.