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->xmlStartTag(
"qtimetadatafield");
83 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"textrating");
84 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getTextRating());
85 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
86 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
87 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"correctanswers");
88 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getCorrectAnswers());
89 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
90 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
91 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"points");
92 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getPoints());
93 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
94 $a_xml_writer->xmlEndTag(
"qtimetadata");
95 $a_xml_writer->xmlEndTag(
"itemmetadata");
99 "label" => $this->object->getTitle()
101 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
103 $a_xml_writer->xmlStartTag(
"flow");
105 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
107 for ($counter = 1; $counter <= $this->
object->getCorrectAnswers(); $counter++)
110 "ident" =>
"TEXTSUBSET_" . sprintf(
"%02d", $counter),
111 "rcardinality" =>
"Single"
113 $a_xml_writer->xmlStartTag(
"response_str", $attrs);
114 $solution = $this->
object->getSuggestedSolution(0);
115 if (count($solution))
117 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
119 $a_xml_writer->xmlStartTag(
"material");
120 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
121 if (strcmp($matches[1],
"") != 0)
123 $intlink = $solution[
"internal_link"];
126 "label" =>
"suggested_solution"
128 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
129 $a_xml_writer->xmlEndTag(
"material");
134 "fibtype" =>
"String",
135 "columns" => $this->object->getMaxTextboxWidth()
137 $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
138 $a_xml_writer->xmlEndTag(
"render_fib");
139 $a_xml_writer->xmlEndTag(
"response_str");
142 $a_xml_writer->xmlEndTag(
"flow");
143 $a_xml_writer->xmlEndTag(
"presentation");
146 $a_xml_writer->xmlStartTag(
"resprocessing");
147 $a_xml_writer->xmlStartTag(
"outcomes");
148 $a_xml_writer->xmlStartTag(
"decvar");
149 $a_xml_writer->xmlEndTag(
"decvar");
151 "varname" =>
"matches",
154 $a_xml_writer->xmlElement(
"decvar", $attribs, NULL);
155 $a_xml_writer->xmlEndTag(
"outcomes");
157 for ($counter = 1; $counter <= $this->
object->getCorrectAnswers(); $counter++)
159 $scoregroups =& $this->
object->joinAnswers();
160 foreach ($scoregroups as $points => $scoreanswers)
165 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
167 $a_xml_writer->xmlStartTag(
"conditionvar");
169 "respident" =>
"TEXTSUBSET_" . sprintf(
"%02d", $counter)
171 $a_xml_writer->xmlElement(
"varsubset", $attrs, join(
",", $scoreanswers));
172 $a_xml_writer->xmlEndTag(
"conditionvar");
175 "varname" =>
"matches",
178 $a_xml_writer->xmlElement(
"setvar", $attrs, $points);
181 "feedbacktype" =>
"Response",
182 "linkrefid" =>
"Matches_" . sprintf(
"%02d", $counter)
184 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
185 $a_xml_writer->xmlEndTag(
"respcondition");
189 $feedback_allcorrect = $this->
object->getFeedbackGeneric(1);
190 $feedback_onenotcorrect = $this->
object->getFeedbackGeneric(0);
191 if (strlen($feedback_allcorrect . $feedback_onenotcorrect))
193 if (strlen($feedback_allcorrect))
198 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
200 $a_xml_writer->xmlStartTag(
"conditionvar");
202 "respident" =>
"points"
204 $a_xml_writer->xmlElement(
"varsubset", $attrs, $this->object->getMaximumPoints());
205 $a_xml_writer->xmlEndTag(
"conditionvar");
208 "feedbacktype" =>
"Response",
209 "linkrefid" =>
"response_allcorrect"
211 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
212 $a_xml_writer->xmlEndTag(
"respcondition");
215 if (strlen($feedback_onenotcorrect))
220 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
222 $a_xml_writer->xmlStartTag(
"conditionvar");
223 $a_xml_writer->xmlStartTag(
"not");
226 "respident" =>
"points"
228 $a_xml_writer->xmlElement(
"varsubset", $attrs, $this->object->getMaximumPoints());
230 $a_xml_writer->xmlEndTag(
"not");
231 $a_xml_writer->xmlEndTag(
"conditionvar");
234 "feedbacktype" =>
"Response",
235 "linkrefid" =>
"response_onenotcorrect"
237 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
238 $a_xml_writer->xmlEndTag(
"respcondition");
242 $a_xml_writer->xmlEndTag(
"resprocessing");
245 for ($counter = 1; $counter <= $this->
object->getCorrectAnswers(); $counter++)
248 "ident" =>
"Matches_" . sprintf(
"%02d", $counter),
251 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
253 $a_xml_writer->xmlStartTag(
"flow_mat");
254 $a_xml_writer->xmlStartTag(
"material");
255 $a_xml_writer->xmlElement(
"mattext");
256 $a_xml_writer->xmlEndTag(
"material");
257 $a_xml_writer->xmlEndTag(
"flow_mat");
258 $a_xml_writer->xmlEndTag(
"itemfeedback");
261 if (strlen($feedback_allcorrect))
264 "ident" =>
"response_allcorrect",
267 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
269 $a_xml_writer->xmlStartTag(
"flow_mat");
270 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
271 $a_xml_writer->xmlEndTag(
"flow_mat");
272 $a_xml_writer->xmlEndTag(
"itemfeedback");
274 if (strlen($feedback_onenotcorrect))
277 "ident" =>
"response_onenotcorrect",
280 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
282 $a_xml_writer->xmlStartTag(
"flow_mat");
283 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
284 $a_xml_writer->xmlEndTag(
"flow_mat");
285 $a_xml_writer->xmlEndTag(
"itemfeedback");
288 $a_xml_writer->xmlEndTag(
"item");
289 $a_xml_writer->xmlEndTag(
"questestinterop");
291 $xml = $a_xml_writer->xmlDumpMem(FALSE);
292 if (!$a_include_header)
294 $pos = strpos($xml,
"?>");
295 $xml = substr($xml, $pos + 2);