MapleTA - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Connectivity : Maple T.A. : MapleTA Package : MapleTA/QTI

MapleTA

  

QTI

  

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

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

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<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<questestinterop xmlns=\"http://www.imsglobal.org/xsd/ims_qtiasiv1p2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.imsglobal.org/xsd/ims_qtiasiv1p2 http://www.imsglobal.org/xsd/ims_qtiasiv1p2p1.xsd\">\n <assessment ident=\"ie2b5708bd9b993cd4ff222d257370d76\" title=\"Assessment two questions\">\n <qtimetadata>\n <qtimetadatafield>\n <fieldlabel>cc_maxattempts</fieldlabel>\n <fieldentry>1</fieldentry>\n </qtimetadatafield>\n </qtimetadata>\n <section ident=\"root_section\">\n <item ident=\"iad1ed6c3049afbc438c5d3d9ac61c128\" title=\"Question 1\">\n <itemmetadata>\n <qtimetadata>\n <qtimetadatafield>\n <fieldlabel>question_type</fieldlabel>\n <fieldentry>true_false_question</fieldentry>\n </qtimetadatafield>\n <qtimetadatafield>\n <fieldlabel>points_possible</fieldlabel>\n <fieldentry>65</fieldentry>\n </qtimetadatafield>\n <qtimetadatafield>\n <fieldlabel>assessment_question_identifierref</fieldlabel>\n <fieldentry>i6ee097beb103beaff86af09b13213ac5</fieldentry>\n </qtimetadatafield>\n </qtimetadata>\n </itemmetadata>\n <presentation>\n <material>\n <mattext texttype=\"text/html\"><div><p>It is better that students don’t understand why they are doing a task in order to increase learning and engagement.</p></div></mattext>\n </material>\n <response_lid ident=\"response1\" rcardinality=\"Single\">\n <render_choice>\n <response_label ident=\"1263\">\n <material>\n <mattext texttype=\"text/plain\">True</mattext>\n </material>\n </response_label>\n <response_label ident=\"4549\">\n <material>\n <mattext texttype=\"text/plain\">False</mattext>\n </material>\n </response_label>\n </render_choice>\n </response_lid>\n </presentation>\n <resprocessing>\n <outcomes>\n <decvar maxvalue=\"100\" minvalue=\"0\" varname=\"SCORE\" vartype=\"Decimal\"/>\n </outcomes>\n <respcondition continue=\"Yes\">\n <conditionvar>\n <varequal respident=\"response1\">1263</varequal>\n </conditionvar>\n <displayfeedback feedbacktype=\"Response\" linkrefid=\"1263_fb\"/>\n </respcondition>\n <respcondition continue=\"Yes\">\n <conditionvar>\n <varequal respident=\"response1\">4549</varequal>\n </conditionvar>\n <displayfeedback feedbacktype=\"Response\" linkrefid=\"4549_fb\"/>\n </respcondition>\n <respcondition continue=\"No\">\n <conditionvar>\n <varequal respident=\"response1\">4549</varequal>\n </conditionvar>\n <setvar action=\"Set\" varname=\"SCORE\">100</setvar>\n </respcondition>\n </resprocessing>\n <itemfeedback ident=\"1263_fb\">\n <flow_mat>\n <material>\n <mattext texttype=\"text/plain\">Students need to not only understand how to do the task, but why in order to communicate clearly what you expect as a teacher.</mattext>\n </material>\n </flow_mat>\n </itemfeedback>\n <itemfeedback ident=\"4549_fb\">\n <flow_mat>\n <material>\n <mattext texttype=\"text/plain\">Correct!</mattext>\n </material>\n </flow_mat>\n </itemfeedback>\n </item>\n <item ident=\"id32bf7b1a1120256d70ce313a3eb9399\" title=\"Question 2\">\n <itemmetadata>\n <qtimetadata>\n <qtimetadatafield>\n <fieldlabel>question_type</fieldlabel>\n <fieldentry>multiple_choice_question</fieldentry>\n </qtimetadatafield>\n <qtimetadatafield>\n <fieldlabel>points_possible</fieldlabel>\n <fieldentry>32</fieldentry>\n </qtimetadatafield>\n <qtimetadatafield>\n <fieldlabel>assessment_question_identifierref</fieldlabel>\n <fieldentry>i9a388ab718a7e71b2a62f810453b3136</fieldentry>\n </qtimetadatafield>\n </qtimetadata>\n </itemmetadata>\n <presentation>\n <material>\n <mattext texttype=\"text/html\"><div><p>What is one indication that you didn’t clearly state something?</p></div></mattext>\n </material>\n <response_lid ident=\"response1\" rcardinality=\"Single\">\n <render_choice>\n <response_label ident=\"6368\">\n <material>\n <mattext texttype=\"text/html\"><p>Students raise their hand for clarification.</p></mattext>\n </material>\n </response_label>\n <response_label ident=\"7824\">\n <material>\n <mattext texttype=\"text/html\"><p>Students start acting up.</p></mattext>\n </material>\n </response_label>\n <response_label ident=\"8330\">\n <material>\n <mattext texttype=\"text/html\"><p>Students start falling asleep.</p></mattext>\n </material>\n </response_label>\n </render_choice>\n </response_lid>\n </presentation>\n <resprocessing>\n <outcomes>\n <decvar maxvalue=\"100\" minvalue=\"0\" varname=\"SCORE\" vartype=\"Decimal\"/>\n </outcomes>\n <respcondition continue=\"Yes\">\n <conditionvar>\n <varequal respident=\"response1\">6368</varequal>\n </conditionvar>\n <displayfeedback feedbacktype=\"Response\" linkrefid=\"6368_fb\"/>\n </respcondition>\n <respcondition continue=\"Yes\">\n <conditionvar>\n <varequal respident=\"response1\">7824</varequal>\n </conditionvar>\n <displayfeedback feedbacktype=\"Response\" linkrefid=\"7824_fb\"/>\n </respcondition>\n <respcondition continue=\"Yes\">\n <conditionvar>\n <varequal respident=\"response1\">8330</varequal>\n </conditionvar>\n <displayfeedback feedbacktype=\"Response\" linkrefid=\"8330_fb\"/>\n </respcondition>\n <respcondition continue=\"No\">\n <conditionvar>\n <varequal respident=\"response1\">6368</varequal>\n </conditionvar>\n <setvar action=\"Set\" varname=\"SCORE\">100</setvar>\n </respcondition>\n </resprocessing>\n <itemfeedback ident=\"6368_fb\">\n <flow_mat>\n <material>\n <mattext texttype=\"text/plain\">Correct!</mattext>\n </material>\n </flow_mat>\n </itemfeedback>\n <itemfeedback ident=\"7824_fb\">\n <flow_mat>\n <material>\n <mattext texttype=\"text/plain\">Incorrect!</mattext>\n </material>\n </flow_mat>\n </itemfeedback>\n <itemfeedback ident=\"8330_fb\">\n <flow_mat>\n <material>\n <mattext texttype=\"text/plain\">Incorrect!</mattext>\n </material>\n </flow_mat>\n </itemfeedback>\n </item>\n <item ident=\"id3ed43047be407ac5af1815932fb93b8\" title=\"Question 3\">\n <itemmetadata>\n <qtimetadata>\n <qtimetadatafield>\n <fieldlabel>question_type</fieldlabel>\n <fieldentry>true_false_question</fieldentry>\n </qtimetadatafield>\n <qtimetadatafield>\n <fieldlabel>points_possible</fieldlabel>\n <fieldentry>87</fieldentry>\n </qtimetadatafield>\n <qtimetadatafield>\n <fieldlabel>assessment_question_identifierref</fieldlabel>\n <fieldentry>iffea1d31f6c8f8cf291f2ecce0f364cc</fieldentry>\n </qtimetadatafield>\n </qtimetadata>\n </itemmetadata>\n <presentation>\n <material>\n <mattext texttype=\"text/html\"><div><p>Are there times when the educator will not want to convey the day’s learning objective?</p></div></mattext>\n </material>\n <response_lid ident=\"response1\" rcardinality=\"Single\">\n <render_choice>\n <response_label ident=\"9170\">\n <material>\n <mattext texttype=\"text/plain\">True</mattext>\n </material>\n </response_label>\n <response_label ident=\"2582\">\n <material>\n <mattext texttype=\"text/plain\">False</mattext>\n </material>\n </response_label>\n </render_choice>\n </response_lid>\n </presentation>\n <resprocessing>\n <outcomes>\n <decvar maxvalue=\"100\" minvalue=\"0\" varname=\"SCORE\" vartype=\"Decimal\"/>\n </outcomes>\n <respcondition continue=\"Yes\">\n <conditionvar>\n <varequal respident=\"response1\">9170</varequal>\n </conditionvar>\n <displayfeedback feedbacktype=\"Response\" linkrefid=\"9170_fb\"/>\n </respcondition>\n <respcondition continue=\"Yes\">\n <conditionvar>\n <varequal respident=\"response1\">2582</varequal>\n </conditionvar>\n <displayfeedback feedbacktype=\"Response\" linkrefid=\"2582_fb\"/>\n </respcondition>\n <respcondition continue=\"No\">\n <conditionvar>\n <varequal respident=\"response1\">9170</varequal>\n </conditionvar>\n <setvar action=\"Set\" varname=\"SCORE\">100</setvar>\n </respcondition>\n </resprocessing>\n <itemfeedback ident=\"9170_fb\">\n <flow_mat>\n <material>\n <mattext texttype=\"text/plain\">Correct!</mattext>\n </material>\n </flow_mat>\n </itemfeedback>\n <itemfeedback ident=\"2582_fb\">\n <flow_mat>\n <material>\n <mattext texttype=\"text/plain\">Incorrect!</mattext>\n </material>\n </flow_mat>\n </itemfeedback>\n </item>\n </section>\n </assessment>\n</questestinterop>&colon;

