Question Generation

The process of setting up a coursework is one of creating the questions, i.e. of generating the appropriate files that define, display and mark the question, and building the question list that defines the question numbering and question order. The most straight-forward way to do this is to use the automatic generation system, that is driven by an XML file that describes the questions. This system is described here and can be used for a reasonable range of questions. For more complex questions or interactions with the student, then a rather more complex process is required which involves writing "jsp" and "java" programs and integrating these with ExerTran, although there is quite a lot of support classes to assist in this. This is dealt with in .

In this chapter, the auto-generation process is presented. This process starts with writing a file in XML that defines one or more questions: this is called a "question document" in the following. XML is now a well-known system, in computing circles at least, for laying out data files, documents, etc. One of its key advantages is that it is possible to check that an XML file is well-formed, i.e. that it is correctly laid out with respect to some defined rules, if a DTD (Document Type Definition) file is created defining the layout rules for the XML file. Writing XML files is not difficult, especially as any editing program can be used, provided the DTD is not too complex. There is plenty of information on the web and in books on XML, and no review is covered here, although an attempt is made to explain some aspects in describing the process of defining questions here.

As might be gathered from the previous paragraph, a DTD file is important in defining the rules for the structuring of an XML file, and for validating that a particular XML file meets these structuring rules, i.e. that it is "well-formed". The DTD for the question generation system is shown in Figure 2 in the Section called Question Document DTD File. This will be referred to occasionally in the rest of this chapter.

The following is an outline of the structure of an XML file that defines a set of questions divided into topics, the dots imply other content:-


       <?xml version="1.0" encoding="UTF-8"?>
                !DOCTYPE question-document SYSTEM "QuestionDocument.dtd">
                <question-document package="telecoms" class="BasicComms" jsp="basicComms">
                  <topic name="Tpc1" title="Basic Communications">
                      <question ...........>
                        .  
                        .  
                        .  
                      </question>
                      <question ...........>
                        .  
                        .  
                      </question>
                  </topic>  
                  <topic  name="Tpc2" title="Packet Switching">
                      <question ...........>
                        .  
                        .  
                        .  
                      </question>
                      <question ...........>
                        .  
                        .  
                      </question>
                  </topic>  
                </question-document>
      
      
An XML file, that is to be validated against a DTD, always starts with 2 header lines, as shown in the listing. The first line defined the version of XML used in the file, currently there is only version 1.0, and the encoding of the text. The second line gives the name of the DTD file, "QuestionDocument.dtd" containing the definition of the XML structure, and the name of the outermost set of tags, "question-document" in the XML file. XML uses tag pairs to define content, e.g. <question> and </question>. The tag name appears within angle-brackets with the closing tag having a "/" before the tag name. All the content in an XML file must appear within the the outermost tag pair, "question-document" in the listing, with the opening tag on the line after the header lines, and the closing tag of the pair being on the last line.

The terminology of XML is that an "element" is a pair of tags, consisting of one "opening" tag and one "closing" tag: the element goes by the name of the tag name, e.g. the question-documnet element. The content of an XML element can be other elements and/or text as specified in the DTD. This is seen in the outline listing above, where the "topic" elements are within the "question-document" element, but themselves contain "question" elements. An element identifies a block of content within an XML file. The rest of this chapter describes the allowable elements in a Question Document, and their attributes, and explains their roles.

A question document XML file defines questions within one or more topics, with the questions within each topic being defined within a "topic" element. Each question being defined within a "question" element. The opening tag of a "topic" element is slightly different from my specification above: it contains two "attributes". An attribute is a name-value pair with the value surrounded by double-quotes and separated from the name by a single "=" sign: the double-quotes are mandatory. Zero or more attributes can be specified for a tag, and the allowable attributes for a tag are specified in the DTD: see the lines at the end of the Figure 2 in the Section called Question Document DTD File. In this instance the nameaatribute gives a string to be associated with the questions of the topic, while the title attribute gives a title string, that is to be associated with the questions in the topic: this title will appear in the question list displayed on the student interface. The "question-document" element also has attributes as can be seen in the example above.

