Previewing the Quiz Machine

Previewing the Quiz Machine

The main program for this chapter is a fun and powerful tool that can be used in many different ways. It is not simply one program, but a system of programs that work together to let you create, administer, and grade multiple choice quizzes automatically.

Start example

It would be reasonably easy to build an HTML page that presents a quiz and a PHP program to grade only that quiz. However, if you will want several quizzes, it might be worth the investment in time and energy to build a system that can automate the creation and administration of quizzes. The real power of programming comes into play not just when you solve one particular immediate problem, but when you can generate a general solution that can be applied to an entire range of related problems. The quiz machine is an example of exactly such a system. It takes a little more effort to build such a system in the beginning, but the effort really pays off when you have a system you can re-use many times.

End example

Entering the Quiz Machine System

Figure 6.1 shows the main page of the system. The user will need a password to take a test, and a different administrator password to edit a test. In this case, I've entered the administrative password (it's "absolute" - like in "absolute beginner's guide") into the appropriate password box, and I'm going to edit the Monty Python quiz.

Click To expand
Figure 6.1: The user is an administrator, preparing to edit a quiz.

Editing a Quiz

If the user has the correct password, the screen shown in Figure 6.2 appears, displaying the requested quiz in a special format on the screen.

Click To expand
Figure 6.2: The user has chosen to edit the Monty Python quiz.

The quiz administrator can edit the quiz in a number of ways. Each quiz has a name, instructor e-mail address, and a password. Each question is stored in a single line with the question, four possible answers, and the correct answer separated by colon (:) characters.

Taking a Quiz

Users with knowledge of the appropriate password can take any of the quizzes known to the system. If a user chooses to take the Monty Python quiz, the screen shown in Figure 6.3 appears.

Click To expand
Figure 6.3: The user is taking the Monty Python quiz. If you want to become a serious programmer, you should probably rent this movie. It's part of the culture.

Seeing the Results

When the user takes a quiz, the user's responses are sent to a program that grades the quiz and provides immediate feedback, as shown in Figure 6.4

Click To expand
Figure 6.4: The grading program provides immediate feedback to the user and stores the information in a file so the administrator can see it later.

Viewing the Quiz Log

The system keeps a log file for each quiz so the administrator can tell the scores of each person who took the quiz. Figure 6.5 shows how people have done on the Monty Python quiz.

Click To expand
Figure 6.5: The log retrieval program presents an activity log for each quiz.

Although the resulting log looks very simplistic, it is generated in a format that can easily be imported into most gradebook programs and spreadsheets. This is very handy if the quiz will be used in a classroom setting.