Mansfield University CIS3306 Report

Design of a Database-based Quiz Creator Application in Java

by

John Phillips

bocaweb@hotmail.com

September 21, 2003

Summary

An multiple-choice quiz creator program was created for use in the computer courses that I teach. This program allows the instructor to create a multiple-choice quiz by filling the blanks on a form. The quiz can be saved as an XML file and quizzes can be loaded in again for further editing. When completed, a quiz can be uploaded to a MySQL database where a JSP program presents the quiz to students via a web-based interface.

This program demonstrates several advanced topics from CIS3306 including an advanced menu-driven GUI, XML file loading / saving, printing, and SQL database control. The source code can be viewed by visiting the project page at http://www.programbetter.com/capella/ts5513/index.html.

Introduction

A few years ago I developed a discussion board program named coursenotebook that I use in teaching both online and standard courses. However, coursenotebook is lacking an online quiz program. This project is part of the effort to fill that void.

A main quiz program (QuizGiver) allowing a student to login, select a quiz, take the quiz, and see his or her grade was created for another project. However, the project was lacking a way to easily create quizzes and insert them into the database. Quiz creation was all done manually and it was a rather tedious and difficult process to get the quiz inserted just right into the database. This report will focus on the QuizMaker application that was written to solve the quiz creation problem and as partial fulfillment of the requirements for CIS3306.

Screen shot of the QuizMaker program in action.

The Database Design

The QuizMaker application makes use of the JPquizzes table. The quizzes table contains all of the quizzes that are available for the student to take. Future versions of this program will allow beginning and ending dates to be set for each quiz so as to control when the student is able to take a quiz. However, for now, the student can take any quiz currently in the table. Below is a relationship diagram showing the tables used by the quiz program. The goal for QuizMaker was simply to allow the insertion of new records into the JPquizzes table. The quiz itself is in XML format and contains the questions as well as the answers. This XML text file is inserted into the quiz field of the JPquizzes table.

The QuizGiver program and database were developed as server-side applications on another server. However, it was not practical to use this database for the development of the CIS3306 project due to permission issues. Therefore, a MySQL 4.0 database was installed and configured on a development system for testing of the QuizMaker program. This is actually a closer model of reality as the final system will be hosted on a school-based Linux server running MySQL. MySQL can be downloaded from http://www.mysql.com/downloads/index.html.

In order for the setup to work, it was necessary to download a JDBC driver and to place the .jar driver file within the classpath. The driver used is named Connector/J 3.0 and is available at http://www.mysql.com/downloads/api-jdbc-stable.html.

The QuizMaker Program

The QuizMaker program is made up of two Java files: QuizMaker.java and QuizPanel.java. The program can be compiled by typing: javac QuizMaker.java and then run by typing java QuizMaker. As mentioned above, the MySQL database must be up and running with the proper user and tables created and the database driver installed within the classpath. When first run a blank quiz is presented. In this development version, quizzes are limited to just three questions. However, the code was designed to allow for future upgrades including allowing a variable number of questions. Below is a screen shot after the program is started.

The instructor can then type in questions and answers. A radio button is selected for each question to mark the correct answer. The instructor can then save the quiz as an XML text file by selecting the File menu and choosing Save As... as shown below.

Likewise, saved XML quiz files can be loaded read in using File and File Open. The current quiz can be printed by choosing File and Print. Of course, the main reason to use QuizMaker is to insert the quiz into the JPquizzes database table. This is done by choosing the Database Menu and then the Upload Quiz to Database menu item. This command causes the QuizMaker program to take the current quiz and format it as an XML document. Then the program connects to the MySQL database and inserts the XML quiz into the JPquizzes table. A view of the XML code generated is provided in a text area located beneath the quiz questions as shown below.

Conclusion

The program discussed has been tested on my home computer. It may or may not work correctly on other computers without having to modify the MySQL information. In addition, although some error checking is present the program is not bulletproof. There are many additions that can be made to improve the usability and functionality. For example, a File New menu option would be welcome, it would be nice if the program warned the user that the current quiz will be overwritten by a new one being loaded in, etc. There is a fair amount of work that must be done to port the QuizGiver application to the school-based Linux server. However, porting the QuizMaker program should not be a problem as it is already designed to work with a MySQL database server.

References

Deitel & Deitel (2003) Java How To Program, 5th ed. Prentice Hall, NJ

DuBois, P. (2000) MySQL. New Riders, Indianapolis, IN

MySQL, Inc. (2003) MySQL Documentation. Available at: http://www.mysql.com/documentation/index.html. Last accessed: September 21, 2003.

Phillips, J. (2003) Mansfield University CIS3306 Project: Design of a Server-Side Database-based Quiz Program Using JSP and Quiz Results Analysis Tool Using Perl and XML. Available at: http://www.programbetter.com/capella/ts5503/. Last accessed: September 21, 2003.

Sun, Inc. (2003) Java 2 Platform Std. Ed. v1.4.2 API Specification. Available at: http://java.sun.com/j2se/1.4.2/docs/api/. Last accessed: September 21, 2003.

Wigglesworth, J. & McMillan, P. (2004) Java Programming: Advanced Topics. Course Technology, Canada.