Monday, September 29, 2008

Freebies - Looking for a Free Gift ??

Creating the Quiz Machine Program

The quiz tool from the beginning of this chapter is actually an entire system of programs designed to work together, in this case, five different programs Each quiz is stored in two separate files, which are automatically generated by the programs. Figure 6.11 is a flow diagram that illustrates how the various programs fit together.

Click To expand
Figure 6.11: This diagram illustrates a user's movement through the quiz machine system.

The QuizMachine.php program is the entry point into the system for both the test administrator and the person who will be taking the quiz. It essentially consists of three forms that allow access to the other parts of the program. To ensure a minimal level of security, all other programs in the system require some sort of password access. The QuizMachine program primarily serves as a gateway to the other parts of the system. If the user has administrative access (determined by a password), he or she can select an exam and call the editQuiz.php page. This page loads up the actual master file of the quiz (if it already exists) or sets up a prototype quiz, and places the quiz data in a Web page as a simple editor. The editQuiz program calls the writeQuiz.php program, which takes the results of the editQuiz form, and writes it to a master test file as well as an HTML page.

If the user wants to take a quiz, the system moves to the takeQuiz.php page, which checks the user's password and presents the quiz if authorized. When the user indicates he or she is finished, the gradeQuiz.php program grades the quiz and stores the result in a text file.

Finally, the administrator can examine the log files resulting from any of the quizzes by indicating a quiz from the QuizMachine page. The showLog.php program will display the appropriate log file.

Building the QuizMachine.php Control Page

The heart of the quiz system is the quizMachine.php page. This is the only page that the user will enter directly. All the other parts of the system will be called from this page or from one of the pages it calls. The purpose of this page is to act as a control panel. It consists of three parts, corresponding to the three primary jobs that can be done with this system: Writing or editing quizzes, taking quizzes, and analyzing the results of quizzes. In each of these cases, the user will have a particular quiz in mind, so the control panel automatically provides a list of appropriate files in each segment. Also, each of these tasks requires a password, to provide at least some level of security.

The main part of the QuizMachine.php program simply sets up the opening HTML and calls a series of functions, which will actually do all the real work.

No comments: