See the download page to obtain this program
This script is intended for teachers to create multiple-choice, self-test web pages. The following figure shows a self-test web page. On the left are sections of the tests. At the top right are the questions for this test. A student answers by clicking on radio buttons. Clicking on a question mark button provides some advice shown at the bottom right.
It is assumed that a separate directory will be used for self-tests, and that this is a sub-directory of some course directory. It is also assumed that this is a sub-directory of the user's home web directory. The script translates self-test files (file.self) in the current directory and creates:
The self2html script creates the self-test pages. A separate self_answer CGI script is used to handle submitted answers and compare them with the correct ones.
The main self.html page is divided into three frames: contents (cont.html), questions (*_que.html) and reasoning for answers (*_rea.html). A frame of questions is obtained by clicking on an item in the contents frame. Answers can then be selected for each question and submitted for evaluation. The reasoning frame is used for the evaluation, and also for explanations requested by clicking on a help symbol in the question frame.
The course name must be given as the first command-line parameter. All self-test files *.self in the current directory are processed. A sample call might be:
self2html "31P5 (Rigorous Design)"
The self2html script uses a number of images that are supplied with the distribution. (Some of these are borrowed from image collections available on the net.) Manually copy or link the following images to the self-test directory. Ensure that the images are all world-readable.
The script links to index.html in the parent directory (which is presumed to describe the course).
The following environment variables are used:
Certainly customisations should be made in the code. Even for a non-Perl programmer these should be reasonably obvious:
The self_answer script will also need a little customisation for file suffixes and words to be capitalised in filenames. See the customise subroutine in the code.
Self-test questions/answers have the file extension .self. They are intended for translation to HTML. In the main, text is copied literally from a .self file to a .html file. This allows the use of literal HTML in the input (e.g. to include images or pre-formatted code).
However, certain lines begin with a control directive. These consist of a character followed by a full stop. If the directive is not one of those below it is treated as literal text. A directive is always the first text of a line. White space (spaces, tabs) at the start of a directive is ignored, as is the case of the letter.
To avoid students guessing that an answer without an explanation is the right one, it is desirable if some right answers have explanations. Equally, some wrong answers may have no explanation. As a regular grammar, the format of a self-test file might be written:
( C | H | Q ( R E? | W E? )+ )?
where `?' is zero or one and `+' is one or more.
Here is a sample self-test file that includes literal HTML. Further examples are provided with the distribution.
C. "example.self" K. J. Turner 22/11/98 H. Self-Test Example Q. The code generated from the tree in: <center><img src="tree-walk.gif"></center> <p>is as follows: R. <pre> LOAD a LOAD b LOAD c MUL ADD </pre> W. <pre> LOAD c LOAD b MUL LOAD a ADD </pre> E. This just happens to calculate the right answer, but in the `wrong' order.
Make the modifications described earlier to self2html and place it in a directory on your search path. Copy the images and sample self-test files from the distribution to some directory under your home web directory. Change to this and run self2html. Study the resulting files and open self.html with a web browser. Click on items in the contents list and help icons in the questions to see if the pages behave as expected.
Now install self_answer in the web server's CGI directory. (CGI.pm needs to have been previously installed). Submit a set of answers from the questions frame and check that an evaluation appears in the reasoning frame.
self2html is free software, distributed under the GNU Public License Version 2. You may re-distribute this software provided you preserve this README file. The contents of this package may be used freely for non-commercial purposes provided this README file and copyright notices are retained. Copyright remains with the author. No warranties are given as to the accuracy or suitability of this package.
These scripts are loosely based on the Honours project work of James A. Hunter (University of Stirling, April 1997).
First public version Ken Turner, 22nd November 1998
Up one level to Web UtilitiesLast Update: 15th July 2006