<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_plain.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="qmlspec">
  <name>QML 1.0 Language Specification</name>
  <metadata>
  <md:version>2.6</md:version>
  <md:created>2001/06/27</md:created>
  <md:revised>2002/06/26</md:revised>
  <md:authorlist>
      <md:author id="bartmess">
      <md:firstname>Elizabeth</md:firstname>
      
      <md:surname>Bartmess</md:surname>
      <md:email>bartmess@alumni.rice.edu</md:email>
    </md:author>
      <md:author id="brentmh">
      <md:firstname>Brent</md:firstname>
      <md:othername>Michael</md:othername>
      <md:surname>Hendricks</md:surname>
      <md:email>brentmh@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="bartmess">
      <md:firstname>Elizabeth</md:firstname>
      
      <md:surname>Bartmess</md:surname>
      <md:email>bartmess@alumni.rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="brentmh">
      <md:firstname>Brent</md:firstname>
      <md:othername>Michael</md:othername>
      <md:surname>Hendricks</md:surname>
      <md:email>brentmh@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>learning assessment</md:keyword>
    <md:keyword>qml</md:keyword>
    <md:keyword>questions markup language</md:keyword>
    <md:keyword>spec</md:keyword>
  </md:keywordlist>

  <md:abstract>Release 1.0 -- Initial release.</md:abstract>