xmldoc is defined in the collapsed section above

qtifileFileTools:-TemporaryFile&colon;

FileTools:-Text:-WriteFileqtifile&comma;xmldoc

MapleTA:-QTIqtifile&comma;outfile=coursemodule.zip

The following example shows a preprocessor procedure that operates on <math> 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

MapleTA:-QTIyour_questions.xml&comma;preprocess=prep

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("<tr (bgcolor=[\"#0-9a-f]+)>" = "<tr class=\"mplqtitr\" \\1>",r);
         r := StringTools:-RegSubs("<tr (valign=[\"a-zA-Z]+ bgcolor=[\"#0-9a-f]+)>" = "<tr class=\"mplqtitr\" \\1>",r);
         r := StringTools:-RegSubs("<tr (bgcolor=[\"#0-9a-f]+ valign=[\"a-zA-Z]+)>" = "<tr class=\"mplqtitr\" \\1>",r);
         r := StringTools:-RegSubs("(<font color=)\"([#0-9a-f]+)\"><b>" = "\\1\"\\2\"><b style=\"color:\\2\">",r);

         if r <> text then
             css := "<style type=\"text/css\">\ntable {\n border-collapse: collapse;\n}\n .mplqtitr td b { color: #404040;}\n </style>\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

MapleTA:-QTIyour_questions2.xml&comma;postprocess=postp

Compatibility

• 

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

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

See Also

MapleTA