39 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false): string
43 $ilUser = $DIC[
'ilUser'];
44 $ilias = $DIC[
'ilias'];
48 $a_xml_writer->xmlHeader();
49 $a_xml_writer->xmlStartTag(
"questestinterop");
52 "title" => $this->
object->getTitle(),
53 "maxattempts" => $this->
object->getNrOfTries()
55 $a_xml_writer->xmlStartTag(
"item", $attrs);
57 $a_xml_writer->xmlElement(
"qticomment", null, $this->
object->getComment());
58 $a_xml_writer->xmlStartTag(
"itemmetadata");
59 $a_xml_writer->xmlStartTag(
"qtimetadata");
60 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
61 $a_xml_writer->xmlElement(
"fieldlabel", null,
"ILIAS_VERSION");
62 $a_xml_writer->xmlElement(
"fieldentry", null, $ilias->getSetting(
"ilias_version"));
63 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
64 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
65 $a_xml_writer->xmlElement(
"fieldlabel", null,
"QUESTIONTYPE");
67 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
68 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
69 $a_xml_writer->xmlElement(
"fieldlabel", null,
"AUTHOR");
70 $a_xml_writer->xmlElement(
"fieldentry", null, $this->
object->getAuthor());
71 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
77 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
78 $a_xml_writer->xmlElement(
"fieldlabel", null,
"thumb_geometry");
79 $a_xml_writer->xmlElement(
"fieldentry", null, $this->
object->getThumbSize());
80 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
81 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
82 $a_xml_writer->xmlElement(
"fieldlabel", null,
"element_height");
83 $a_xml_writer->xmlElement(
"fieldentry", null, $this->
object->getElementHeight());
84 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
85 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
86 $a_xml_writer->xmlElement(
"fieldlabel", null,
"points");
87 $a_xml_writer->xmlElement(
"fieldentry", null, $this->
object->getPoints());
88 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
89 $a_xml_writer->xmlEndTag(
"qtimetadata");
90 $a_xml_writer->xmlEndTag(
"itemmetadata");
94 "label" => $this->
object->getTitle()
96 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
98 $a_xml_writer->xmlStartTag(
"flow");
105 $ordering_type =
'OQP';
107 $ordering_type =
'OQNP';
109 $ordering_type =
'OQNT';
111 $ordering_type =
'OQT';
115 "ident" => $ordering_type,
116 "rcardinality" =>
"Ordered" 119 $attrs[
"output"] =
"javascript";
120 $a_xml_writer->xmlStartTag(
"response_lid", $attrs);
124 if ($this->
object->getShuffle()) {
133 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
136 foreach ($this->
object->getOrderingElementList() as $element) {
138 'ident' => $element->getExportIdent()
140 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
143 $imagetype =
"image/jpeg";
145 $a_xml_writer->xmlStartTag(
"material");
146 if ($force_image_references) {
148 "imagtype" => $imagetype,
149 "label" => $element->getContent(),
150 "uri" => $this->
object->getImagePathWeb() . $element->getContent()
152 $a_xml_writer->xmlElement(
"matimage", $attrs);
154 $imagepath = $this->
object->getImagePath() . $element->getContent();
155 if (file_exists($imagepath) && is_file($imagepath)) {
156 $fh = @fopen($imagepath,
"rb");
158 $imagefile = fread($fh, filesize($imagepath));
160 $base64 = base64_encode($imagefile);
162 if (preg_match(
"/.*\.(png|gif)$/", $element->getContent(), $matches)) {
163 $imagetype =
"image/" . $matches[1];
166 "imagtype" => $imagetype,
167 "label" => $element->getContent(),
168 "embedded" =>
"base64" 170 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
174 $a_xml_writer->xmlEndTag(
"material");
177 $a_xml_writer->xmlStartTag(
"material");
178 $this->
addQTIMaterial($a_xml_writer, $element->getContent(),
true,
false);
179 $a_xml_writer->xmlEndTag(
"material");
180 $a_xml_writer->xmlStartTag(
"material");
181 $attrs = array(
"label" =>
"answerdepth");
182 $a_xml_writer->xmlElement(
"mattext", $attrs, $element->getIndentation());
183 $a_xml_writer->xmlEndTag(
"material");
185 $a_xml_writer->xmlEndTag(
"response_label");
187 $a_xml_writer->xmlEndTag(
"render_choice");
188 $a_xml_writer->xmlEndTag(
"response_lid");
189 $a_xml_writer->xmlEndTag(
"flow");
190 $a_xml_writer->xmlEndTag(
"presentation");
193 $a_xml_writer->xmlStartTag(
"resprocessing");
194 $a_xml_writer->xmlStartTag(
"outcomes");
195 $a_xml_writer->xmlStartTag(
"decvar");
196 $a_xml_writer->xmlEndTag(
"decvar");
197 $a_xml_writer->xmlEndTag(
"outcomes");
199 foreach ($this->
object->getOrderingElementList() as $element) {
203 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
205 $a_xml_writer->xmlStartTag(
"conditionvar");
209 $ordering_type =
'OQP';
211 $ordering_type =
'OQNP';
213 $ordering_type =
'OQNT';
215 $ordering_type =
'OQT';
218 $attrs = array(
"respident" => $ordering_type);
220 $attrs[
"index"] = $element->getPosition();
221 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
222 $a_xml_writer->xmlEndTag(
"conditionvar");
227 $points = $this->
object->getPoints() / $this->
object->getOrderingElementList()->countElements();
228 $a_xml_writer->xmlElement(
"setvar", $attrs, $points);
231 "feedbacktype" =>
"Response",
232 "linkrefid" =>
"link_" . $element->getPosition()
234 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
235 $a_xml_writer->xmlEndTag(
"respcondition");
238 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
242 if (strlen($feedback_allcorrect)) {
246 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
248 $a_xml_writer->xmlStartTag(
"conditionvar");
250 foreach ($this->
object->getOrderingElementList() as $element) {
254 $ordering_type =
'OQP';
256 $ordering_type =
'OQNP';
258 $ordering_type =
'OQNT';
260 $ordering_type =
'OQT';
263 $attrs = array(
"respident" => $ordering_type);
265 $attrs[
"index"] = $element->getPosition();
266 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
269 $a_xml_writer->xmlEndTag(
"conditionvar");
272 "feedbacktype" =>
"Response",
273 "linkrefid" =>
"response_allcorrect" 275 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
276 $a_xml_writer->xmlEndTag(
"respcondition");
279 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
283 if (strlen($feedback_onenotcorrect)) {
287 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
289 $a_xml_writer->xmlStartTag(
"conditionvar");
290 $a_xml_writer->xmlStartTag(
"not");
292 foreach ($this->
object->getOrderingElementList() as $element) {
295 $ordering_type =
'OQP';
297 $ordering_type =
'OQNP';
299 $ordering_type =
'OQNT';
301 $ordering_type =
'OQT';
304 $attrs = array(
"respident" => $ordering_type);
306 $attrs[
"index"] = $element->getPosition();
307 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
310 $a_xml_writer->xmlEndTag(
"not");
311 $a_xml_writer->xmlEndTag(
"conditionvar");
314 "feedbacktype" =>
"Response",
315 "linkrefid" =>
"response_onenotcorrect" 317 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
318 $a_xml_writer->xmlEndTag(
"respcondition");
321 $a_xml_writer->xmlEndTag(
"resprocessing");
324 foreach ($this->
object->getOrderingElementList() as $element) {
326 "ident" =>
"link_" . $element->getPosition(),
329 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
331 $a_xml_writer->xmlStartTag(
"flow_mat");
332 $a_xml_writer->xmlStartTag(
"material");
333 $a_xml_writer->xmlElement(
"mattext", null, $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
334 $this->object->getId(),
336 $element->getPosition()
338 $a_xml_writer->xmlEndTag(
"material");
339 $a_xml_writer->xmlEndTag(
"flow_mat");
340 $a_xml_writer->xmlEndTag(
"itemfeedback");
343 if (strlen($feedback_allcorrect)) {
345 "ident" =>
"response_allcorrect",
348 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
350 $a_xml_writer->xmlStartTag(
"flow_mat");
352 $a_xml_writer->xmlEndTag(
"flow_mat");
353 $a_xml_writer->xmlEndTag(
"itemfeedback");
355 if (strlen($feedback_onenotcorrect)) {
357 "ident" =>
"response_onenotcorrect",
360 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
362 $a_xml_writer->xmlStartTag(
"flow_mat");
364 $a_xml_writer->xmlEndTag(
"flow_mat");
365 $a_xml_writer->xmlEndTag(
"itemfeedback");
370 $a_xml_writer->xmlEndTag(
"item");
371 $a_xml_writer->xmlEndTag(
"questestinterop");
373 $xml = $a_xml_writer->xmlDumpMem(
false);
374 if (!$a_include_header) {
375 $pos = strpos($xml,
"?>");
376 $xml = substr($xml, $pos + 2);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addQTIMaterial(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
const OQ_PICTURES
Ordering question constants.
const ORDERING_QUESTION_IDENTIFIER
toXML($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
Returns a QTI xml representation of the question Returns a QTI xml representation of the question and...
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
addSuggestedSolution(ilXmlWriter $writer)
addSolutionHints(ilXmlWriter $writer)