QTI - Maple Help

MapleTA

 QTI
 create a Maple T.A. course module from a QTI file

 Calling Sequence QTI(filename, opts)

Parameters

 filename - string or list of strings opts - (optional) equations of the form option=value; specify options for the QTI command

Options

 • resourcedir = string (default is NULL)
 • preprocess = table (default is table())
 • postprocess = table (default is table())
 • verbose = true or false (default is false)
 • id = string
 • cmname = string (default is "mplqti_import")
 • cmdescription = string (default is "External Conversion")
 • outfile = string (default is "cm.zip")
 • overwrite = true or false (default is false)
 • groupname = string
 • output = filename or raw (default is filename)

Description

 • The QTI command converts IMS Question & Test Interoperability (QTI) files into Maple T.A./Mobius course modules.
 • Only a portion of the QTI 1.2 specification is supported by this command.  Some optional mechanisms are provided in order for users to extend the capabilities of this command.
 • The input filename can be the name of a file, the name of a directory, or a list of files and directories.  All files that match the supported QTI XML structure are converted into Maple T.A. questions and packaged in a course module.  Files in the directory that are obviously not XML, or do not have top-level XML elements matching one of assessment, item, or section are ignored.  This allows easy import of an entire directory with mixed QTI and resource files.
 • The preprocess option allows you to specify element handlers for preprocessing specific XML entities.  You must provide a table of handlers, with each entry in the table being of the form "string" = procedure(record,string).  Before processing an element matching the table index, the handler procedure is called, which can modify the given record.  The return value is used instead of the original record to continue processing.  A pair of return values can be returned of type (record,string), in which case the second return value indicates the element should be processed as a new entity type. Preprocessing is only invoked on certain subelements of item, presentation, and equivalent elements.
 • The postprocess option allows you to specify element handlers for postprocessing specific XML entities.  You must provide a table of handlers, with each entry in the table being of the form "string" = procedure(string,string). After processing an element matching the table index, the handler procedure is called, which can modify the given string.  The return value is used instead of the original output to continue processing.  The first argument of the handler is the processed XML as a string (not a record).  The second argument to the handler is the name of the element. Postprocessing is only invoked on certain subelements of item, presentation, and equivalent elements.
 • If the verbose option is set to true, the command outputs additional processing information.
 • The id option allows you to specify the unique identifier to be stored as part of the question.  When importing the course module into Maple T.A., questions that match this id will be overwritten with the new question. It is useful to specify the id when the generation/import process will be repeated multiple times.  When processing multiple files, id can be supplied as a prefix, to which a count will be added to each subsequent question. If no id is provided this commands attempts to find id or ident attributes in the XML, and failing that produces a random id.  The id is a 32-character alphanumeric string.  Longer strings will be truncated, and shorter ones padded out.
 • The cmname option specifies the course module name.  The default is "mplqti_import".
 • The cmdescription option specifies a brief description for the course module.  The default is "External Conversion".
 • The outfile option lets you specify the name of the output file.  The default is "cm.zip".
 • The overwrite=true option is needed if outfile already exists; otherwise an error will be raised.
 • The resourcedir option lets you specify a path to resource files.  Currently this is only used for locating an external Maple library for interval questions when related commands are detected in the question source.
 • If the groupname option is specified, the Maple T.A. questions are put in a group of the given name.
 • If output = raw is specified, this command returns an array of nested records containing the course module's manifest.xml information.

Examples

Sample QTI XML

 • Sample source from https://raw.githubusercontent.com/lumenlearning/OpenAssessments/master/spec/fixtures/assessment2.xml
 >

xmldoc is defined in the collapsed section above

 > $\mathrm{qtifile}≔\mathrm{FileTools}:-\mathrm{TemporaryFile}\left(\right):$
 > $\mathrm{FileTools}:-\mathrm{Text}:-\mathrm{WriteFile}\left(\mathrm{qtifile},\mathrm{xmldoc}\right)$
 > $\mathrm{MapleTA}:-\mathrm{QTI}\left(\mathrm{qtifile},'\mathrm{outfile}'="coursemodule.zip"\right)$

The following example shows a preprocessor procedure that operates on [itex] structures (MathML expressions) to turn block-centered math to inline math.

 > prep := table({     "math" = proc(elem,action)          if member(_attributes,elem) and member(display,elem:-_attributes)             and elem:-_attributes:-display = "block"          then               #printf("here: %s\n",action);               elem:-_attributes:-display := "inline";          fi;          elem;      end }):

Note: you will need to supply your own QTI file in order to run this example

 > $\mathrm{MapleTA}:-\mathrm{QTI}\left("your_questions.xml",'\mathrm{preprocess}'=\mathrm{prep}\right)$

The following example shows a post-processor procedure that operates on <presentation> structures to add some CSS styling and redefine deprecated html bgcolor attributes.

 > postp := table({     "presentation" = proc(text,action)          local r, css;          r := text;          # color fixes for old html          r := StringTools:-RegSubs("
" = "",r);          r := StringTools:-RegSubs("" = "",r);          r := StringTools:-RegSubs("" = "",r);          r := StringTools:-RegSubs("(" = "\\1\"\\2\">",r);          if r <> text then              css := "\n\n";              if StringTools:-Search(css,r) = 0 then                  r := cat(css,r);              fi;          fi;          r;      end });

Note: you will need to supply your own QTI file in order to run this example

 > $\mathrm{MapleTA}:-\mathrm{QTI}\left("your_questions2.xml",'\mathrm{postprocess}'=\mathrm{postp}\right)$

Compatibility

 • The MapleTA[QTI] command was introduced in Maple 2018.