24 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
46 function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
50 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
54 $a_xml_writer->xmlStartTag(
"questestinterop");
56 "ident" =>
"il_".IL_INST_ID.
"_qst_".$this->object->getId(),
57 "title" => $this->
object->getTitle(),
58 "maxattempts" => $this->
object->getNrOfTries()
60 $a_xml_writer->xmlStartTag(
"item", $attrs);
62 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->object->getComment());
64 $workingtime = $this->
object->getEstimatedWorkingTime();
65 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
66 $a_xml_writer->xmlElement(
"duration", NULL, $duration);
68 $a_xml_writer->xmlStartTag(
"itemmetadata");
69 $a_xml_writer->xmlStartTag(
"qtimetadata");
70 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
71 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
72 $a_xml_writer->xmlElement(
"fieldentry", NULL, $ilias->getSetting(
"ilias_version"));
73 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
74 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
75 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"QUESTIONTYPE");
77 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
78 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
79 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"AUTHOR");
80 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getAuthor());
81 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
82 $a_xml_writer->xmlEndTag(
"qtimetadata");
83 $a_xml_writer->xmlEndTag(
"itemmetadata");
87 "label" => $this->object->getTitle()
89 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
91 $a_xml_writer->xmlStartTag(
"flow");
93 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
97 "rcardinality" =>
"Single",
98 "numtype" =>
"Decimal"
100 $a_xml_writer->xmlStartTag(
"response_num", $attrs);
101 $solution = $this->
object->getSuggestedSolution(0);
102 if (count($solution))
104 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
106 $a_xml_writer->xmlStartTag(
"material");
107 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
108 if (strcmp($matches[1],
"") != 0)
110 $intlink = $solution[
"internal_link"];
113 "label" =>
"suggested_solution"
115 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
116 $a_xml_writer->xmlEndTag(
"material");
121 "fibtype" =>
"Decimal",
122 "maxchars" => $this->object->getMaxChars()
124 $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
125 $a_xml_writer->xmlEndTag(
"render_fib");
126 $a_xml_writer->xmlEndTag(
"response_num");
127 $a_xml_writer->xmlEndTag(
"flow");
128 $a_xml_writer->xmlEndTag(
"presentation");
131 $a_xml_writer->xmlStartTag(
"resprocessing");
132 $a_xml_writer->xmlStartTag(
"outcomes");
133 $a_xml_writer->xmlStartTag(
"decvar");
134 $a_xml_writer->xmlEndTag(
"decvar");
135 $a_xml_writer->xmlEndTag(
"outcomes");
137 $a_xml_writer->xmlStartTag(
"respcondition");
139 $a_xml_writer->xmlStartTag(
"conditionvar");
143 $a_xml_writer->xmlElement(
"vargte", $attrs, $this->object->getLowerLimit());
144 $a_xml_writer->xmlElement(
"varlte", $attrs, $this->object->getUpperLimit());
145 $a_xml_writer->xmlEndTag(
"conditionvar");
150 $a_xml_writer->xmlElement(
"setvar", $attrs, $this->object->getPoints());
153 "feedbacktype" =>
"Response",
154 "linkrefid" =>
"Correct"
156 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
157 $a_xml_writer->xmlEndTag(
"respcondition");
159 $feedback_allcorrect = $this->
object->getFeedbackGeneric(1);
160 if (strlen($feedback_allcorrect))
165 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
167 $a_xml_writer->xmlStartTag(
"conditionvar");
171 $a_xml_writer->xmlElement(
"vargte", $attrs, $this->object->getLowerLimit());
172 $a_xml_writer->xmlElement(
"varlte", $attrs, $this->object->getUpperLimit());
173 $a_xml_writer->xmlEndTag(
"conditionvar");
176 "feedbacktype" =>
"Response",
177 "linkrefid" =>
"response_allcorrect"
179 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
180 $a_xml_writer->xmlEndTag(
"respcondition");
183 $feedback_onenotcorrect = $this->
object->getFeedbackGeneric(0);
184 if (strlen($feedback_onenotcorrect))
189 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
191 $a_xml_writer->xmlStartTag(
"conditionvar");
192 $a_xml_writer->xmlStartTag(
"not");
196 $a_xml_writer->xmlElement(
"vargte", $attrs, $this->object->getLowerLimit());
197 $a_xml_writer->xmlElement(
"varlte", $attrs, $this->object->getUpperLimit());
198 $a_xml_writer->xmlEndTag(
"not");
199 $a_xml_writer->xmlEndTag(
"conditionvar");
202 "feedbacktype" =>
"Response",
203 "linkrefid" =>
"response_onenotcorrect"
205 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
206 $a_xml_writer->xmlEndTag(
"respcondition");
209 $a_xml_writer->xmlEndTag(
"resprocessing");
213 "ident" =>
"Correct",
216 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
218 $a_xml_writer->xmlStartTag(
"flow_mat");
219 $a_xml_writer->xmlStartTag(
"material");
220 $a_xml_writer->xmlElement(
"mattext");
221 $a_xml_writer->xmlEndTag(
"material");
222 $a_xml_writer->xmlEndTag(
"flow_mat");
223 $a_xml_writer->xmlEndTag(
"itemfeedback");
224 if (strlen($feedback_allcorrect))
227 "ident" =>
"response_allcorrect",
230 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
232 $a_xml_writer->xmlStartTag(
"flow_mat");
233 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
234 $a_xml_writer->xmlEndTag(
"flow_mat");
235 $a_xml_writer->xmlEndTag(
"itemfeedback");
237 if (strlen($feedback_onenotcorrect))
240 "ident" =>
"response_onenotcorrect",
243 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
245 $a_xml_writer->xmlStartTag(
"flow_mat");
246 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
247 $a_xml_writer->xmlEndTag(
"flow_mat");
248 $a_xml_writer->xmlEndTag(
"itemfeedback");
251 $a_xml_writer->xmlEndTag(
"item");
252 $a_xml_writer->xmlEndTag(
"questestinterop");
254 $xml = $a_xml_writer->xmlDumpMem(FALSE);
255 if (!$a_include_header)
257 $pos = strpos($xml,
"?>");
258 $xml = substr($xml, $pos + 2);