Create Self-Tests in HTML

See the download page to obtain this program

Description

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.

self-test

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:

blank_que.html
self-test question instructions
blank_rea.html
self-test reasoning instructions
cont.html
self-test contents page
index.html
a symbolic link to self.html
self.html
main self-test page (a set of frames)
*_que.html
questions from file.self
*_rea.html
reasoning for answers from file.self

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.

Usage

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.

email-small.gif
small email image
explan-small.gif
small explanation image
search-small.gif
small search image
self.jpeg
background image for pages; this is not part of the distribution and should be optionally supplied by the user
uparrow-small.gif
small up-arrow image
thumbs-down.gif
not OK image
thumbs-up.gif
OK image
web-small.gif
small web image

The script links to index.html in the parent directory (which is presumed to describe the course).

The following environment variables are used:

$AUTHOR
the user's name (e.g. `Ken Turner', $USER if not defined)
$USER
the login username

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 Format

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.

C. (Comment)
Text up to the end of the line is ignored. A comment line may appear anywhere.
E. (Explanation)
Text up to the next directive is treated as part of the explanation for a right or wrong answer. This is allowed only after R. or W. and is optional there.
H. (Header)
Text up to the end of the line is treated as header. This normally appears once early in the file, but could be repeated.
Q. (Question)
Text up to the next directive is treated as part of a question.
R. (Right Answer)
Text up to the next directive is treated as part of the right answer to a question. Usually there is just one right answer, but several are allowed (or even none). This is allowed only after Q.
W. (Wrong Answer)
Text up to the next directive is treated as part of the wrong answer to a question. Usually there is at least one wrong answer, but several may be given (or even none). This is allowed only after Q.

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.

Confidence Check

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.

Licence

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.

History

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 Utilities

Web Ken Turner Home   Email    Search Search Web Pages

Last Update: 15th July 2006
URL: https://www.cs.stir.ac.uk/~kjt/software/web/self2html.html