4 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
26 function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
30 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
34 $a_xml_writer->xmlStartTag(
"questestinterop");
36 "ident" =>
"il_".IL_INST_ID.
"_qst_".$this->object->getId(),
37 "title" => $this->
object->getTitle(),
38 "maxattempts" => $this->
object->getNrOfTries()
40 $a_xml_writer->xmlStartTag(
"item", $attrs);
42 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->
object->getComment());
44 $workingtime = $this->
object->getEstimatedWorkingTime();
45 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
46 $a_xml_writer->xmlElement(
"duration", NULL,
$duration);
48 $a_xml_writer->xmlStartTag(
"itemmetadata");
49 $a_xml_writer->xmlStartTag(
"qtimetadata");
50 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
51 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
52 $a_xml_writer->xmlElement(
"fieldentry", NULL, $ilias->getSetting(
"ilias_version"));
53 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
54 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
55 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"QUESTIONTYPE");
57 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
58 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
59 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"IS_MULTIPLE_CHOICE");
60 $a_xml_writer->xmlElement(
"fieldentry", NULL, ($this->
object->getIsMultipleChoice())?
"1":
"0" );
61 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
62 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
63 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"AUTHOR");
64 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getAuthor());
65 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
71 $a_xml_writer->xmlEndTag(
"qtimetadata");
72 $a_xml_writer->xmlEndTag(
"itemmetadata");
76 "label" => $this->
object->getTitle()
78 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
80 $a_xml_writer->xmlStartTag(
"flow");
82 $this->
object->addQTIMaterial($a_xml_writer, $this->
object->getQuestion());
86 "rcardinality" =>
"Single" 88 $a_xml_writer->xmlStartTag(
"response_xy", $attrs);
89 $solution = $this->
object->getSuggestedSolution(0);
92 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
94 $a_xml_writer->xmlStartTag(
"material");
95 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
96 if (strcmp($matches[1],
"") != 0)
98 $intlink = $solution[
"internal_link"];
101 "label" =>
"suggested_solution" 103 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
104 $a_xml_writer->xmlEndTag(
"material");
107 $a_xml_writer->xmlStartTag(
"render_hotspot");
108 $a_xml_writer->xmlStartTag(
"material");
109 $imagetype =
"image/jpeg";
110 if (preg_match(
"/.*\.(png|gif)$/i", $this->
object->getImageFilename(), $matches))
112 $imagetype =
"image/" . strtolower($matches[1]);
115 "imagtype" => $imagetype,
116 "label" => $this->
object->getImageFilename()
118 if ($a_include_binary)
120 if ($force_image_references)
122 $attrs[
"uri"] = $this->
object->getImagePathWeb() . $this->
object->getImageFilename();
123 $a_xml_writer->xmlElement(
"matimage", $attrs);
127 $attrs[
"embedded"] =
"base64";
128 $imagepath = $this->
object->getImagePath() . $this->
object->getImageFilename();
129 $fh = fopen($imagepath,
"rb");
133 $ilErr->raiseError(
$GLOBALS[
'lng']->txt(
"error_open_image_file"), $ilErr->MESSAGE);
136 $imagefile = fread(
$fh, filesize($imagepath));
138 $base64 = base64_encode($imagefile);
139 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, FALSE, FALSE);
144 $a_xml_writer->xmlElement(
"matimage", $attrs);
146 $a_xml_writer->xmlEndTag(
"material");
149 foreach ($this->
object->getAnswers() as $index => $answer)
152 switch ($answer->getArea())
155 $rarea =
"Rectangle";
168 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
169 $a_xml_writer->xmlData($answer->getCoords());
170 $a_xml_writer->xmlStartTag(
"material");
171 $a_xml_writer->xmlElement(
"mattext", NULL, $answer->getAnswertext());
172 $a_xml_writer->xmlEndTag(
"material");
173 $a_xml_writer->xmlEndTag(
"response_label");
175 $a_xml_writer->xmlEndTag(
"render_hotspot");
176 $a_xml_writer->xmlEndTag(
"response_xy");
177 $a_xml_writer->xmlEndTag(
"flow");
178 $a_xml_writer->xmlEndTag(
"presentation");
181 $a_xml_writer->xmlStartTag(
"resprocessing");
182 $a_xml_writer->xmlStartTag(
"outcomes");
183 $a_xml_writer->xmlStartTag(
"decvar");
184 $a_xml_writer->xmlEndTag(
"decvar");
185 $a_xml_writer->xmlEndTag(
"outcomes");
187 foreach ($this->
object->getAnswers() as $index => $answer)
192 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
194 $a_xml_writer->xmlStartTag(
"conditionvar");
195 if (!$answer->isStateSet())
197 $a_xml_writer->xmlStartTag(
"not");
200 switch ($answer->getArea())
203 $areatype =
"Rectangle";
206 $areatype =
"Ellipse";
209 $areatype =
"Bounded";
214 "areatype" => $areatype
216 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getCoords());
217 if (!$answer->isStateSet())
219 $a_xml_writer->xmlEndTag(
"not");
221 $a_xml_writer->xmlEndTag(
"conditionvar");
226 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
227 $linkrefid =
"response_$index";
229 "feedbacktype" =>
"Response",
230 "linkrefid" => $linkrefid
232 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
233 $a_xml_writer->xmlEndTag(
"respcondition");
237 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
239 $a_xml_writer->xmlStartTag(
"conditionvar");
243 $a_xml_writer->xmlStartTag(
"not");
244 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getCoords());
245 $a_xml_writer->xmlEndTag(
"not");
246 $a_xml_writer->xmlEndTag(
"conditionvar");
251 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPointsUnchecked());
252 $a_xml_writer->xmlEndTag(
"respcondition");
255 $answers = $this->
object->getAnswers();
256 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
257 $this->
object->getId(), true
259 if (strlen($feedback_allcorrect))
264 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
266 $a_xml_writer->xmlStartTag(
"conditionvar");
267 if(!$this->
object->getIsMultipleChoice())
271 foreach ($answers as $index => $answer)
273 if ($answer->getPoints() > $maxpoints)
275 $maxpoints = $answer->getPoints();
284 $answer = $answers[$bestindex];
285 switch ($answer->getArea())
288 $areatype =
"Rectangle";
291 $areatype =
"Ellipse";
294 $areatype =
"Bounded";
299 "areatype" => $areatype
301 $a_xml_writer->xmlElement(
"varinside", $attrs, $answer->getCoords());
305 foreach ($answers as $index => $answer)
307 if ($answer->getPoints() < $answer->getPointsUnchecked())
309 $a_xml_writer->xmlStartTag(
"not");
311 switch ($answer->getArea())
314 $areatype =
"Rectangle";
317 $areatype =
"Ellipse";
320 $areatype =
"Bounded";
325 "areatype" => $areatype
327 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
328 if ($answer->getPoints() < $answer->getPointsUnchecked())
330 $a_xml_writer->xmlEndTag(
"not");
335 $a_xml_writer->xmlEndTag(
"conditionvar");
338 "feedbacktype" =>
"Response",
339 "linkrefid" =>
"response_allcorrect" 341 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
342 $a_xml_writer->xmlEndTag(
"respcondition");
345 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
346 $this->
object->getId(), false
348 if (strlen($feedback_onenotcorrect))
353 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
355 $a_xml_writer->xmlStartTag(
"conditionvar");
356 if(!$this->
object->getIsMultipleChoice())
360 foreach ($answers as $index => $answer)
362 if ($answer->getPoints() > $maxpoints)
364 $maxpoints = $answer->getPoints();
371 $a_xml_writer->xmlStartTag(
"not");
374 $answer = $answers[$bestindex];
375 switch ($answer->getArea())
378 $areatype =
"Rectangle";
381 $areatype =
"Ellipse";
384 $areatype =
"Bounded";
389 "areatype" => $areatype
391 $a_xml_writer->xmlElement(
"varinside", $attrs, $answer->getCoords());
393 $a_xml_writer->xmlEndTag(
"not");
397 foreach ($answers as $index => $answer)
401 $a_xml_writer->xmlStartTag(
"or");
403 if ($answer->getPoints() >= $answer->getPointsUnchecked())
405 $a_xml_writer->xmlStartTag(
"not");
407 switch ($answer->getArea())
410 $areatype =
"Rectangle";
413 $areatype =
"Ellipse";
416 $areatype =
"Bounded";
421 "areatype" => $areatype
423 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
424 if ($answer->getPoints() >= $answer->getPointsUnchecked())
426 $a_xml_writer->xmlEndTag(
"not");
430 $a_xml_writer->xmlEndTag(
"or");
434 $a_xml_writer->xmlEndTag(
"conditionvar");
437 "feedbacktype" =>
"Response",
438 "linkrefid" =>
"response_onenotcorrect" 440 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
441 $a_xml_writer->xmlEndTag(
"respcondition");
444 $a_xml_writer->xmlEndTag(
"resprocessing");
447 foreach ($this->
object->getAnswers() as $index => $answer)
450 $linkrefid =
"response_$index";
452 "ident" => $linkrefid,
455 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
457 $a_xml_writer->xmlStartTag(
"flow_mat");
458 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
459 $this->
object->getId(), $index
461 $this->
object->addQTIMaterial($a_xml_writer, $fb);
462 $a_xml_writer->xmlEndTag(
"flow_mat");
463 $a_xml_writer->xmlEndTag(
"itemfeedback");
465 if (strlen($feedback_allcorrect))
468 "ident" =>
"response_allcorrect",
471 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
473 $a_xml_writer->xmlStartTag(
"flow_mat");
474 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
475 $a_xml_writer->xmlEndTag(
"flow_mat");
476 $a_xml_writer->xmlEndTag(
"itemfeedback");
478 if (strlen($feedback_onenotcorrect))
481 "ident" =>
"response_onenotcorrect",
484 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
486 $a_xml_writer->xmlStartTag(
"flow_mat");
487 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
488 $a_xml_writer->xmlEndTag(
"flow_mat");
489 $a_xml_writer->xmlEndTag(
"itemfeedback");
492 $a_xml_writer->xmlEndTag(
"item");
493 $a_xml_writer->xmlEndTag(
"questestinterop");
495 $xml = $a_xml_writer->xmlDumpMem(FALSE);
496 if (!$a_include_header)
498 $pos = strpos($xml,
"?>");
499 $xml = substr($xml, $pos + 2);
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Class for question exports.
Class for imagemap question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
xmlHeader()
Writes xml header public.
Create styles array
The data for the language used.
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
Create new PHPExcel object
obj_idprivate
const IMAGEMAP_QUESTION_IDENTIFIER