The possible layout of a question (a channel error rate question for telecomunications course) is shown in the following listing:-


      
    <question name="1" mark="2" type="multi" awardPartMarks="true">
    <question-message>"Y-bit words are transmitted down a channel which has a bit error rate of 10&lt;sup&gt;-X&lt;/sup&gt;(assume bit-errors are independent)."</question-message>
    <question-part part="0" partMark="1">"What is the residual error rate in terms of words? [N.B. you may use engineering notation - e.g. 3.7E-9]"</question-part>
    <question-part part="1" partMark="1">"A single parity bit is added to each word in Question 1 (making a total of Y+1 bits per word). Estimate the new residual error rate in terms of words. [N.B. you may use engineering notation - e.g. 3.7E-9]"</question-part>
    <variable>
    	<random type="double" name="errorExp" low="6" high="12" step="1" message="Error rate exponent, X, = "/>
    	<random type="double" name="wordSize" low="10" high="20" step="1" message="Word size, Y, in bits  = "/>
    </variable>
    <equation>double prob = Math.pow(10,-errorExp) ;</equation>
    <double  units="" precisionPercent="1" part="0">(1-Math.pow((1-prob),wordSize))</double>
    <double  units="" precisionPercent="1" part="1">(wordSize*((wordSize-1)/2)*prob*prob*Math.pow((1-prob),wordSize-2))</double>
    <helpfile name=""/>
  </question>
      
      
This question has 2 parts: there are 2 "question-part" elements. Each part has a mark of 1, attribute "partMark" is 1 for both, and marks for the individuale parts are awarded, attribute "awardPartMarks" on the question is set true. For each question part, there is some text defining the question to be answered for the part, but there is also some overall text related to all parts of the question, which is defined by the content of the "question-message" element. Within the question 2 "random" variables are defined, for each of which is defined: a name to refer to the variable; the type of the variable, e.g. integer, double floating point; the minimum and maximum value of the variable; how value of the variable changes between the high and low values; a message that relates to the variable. The "low", "high" and "step" attributes define a set of values for each variable, one of which values will be allocated to the variable at random when the question is displayed: the variable message and the variable value are output to the web page whenever the question is attempted.

The content of the "equation" element provides a mechanism to use the values from the variables to calculate values for use in answer elements. This content needs to be Java statements. The answers for each part of the question are defined in this listing within "answer-double" elements, where there are attributes to define such things as the part being answered; the precision of the student's answer relative to the program generated answer; the units to be printed against the answers in the output display. The content of an "answer-double" element is some Java expression that defines the answer in terms of the variables specified in the question, a variable calculated in the equation section, or some mixture of these: the last is true for both parts in the listing.

A "help" element can specify a file containing a help page that will be displayed on the question page: help files reside within the WEB-INF/help directory of the ExerTran application.

The question in the listing above produces the output display shown in Figure 1

Figure 1. Output display for the channel error rate question

The last section of this chapter details the elements, i.e tag pairs, available within a question document, and their attributes.

Generating the files from the XML definition

For each question document file, 3 files are generated from the XML definition of the topics and questions. One file is a Java file that assigns values to variables and calculates question answers: it includes the Java statements in any equation elements and Java expressions from the answer parts. One file is a JSP file that displays the questions. The third file is a list of the questions in a form that can be included in the question list form on the manager interface: see . The structure of each file is defined with an XSL file for each one. XSL is the Extensible StyleSheet Language. XSL provides a mechanism for defining how to process an XML file to generate some particular output format. XSL files are quite complex and mine are not particularly easy to read.

There are a number of available systems for parsing an XML file with an XSL file. The manager interface uses the Xerces SAXParser from Apache, and the file generation process can be performed from the manager interface with the question generation command. The output files will be placed in a sub-directory of the coursework's packages directory structure with the directory name given by the package attribute question-document of the XML file:-

Java File

This goes in the java directory. The class file derived from the Java file is compiled to the appropriate package directory in the WEB-INF/classes directory of the coursework's Tomcat webapps directory. See the section on the Tomcat Directory Structure and the section on Courses Directory Overview.

JSP File

This goes in the java directory. It is also copied to the appropriate package directory in the jsp directory of the coursework's Tomcat webapps directory. See the section on the Tomcat Directory Structure and the section on Webapps Jsp Directory.

Question List File

This will be placed in the Applications WEB-INF/files directory. The name of the file is ***********!!. See the section on the Tomcat Directory Structure.