Multiple Choice Loging Question Script


mcqscript.cgi is a Perl script that generates multiple choice questions from a question data file. The questions are presented to the user who must enter a class number and student id number for data logging purposes. Once the user answers the question, the script evaluates the answer and will log the results into a data file that has the same name as the class number. Answers are either right or wrong, 1 or 0. Users are only allowed to answer each question once, the program will prevent further attempts to change an incorrect answer. The question data file is in the same format as the mcsimple data files. To see the examples in action click on a question below.

Question 1

Question 2

Question 3

Use of the Script

For the most part, the mclog script is the same as the mcsimple script but with additional code built to handle logging of student responses. Please see the notes for mcsimple and make sure you can get that script running before attempting to install and use mclog. Outwardly, using mclog is the same as using mcsimple. You need to supply the same type of HREF link to the script and pass it the pathname of the question to use. So, for all practical purposes, if you can use mcsimple you can use mclog. Where the scripts differ is in the use of a roster file.

View the script

The Roster File and Logging of Student Responses

The mclog script will need a roster file in order to operate. This roster file will essentially be a list of the student id's for which you'd like to log responses. The first row in the file should be heading columns that the script will use when it display's results. Here is an example:
The file is comma delimited, that is, each field is separated by a comma. Create this file and save it, giving it a 4 character name that corresponds to the class number. This is the same number that the students will type in to identify the file so that the script can determine if they're enrolled or not.

After the file is created, you must decide where you will keep the roster file. I suggest a directory outside of Webspace, that is, not viewable to visitors of your Website. You will need to modify the mclog script to point to this directory. The variable $roster_path in the script will have to be changed to reflect your site. Also, at this time you might want to change the $data_path variable to reflect your site (see mcsimple).

Once this is done, create a link to the script with a question file and give it a try. Each time a particular question is tried the script will add a column to the roster file to store student responses. For example, take a look at the roster file 5467 which has 2 students. The file will start out looking like this:

After the first student tries a question, say Question1.qdf, and answers it correctly. That question will be added to the file along with that students' grades. Students that haven't tried that particular question will have a NA (not applicable) stored as their grade until they complete it. The file would then look like this:

If the second student then tries Question3.qdf, and answers it incorrectly, the file will then look like this:

The program will only allow each student one attempt to answer the question. Since the file is a comma delimited format, it is quite simple to import the file into a spreadsheet for manipulation.

Script Messages

When the script encounters data that it cannot find or properly open, it will generate an error message. Here is a list of errors and possible causes:

1. Cannot find the roster file - Either the student entered a class number for a file that doesn't exist or the enviroment variable in the script, $roster_path, is pointing in the wrong place.

2. Cannot find student id number - The student entered the id number incorrectly or it doesn't exist in the roster file. The student id's must occupy the first column in the roster file.

3. Cannot fine file:XXXXXXXXXXXX - Can't find the question data file. Check the enviroment varible that points to the question directory and check your A HREF link.

If the script encounters any of these problems it will not log any data into the roster file.

Let us know you're using the scripts.


This hypermedia page is maintained and copyrighted by Ron Earp.