</metadata>

  <content>
    <section id="version">
      <name>Document History</name>
      <para id="p1">
	Release 1.0 - Initial release.
      </para>	
    </section>

    <section id="intro">
      <name>Introduction</name>
      <para id="par_intro1">
	This document contains the specification for the Questions
	Markup Language (QML).  It is the definitive reference for the
	language and takes precedence over all other documents,
	including the DTD.
      </para>
      <para id="par_intro2">
	QML is an <link src="http://www.w3.org/XML">XML</link>
	application created for the purpose of marking up learning
	assessment items for the <link src="http://cnx.rice.edu">Connexions Project</link>.  The
	language is concerned with the semantic content of the
	information and attempts to enforce separation of content and
	presentation.  It contains few (if any) elements that deal
	with style or presentation.  Decisions about how to display
	QML should be made elsewhere.
      </para>
    </section>

    <section id="doctype">
      <name>Document Type</name>
      <para id="par_doctype1">
	QML documents must be well-formed XML documents, meaning that
	they must conform to the World Wide Web Consortium (W3C)'s
	definition of a valid XML document.  In order to be considered
	valid QML, a document must also declare itself using a
	Document Type Declaration.
      </para>

      <para id="par_doctyp2">
	The Document Type Declaration (DTDs) for QML differs depending
	on whether you are using QML by itself or with other
	language(s).  If you are using QML with other languages, you
	will also need to use namespaces (discussed in the following
	section).
      </para>

      <para id="par2_5">
	Document Type Declarations are provided here for QML by
	itself, QML with CNXML, and QML with CNXML and MathML.  If you
	are using QML with a language not listed here, you will need
	to create your own DTD.
      </para>

      <para id="par_3">
	In addition, you may need to alter one word in the DTDs below
	depending on whether you are using a problemset or an item as
	your base tag. If you are using a problemset as the base tag,
	you need to replace the word "item" in the second line with
	the word "problemset".
      </para>

      <para id="p4">
	If you are using QML by itself, put the following three lines
	at the top of your document:
      </para>

      <code type="block">
	<![CDATA[
	<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
	<!DOCTYPE item PUBLIC "-//CNX//DTD QML 1.0//EN"
	"http://cnx.rice.edu/qml/1.0/DTD/qml.dtd">]]>
      </code>

      <para id="p5">
	If you are using both QML and CNXML, use the following three
	lines: 
      </para>

      <code type="block">
	<![CDATA[
	<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
	<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus QML//EN"
	"http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_qml.dtd">]]>
      </code>

      <para id="p6">
	If you are using MathML as well as CNXML, use the following
	three lines:
      </para>

      <code type="block">
	<![CDATA[
	<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
	<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML plus QML//EN"
	"http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml_qml.dtd">]]>
      </code>
    </section>

    <section id="namespaces">
      <name>Namespaces</name>
      <para id="namesp1">
	One of the benefits of using XML is that it allows you to
	unambiguously combine different XML languages within the same
	document by the use of <term>namespaces</term> (See the W3C's
	recommendation, <link src="http://www.w3.org/TR/REC-xml-names/">Namespaces in
	XML</link>).
      </para>

      <para id="namesp2">
	It is possible to declare a default namespace by including the
	<code>xmlns</code> attribute in the root node (either
	problemset or item for QML).  The attribute contains a unique
	identifier (usually a uri).  It is important that the proper
	value of this attribute be used consistently.  The namespace
	identifier for QML is
	<code>http://cnx.rice.edu/qml/1.0</code>.  So for a
	document that only contains QML, the opening module tag should
	look like one OF the following, depending on whether your root
	tag is problemset or item.
      </para>

      <code type="block">
	<![CDATA[<problemset xmlns="http://cnx.rice.edu/qml/1.0". . . >]]>     

	<![CDATA[<item xmlns="http://cnx.rice.edu/qml/1.0". . . >]]>
      </code>

      <para id="name3">
	However, if you are using QML with another language, you must
	also declare a prefix (for example, <code>foo</code>)
	using the attribute <code>xmlns:foo</code> and the
	same value that you would use on the default namespace.  You
	can then indicate which tags come from a particular namespace
	or language by prefixing each tag with a
	<code>foo:</code>.  Thus, an item tag in foo's
	namespace would be written using
	<code>&lt;foo:item&gt;</code> and
	<code>&lt;/foo:item&gt;</code>.  The default namespace
	however, allows you to omit the prefix for that particular
	namespace and continue using <code>&lt;item&gt;</code>
	as you had previously.  However, if you are using more than
	one language, you will need to use prefixes with all
	namespaces but your default namespace.  For example, if you
	were using QML, MathML, and CNXML and wanted CNXML to be your
	default namespace, you would declare as follows in the CNXML
	root tag, module:
      </para>

      <code type="block">
	<![CDATA[
      <document xmlns="http://cnx.rice.edu/cnxml"
	xmlns:q="http://cnx.rice.edu/qml/1.0" 
	xmlns:m="http://www.w3.org/1998/Math/MathML". . .>]]>     
      </code>

      <para id="name4">
	You would then need to preface each QML tag in the document
	with "q:" and each MathML tag in the document with "m:" but
	would not need to preface the CNXML tags, because they are the
	default namespace.
      </para>

      <code type="block">
	<![CDATA[
      <list>...</list>
      <q:item id='item01'>...</q:item>]]>
      </code>

      <para id="name5">
	If you are adding other language(s) to a QML document, you
	will probably want QML to be the default namespace; if you are
	adding QML to a document in another language, you will
	probably want the original language to be a default namespace.
      </para>
    </section>

    <section id="bothtogether">
      <name>Using QML with CNXML</name>
      <para id="both1">
	QML within a CNXML document consists of one QML item tag
	encased within a CNXML exercise tag.
      </para>
    </section>

    <section id="tags">
      <name>Tags</name>
      
      <para id="st_par1">
	The <cnxn target="problemset" strength="8">problemset</cnxn>
	and <cnxn target="item" strength="8">item</cnxn> tags are the
	two base tags.  Although either may be used as a base tag, the
	problemset tag is used to contain a set of items and the item
	tag is used to contain a single item.
      </para>
      
      <section id="problemset">
	<name>Problemset</name>
	<section id="probdesc">
	  <name>Description</name>
	  <para id="probp1">
	    The problemset tag is the root tag for a set of items.  
	  </para>
	</section>
	
	<section id="probattr">
	  <name>Attributes</name>
	  <list id="problist1" type="bulleted">
	    <item>id - A unique identifier for the problemset
	      <list type="bulleted" id="problist2">
		<item>Optional</item>
	      </list>
	    </item>
	  </list>
	</section>
	
	<section id="probchild">
	  <name>Children</name>
	  <para id="probp2">
	    The only children of the problemset tag are <cnxn strength="8" target="item">item</cnxn> tags.  One or more
	    item tags must appear within the problemset tag.
	  </para>
	</section>
	
	<section id="probex">
	  <name>Examples</name>
	  <code type="block">
	    <![CDATA[      
	  <problemset id="math_set_1">
	  <item id="item1" type="single-response">
	    .
	    .
	    .
	  </item>
	  <item id="item2" type="single-response"> 
	    .
	    .
	    .
	  </item>

	  </problemset>]]>
	  </code>
	</section>
      </section>
      
      <section id="item">
	<name>Item</name>
	<section id="itemdesc">
	  <name>Description</name>
	  <para id="itemp1">
	    The item tag is the base tag for a single item.  Items may
	    be placed into a document singly or contained within a
	    problemset.
	  </para>
	</section>

	<section id="attr">
	  <name>Attributes</name>
	  <list id="itemlist" type="bulleted">
	    <item>id - a unique identifier for the item
	      <list type="bulleted" id="seclist2">
		<item>Required</item>
	      </list>
	    </item>
	    <item>type
	      <list type="bulleted" id="seclist3">
		<item>Required</item>
		<item>Possible values:
		  <list type="bulleted" id="seclist4">
		    <item>
		      single-response (for multiple-choice,
		      true/false, <foreign>etc.</foreign>)</item>
		    <item>
		      multiple-response (where two or more options
		      must be selected)</item>
		    <item>
		      text-response (a string of text or a numerical
		      answer)</item>
		    <item>
		      ordered-response (multiple-response for which
		      order of the selected responses is
		      important)</item>
		  </list>
		</item>
	      </list>
	    </item>
	  </list>
	</section>
	
	<section id="itemchild">
	  <name>Children</name>
	  <list type="bulleted" id="seclist5">
	    <item>
	      The first child of an item tag must be a <cnxn strength="8" target="question">question</cnxn> tag.
	      </item>
	    <item>
	      It may be followed by, in this order,
	    </item> 
	    <item>
	      One or more optional <cnxn strength="8" target="resource">resource</cnxn> tags; </item>
	    <item>
	      One or more optional <cnxn strength="8" target="answer">answer</cnxn> tags; </item>
	    <item>
	      One or more optional <cnxn strength="8" target="hint">hint</cnxn> tags; </item>
	    <item>
	      One optional <cnxn strength="8" target="feedback">feedback</cnxn> tag; </item>
	    <item>
	      And finally, one optional <cnxn strength="8" target="key">key</cnxn> tag.
	    </item>
	  </list>
	</section>

	<section id="itemex">
	  <name>Examples</name>
	  <code type="block">
	    <![CDATA[
	  <item id="item1" type="single-response">

	  <question> . . . </question>

	  <resource uri="http://www.bananas.com" />

	  <answer id="answer1"> . . . </answer>      

	  <answer id="answer2"> . . . </answer>

	  <hint> . . . </hint>

	  <feedback id='general'> . . . </feedback>

	  <key answer="answer2" />

	  </item>]]>
	  </code>
	</section>
      </section>

      <section id="question">
	<name>Question</name>
	<section id="quesdes">
	  <name>Description</name>
	  <para id="quesp1">
	    The question element contains the question being asked of
	    the learner in plain text or embedded markup.
	  </para>
	</section>
	<section id="quesatt">
	  <name>Attributes</name>
	  <para id="quesp2">
	    None.
	  </para>
	</section>
	
	<section id="queschild">
	  <name>Children</name>
	  <para id="quesp3">
	    A question tag may contain embedded markup (including
	    plain text).
	  </para>
	</section>
	
	<section id="quesex">
	  <name>Examples</name>
	  <code type="block">
	    <![CDATA[
	  <question>
	    How many XML programmers does it take to change a lightbulb?  
	  </question>]]>
	  </code>
	  
	</section>
      </section>

      <section id="resource">
	<name>Resource</name>
	<section id="resdes">
	  <name>Description</name>
	  <para id="resp1">
	    Contains a URI which is a pointer to external resources
	    relevant to the item (such as a dataset).
	  </para>
	</section>
	<section id="resatt">
	  <name>Attributes</name>
	  <list type="bulleted" id="reslist1">
	    <item>
	      URI
	      <list type="bulleted" id="reslist2">
		<item>Required</item>
		<item>The location of the resource file.</item>
	      </list>
	    </item>
	    <item>id - a unique identifier for the resource
	      <list type="bulleted" id="reslist3">
		<item>Optional</item>
	      </list>
	    </item>
	  </list>	
	</section>
	
	<section id="reschild">
	  <name>Children</name>
	  <para id="resp2">
	    The resource tag is an empty tag and has no children.
	  </para>
	</section>
	
	<section id="resex">
	  <name>Examples</name>
	  <code type="block">
	    <![CDATA[
	  <resource uri="www.lightbulb.com/dataset.txt" id="res1" />]]>
	  </code>
	  
	</section>
      </section>

      <section id="answer">
	<name>Answer</name>
	<section id="ansdes">
	  <name>Description</name>
	  <para id="par_ans1">
	    Contains the response options to a question.
	  </para>
	</section>
	
	<section id="ansattr">
	  <name>Attributes</name>
	  <list id="anslist1" type="bulleted">
	    <item>id
	      <list type="bulleted" id="anslist2">
		<item>
		  Recommended for single-response, multiple-response,
		  and ordered-response.  May not contain commas, as
		  commas are used to separate answer IDs when
		  referring to them in the key.
		</item>
		<item>
		  Optional for text-response.  May not contain commas
		  (see above).
		</item>
	      </list>
	    </item>
	  </list>
	</section>
	
	<section id="anschild">
	  <name>Children</name>
	  <para id="ansp1">
	    May contain zero or one <cnxn strength="8" target="response">response</cnxn> tags followed by 0, 1,
	    or 2 <cnxn strength="8" target="feedback">feedback</cnxn>
	    tags.  In the case of one response tag, it may only have
	    one feedback tag containing the feedback corresponding to
	    that response.  In the case of 0 response tags, it may
	    have 0 feedback tags, 1 feedback tags (feedback for either
	    a correct or incorrect answer) or 2 feedback tags
	    (feedback for a correct answer and feedback for an
	    incorrect answer).  (General feedback, supplied to the
	    user regardless of correctness or incorrectness of the
	    user's answer, goes in the general feedback tag, which
	    follows the hint tag.)
	  </para>
	</section>
	
	<section id="ansex">
	  <name>Examples</name>
	  <code type="block">
	    <![CDATA[
	  <answer id="vegetable">
	    
	  <response>A vegetable.</response>
	    
	  <feedback>No, don't be silly.</feedback>
	    
	  </answer>]]>
	    
	    <![CDATA[
	    
	  <answer>
	    
	  <feedback correct="no">No, don't be silly.</feedback>
	    
	  <feedback correct="yes">Yes, your answer was correct.</feedback>

	  </answer>]]>
	  </code>
	</section>
      </section>

      <section id="response">
	<name>Response</name>
	<section id="respdesc">
	  <name>Description</name>
	  <para id="respp1">
	    The response tag contains one of the response options for
	    the question.
	  </para>
	</section>
	<section id="respattr">
	  <name>Attributes</name>
	  <para id="respp2">
	    None.
	  </para>
	</section>
	
	<section id="respchild">
	  <name>Children</name>
	  <para id="respp3">
	    A response tag may contain embedded markup (including
	    plain text).
	  </para>
	</section>      
	<section id="respex">
	  <name>Examples</name>
	  <code type="block">
	    <![CDATA[
	  <response>2.314</response>]]>      
	  </code>
	</section>
      </section>

      <section id="feedback">
	<name>Feedback</name>
	<section id="feeddesc">
	  <name>Description</name>
	  <para id="feedp1">
	    The feedback tag within a response element contains
	    feedback specific to the accompanying response option (or
	    feedback specific to a correct or incorrect answer, if
	    there is no accompanying response option).  The feedback
	    tag in an item element follows the response and hint
	    elements and contains feedback to be shown to the user
	    regardless of his or her answer.
	  </para>
	</section>
	<section id="feedattr">
	  <name>Attributes</name>
	  <list id="feedlist1" type="bulleted">
	    <item>Correct
	      <list type="bulleted" id="feedlist3">
		<item>
		  Recommended for text-response items to determine
		  correct and incorrect answers (correct="yes"
		  vs. correct="no"), when feedback tag is contained
		  within a response.
		</item>
		<item>Optional for other item-types.</item>
		<item>
		  Optional when not contained within a response.</item>
	      </list>
	    </item>
	  </list>
	</section>
	
	<section id="feedchild">
	  <name>Children</name>
	  <para id="feedp3">
	    A feedback tag may contain embedded markup (including
	    plain text).
	  </para>
	</section>
	
	<section id="feedex">
	  <name>Examples</name>
	  <code type="block">
	    <![CDATA[
	  <feedback>Incorrect; bananas are not blue.</feedback>]]>      
	  </code>
	</section>
      </section>

      <section id="hint">
	<name>Hint</name>
	<section id="hintdesc">
	  <name>Description</name>
	  <para id="hintp1">
	    The hint tag contains a hint to be given to the user upon
	    request.
	  </para>
	</section>
	<section id="hintattr">
	  <name>Attributes</name>
	  <para id="hintp2">
	    None
	  </para>
	</section>
	
	<section id="hintchild">
	  <name>Children</name>
	  <para id="hintp3">
	    A hint tag may contain embedded markup (including plain
	    text).
	  </para>
	</section>
	
	<section id="hintex">
	  <name>Examples</name>
	  <code type="block">
	    <![CDATA[
	  <hint>Bananas are fruit.</hint>]]>      
	  </code>
	</section>
      </section>
      
      <section id="key">
	<name>Key</name>
	<section id="keydesc">
	  <name>Description</name>
	  <para id="keyp1">
	    The key tag contains the correct answer to an item.
	  </para>
	</section>
	<section id="keyattr">
	  <name>Attributes</name>
	  <list id="keylist1" type="bulleted">
	    <item>Answer.
	      <list id="keylist2" type="bulleted">
		<item>
		  Recommended for single-choice, multiple-choice, and
		  ordered-response types.
		  <list id="keylist3" type="bulleted">
		    <item>
		      Content corresponds to the id(s) of the correct
		      answer(s) for these response types.</item>
		  </list>
		</item>
		<item>Text-response uses embedded
		  markup rather than an attribute.</item>
	      </list>
	    </item>
	  </list>
	</section>
	
	<section id="keychild">
	  <name>Children</name>
	  <para id="keyp3">
	    A key tag may contain embedded markup (including plain
	    text) for text-response questions.
	  </para>
	</section>
	
	<section id="keyex">
	  <name>Examples</name>
	  <code type="block">
	    <![CDATA[
	  <key answer="a,b" />
	    
	  <key>Bananas are fruit.</key>]]>      
	  </code>

	</section>
      </section>
    </section>  

  </content>
</document>
