Assignment 5: CGI

Due Monday, December 1, 2003 10 PM

In this assignment, we create a web application to help learn vocabulary words. The web site freevocabulary.com contains a list of about 5000 words and short definitions. I have extracted this list into the file /home/unixtool/data/vocab.dat. Your task is to write a CGI script that presents and grades a vocabulary quiz.

The first part of this is creating the quiz. For this, your CGI script will pick ten random words from the data file, and for each of these present four definitions (one correct and three incorrect ones). The user will pick the correct definitions by using an appropriate HTML form element (such as radio or drop down menu).

When the form is submitted, another CGI script will grade the test and report the results. This is the second part of the assignment.

Here's an outline as to how you might want to write this program (note that you are free to implement it however you want, this is just a suggestion):

  1. Randomize the order of the vocab.dat file. The script /home/unixtool/bin/shuffle handily does this for you. Take the first 40 lines.
  2. Read 4 lines at a time. Use each definition as the possible answers. Randomly pick one of the 4 words as the question. (You can use (($RANDOM % 4)) in ksh and int(rand(4)) in Perl to do this).
  3. Store the correct answer as a hidden form element.
  4. Have your grading CGI script compare the hidden form elements to the user selected form elements.

Notes

You may write your scripts in perl or ksh (or one part in each if you'd like).

The file format is word|part-of-speech|definition. For example,

      muddle|v.|To confuse or becloud, especially with or as with drink. 
You can ignore the second field (part of speech).

To see a working version of this assignment, click here. You are encouraged but not required to make your output look nicer than that. (FYI: the version linked to is written in ksh, each part is 24 lines).

Developing CGI Scripts

Information about setting up CGI at NYU can be found here.

Turning in the assignment