Back to the CCCE Spring 2001 Newsletter.

Interactive, Multiple-Choice, Practice Examinations

Steal My JavaScript

Carl H. Snyder, Chemistry Department, University of Miami, Coral Gables, FL 33124
CSnyder@miami.edu

In the 1996 issue of the CCCE Newsletter, I described a procedure for converting multiple-choice examinations into Web-based, interactive examinations through HTML coding ("A Web Page in Chemical Education"). The process involved:

Choosing a wrong answer transferred you to a corresponding wrong-answer file. This required the use of the browser's return function to go back to the question for another attempt. Choosing the right answer carried you to a file with a congratulatory message and a link to the next question in the examination file. Although simple to construct and use, the system was cumbersome. A 50-question examination required 56 files:

with appropriate links among all. The procedure resulted in continuous interaction with the server, switching back and forth among the various files. This could prove frustrating on a busy Web-day.

More recently I have adapted JavaScript to these practice examinations. Only one file is used, the examination file itself. The result is an increase in elegance, simplicity and speed. Although JavaScript is a more complex scripting language than HTML, the genius of the Web provides a simple solution to anyone who wishes to adopt the procedure. The key lies in the subtitle of this paper, Steal My JavaScript. Those who are reluctant to steal a Web script can take heart: You will not actually be stealing this one; you will simply be accepting my invitation to download it and adapt it to your own purposes.

Begin by examining the three JavaScript-coded examinations linked below. Skim through each, simply pressing and holding down the left mouse button over your choice of answer. Don't click the button. After reading the comment release the button and move to a different answer if your first choice was wrong. If your choice was right the program itself takes you to the next question when you release the button. The process is simple and fast since your browser reads only one file, the one it receives from the server. You do not continually interact with the server. To examine the operation choose from any of the following three examples. But first, two notes:

The examples: To see what makes the system tick, view the source code with your browser's view-source function or simply download the file and examine it with a word processor or an editor. You'll find three major segments to the JavaScript coding:
  1. Within the head, above the line of asterisks, lies code designed to make the JavaScript work with both Netscape and Internet Explorer, and to place the "right" and "wrong" overlays at a suitable spot on the screen. All this code was written by members of the University of Miami Information Technology group. I suggest using this as it stands. It works well.

  2. Following the head, just below the body tag, lies code for 10 overlays (Layers 1 - 0), which consist of 5 "wrong" (1 - 5) and 5 "right" (6 - 0) overlays. I have chosen to connect the wrong overlays to the wrong answers among a - e, and to assign the right overlays randomly to the single right answer within each question. Other options can be used, including only one "wrong" overlay to be used with all wrong answers and one "right" overlay to be used with all right answers. You might want to play with these to customize the comments and/or the colors.

  3. Following the 10 Layers come the questions themselves. In converting an examination into a JavaScript file I use a word processor macro to insert a wrong-answer code, from Layers 1 - 5, into each of the five choices of answers, a - e. Then I manually convert the single right answer in each question to a randomly chosen right-answer code, from Layers 6 - 0. All the initial, routine wrong-answer coding for all five answers can be accomplished by macros.

That summarizes the general approach. Feel free to download the files and alter the script to fit your own needs.

In its utility JavaScript lies between the simpler HTML and the more complex CGI scripts. HTML was described in the 1996 article; CGI allows radio buttons, reporting of test scores, and other advances beyond JavaScript.

The nicest compliment I've received on these JavaScript file examinations came from an out-of-state student. Our end-of- semester examinations come soon after the Thanksgiving break. She had gone home for Thanksgiving. On her return to Miami she thanked me for putting the JavaScript practice examinations on the Web. They allowed her to review for her Miami chemistry examinations from her home in Wisconsin, via the Web. We are living in a truly glorious age!

You can send comments or questions to me at csnyder@miami.edu

END

Back to the CCCE Spring 2001 Newsletter.