This page describes mcsimple.cgi, which is a PERL script that generates HTML pages containing a multiple-choice question or responses to the user's input. This script was written and developed in Perl 5.0 and is designed to work with Perl 4.0 or greater. Hopefully, this script will prove to be useful for the educator desiring to place multiple choice questions on an educational Web site for feedback purposes. The two question links below provide working examples of the script in action.
Question 1 is a three-part question and question 2 is a six-part question. Question 3 is of particular note as it is a four part graphical question. The question script reads the question data in from a specified file and generates an html file to present the question to the user. After the user selects an answer, the same script will read the question data file again and generate an answer html file with appropriate responses. The script is totally generic, as I hoped the question contents will show. They can be used for any topics you care to query about.
A HREF="server_root/question_dir/multi_question.cgi?filename=data/question1">My Question
The call for the question is located on any web page that you currently have and want to link a question from. In this example the question script is maintained in a question directory and the data files in another location . This way, subdirectories for each question can exist underneth the main data directory making question calls simple. The path to the question data file is appended with a "?" right after the script name. Simply place ?filename="your question file" at the end of the cgi call. Of course, then you place some text to indentify the HREF call. You can also check the source for this document to view the question calls. You must have a version of cgi-utils.pl installed for the scripts to work. This is a very nice script that will handle retrieving and splitting apart the input stream from the user so that the cgi script can work with the information.
Script calling flow diagram
The data file includes comments denoted with a # and they must be present in the data file for the scripts to work. Each line is terminated with a hard return. The questions can have any number of answers but the answers must start on line 7 of the data file. I suggest just using a blank question form and filling it in when necessary. The question data file must end with the .qdf extension for identification. Here is an example file:
Sample data file
Sample data file with graphics
View the script
This probably isn't the best example Perl code in the known world, but, twas my first attempt at Perl programming and I am only a humble chemist.
The scrpit operation is fairly straightforward. The question is presented in multiple choice format. The user is to select an answer and hit the submit answer button. If the user doesn't select an answer, this state is trapped out and the user is given a link back to the question. Both correct and incorrect responses are given an explination of the question answer. The responses can be changed by setting the proper variables at the beginning of the script. Check the script comments. It would be a simple matter to add code to gather student id's and log the responses to a file. We currently do this at our site but thought that a more general serving script would be useful for most people.
Question script flow diagram
Let us know you're using the scripts.