4 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
26 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
29 $ilias = $DIC[
'ilias'];
31 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
35 $a_xml_writer->xmlStartTag(
"questestinterop");
37 "ident" =>
"il_" . IL_INST_ID .
"_qst_" . $this->object->getId(),
38 "title" => $this->
object->getTitle(),
39 "maxattempts" => $this->
object->getNrOfTries()
41 $a_xml_writer->xmlStartTag(
"item", $attrs);
43 $a_xml_writer->xmlElement(
"qticomment", null, $this->object->getComment());
45 $workingtime = $this->
object->getEstimatedWorkingTime();
46 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
47 $a_xml_writer->xmlElement(
"duration", null, $duration);
49 $a_xml_writer->xmlStartTag(
"itemmetadata");
50 $a_xml_writer->xmlStartTag(
"qtimetadata");
51 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
52 $a_xml_writer->xmlElement(
"fieldlabel", null,
"ILIAS_VERSION");
53 $a_xml_writer->xmlElement(
"fieldentry", null, $ilias->getSetting(
"ilias_version"));
54 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
55 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
56 $a_xml_writer->xmlElement(
"fieldlabel", null,
"QUESTIONTYPE");
58 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
59 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
60 $a_xml_writer->xmlElement(
"fieldlabel", null,
"IS_MULTIPLE_CHOICE");
61 $a_xml_writer->xmlElement(
"fieldentry", null, ($this->object->getIsMultipleChoice())?
"1":
"0");
62 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
63 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
64 $a_xml_writer->xmlElement(
"fieldlabel", null,
"AUTHOR");
65 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getAuthor());
66 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
72 $a_xml_writer->xmlEndTag(
"qtimetadata");
73 $a_xml_writer->xmlEndTag(
"itemmetadata");
77 "label" => $this->object->getTitle()
79 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
81 $a_xml_writer->xmlStartTag(
"flow");
83 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
87 "rcardinality" =>
"Single" 89 $a_xml_writer->xmlStartTag(
"response_xy", $attrs);
90 $solution = $this->
object->getSuggestedSolution(0);
91 if (count($solution)) {
92 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
93 $a_xml_writer->xmlStartTag(
"material");
94 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
95 if (strcmp($matches[1],
"") != 0) {
96 $intlink = $solution[
"internal_link"];
99 "label" =>
"suggested_solution" 101 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
102 $a_xml_writer->xmlEndTag(
"material");
105 $a_xml_writer->xmlStartTag(
"render_hotspot");
106 $a_xml_writer->xmlStartTag(
"material");
107 $imagetype =
"image/jpeg";
108 if (preg_match(
"/.*\.(png|gif)$/i", $this->object->getImageFilename(), $matches)) {
109 $imagetype =
"image/" . strtolower($matches[1]);
112 "imagtype" => $imagetype,
113 "label" => $this->object->getImageFilename()
115 if ($a_include_binary) {
116 if ($force_image_references) {
117 $attrs[
"uri"] = $this->
object->getImagePathWeb() . $this->
object->getImageFilename();
118 $a_xml_writer->xmlElement(
"matimage", $attrs);
120 $attrs[
"embedded"] =
"base64";
121 $imagepath = $this->
object->getImagePath() . $this->
object->getImageFilename();
122 $fh =
fopen($imagepath,
"rb");
129 $imagefile = fread($fh, filesize($imagepath));
131 $base64 = base64_encode($imagefile);
132 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
135 $a_xml_writer->xmlElement(
"matimage", $attrs);
137 $a_xml_writer->xmlEndTag(
"material");
140 foreach ($this->object->getAnswers() as
$index => $answer) {
142 switch ($answer->getArea()) {
144 $rarea =
"Rectangle";
157 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
158 $a_xml_writer->xmlData($answer->getCoords());
159 $a_xml_writer->xmlStartTag(
"material");
160 $a_xml_writer->xmlElement(
"mattext", null, $answer->getAnswertext());
161 $a_xml_writer->xmlEndTag(
"material");
162 $a_xml_writer->xmlEndTag(
"response_label");
164 $a_xml_writer->xmlEndTag(
"render_hotspot");
165 $a_xml_writer->xmlEndTag(
"response_xy");
166 $a_xml_writer->xmlEndTag(
"flow");
167 $a_xml_writer->xmlEndTag(
"presentation");
170 $a_xml_writer->xmlStartTag(
"resprocessing");
171 $a_xml_writer->xmlStartTag(
"outcomes");
172 $a_xml_writer->xmlStartTag(
"decvar");
173 $a_xml_writer->xmlEndTag(
"decvar");
174 $a_xml_writer->xmlEndTag(
"outcomes");
176 foreach ($this->object->getAnswers() as $index => $answer) {
180 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
182 $a_xml_writer->xmlStartTag(
"conditionvar");
183 if (!$answer->isStateSet()) {
184 $a_xml_writer->xmlStartTag(
"not");
187 switch ($answer->getArea()) {
189 $areatype =
"Rectangle";
192 $areatype =
"Ellipse";
195 $areatype =
"Bounded";
200 "areatype" => $areatype
202 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getCoords());
203 if (!$answer->isStateSet()) {
204 $a_xml_writer->xmlEndTag(
"not");
206 $a_xml_writer->xmlEndTag(
"conditionvar");
211 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
212 $linkrefid =
"response_$index";
214 "feedbacktype" =>
"Response",
215 "linkrefid" => $linkrefid
217 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
218 $a_xml_writer->xmlEndTag(
"respcondition");
222 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
224 $a_xml_writer->xmlStartTag(
"conditionvar");
228 $a_xml_writer->xmlStartTag(
"not");
229 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getCoords());
230 $a_xml_writer->xmlEndTag(
"not");
231 $a_xml_writer->xmlEndTag(
"conditionvar");
236 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPointsUnchecked());
237 $a_xml_writer->xmlEndTag(
"respcondition");
240 $answers = $this->
object->getAnswers();
241 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
242 $this->object->getId(),
245 if (strlen($feedback_allcorrect)) {
249 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
251 $a_xml_writer->xmlStartTag(
"conditionvar");
252 if (!$this->object->getIsMultipleChoice()) {
255 foreach ($answers as $index => $answer) {
256 if ($answer->getPoints() > $maxpoints) {
257 $maxpoints = $answer->getPoints();
266 $answer = $answers[$bestindex];
267 switch ($answer->getArea()) {
269 $areatype =
"Rectangle";
272 $areatype =
"Ellipse";
275 $areatype =
"Bounded";
280 "areatype" => $areatype
282 $a_xml_writer->xmlElement(
"varinside", $attrs, $answer->getCoords());
284 foreach ($answers as $index => $answer) {
285 if ($answer->getPoints() < $answer->getPointsUnchecked()) {
286 $a_xml_writer->xmlStartTag(
"not");
288 switch ($answer->getArea()) {
290 $areatype =
"Rectangle";
293 $areatype =
"Ellipse";
296 $areatype =
"Bounded";
301 "areatype" => $areatype
303 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
304 if ($answer->getPoints() < $answer->getPointsUnchecked()) {
305 $a_xml_writer->xmlEndTag(
"not");
310 $a_xml_writer->xmlEndTag(
"conditionvar");
313 "feedbacktype" =>
"Response",
314 "linkrefid" =>
"response_allcorrect" 316 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
317 $a_xml_writer->xmlEndTag(
"respcondition");
320 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
321 $this->object->getId(),
324 if (strlen($feedback_onenotcorrect)) {
328 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
330 $a_xml_writer->xmlStartTag(
"conditionvar");
331 if (!$this->object->getIsMultipleChoice()) {
334 foreach ($answers as $index => $answer) {
335 if ($answer->getPoints() > $maxpoints) {
336 $maxpoints = $answer->getPoints();
343 $a_xml_writer->xmlStartTag(
"not");
346 $answer = $answers[$bestindex];
347 switch ($answer->getArea()) {
349 $areatype =
"Rectangle";
352 $areatype =
"Ellipse";
355 $areatype =
"Bounded";
360 "areatype" => $areatype
362 $a_xml_writer->xmlElement(
"varinside", $attrs, $answer->getCoords());
364 $a_xml_writer->xmlEndTag(
"not");
366 foreach ($answers as $index => $answer) {
368 $a_xml_writer->xmlStartTag(
"or");
370 if ($answer->getPoints() >= $answer->getPointsUnchecked()) {
371 $a_xml_writer->xmlStartTag(
"not");
373 switch ($answer->getArea()) {
375 $areatype =
"Rectangle";
378 $areatype =
"Ellipse";
381 $areatype =
"Bounded";
386 "areatype" => $areatype
388 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
389 if ($answer->getPoints() >= $answer->getPointsUnchecked()) {
390 $a_xml_writer->xmlEndTag(
"not");
393 $a_xml_writer->xmlEndTag(
"or");
397 $a_xml_writer->xmlEndTag(
"conditionvar");
400 "feedbacktype" =>
"Response",
401 "linkrefid" =>
"response_onenotcorrect" 403 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
404 $a_xml_writer->xmlEndTag(
"respcondition");
407 $a_xml_writer->xmlEndTag(
"resprocessing");
410 foreach ($this->object->getAnswers() as $index => $answer) {
412 $linkrefid =
"response_$index";
414 "ident" => $linkrefid,
417 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
419 $a_xml_writer->xmlStartTag(
"flow_mat");
420 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
421 $this->object->getId(),
425 $this->
object->addQTIMaterial($a_xml_writer, $fb);
426 $a_xml_writer->xmlEndTag(
"flow_mat");
427 $a_xml_writer->xmlEndTag(
"itemfeedback");
429 if (strlen($feedback_allcorrect)) {
431 "ident" =>
"response_allcorrect",
434 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
436 $a_xml_writer->xmlStartTag(
"flow_mat");
437 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
438 $a_xml_writer->xmlEndTag(
"flow_mat");
439 $a_xml_writer->xmlEndTag(
"itemfeedback");
441 if (strlen($feedback_onenotcorrect)) {
443 "ident" =>
"response_onenotcorrect",
446 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
448 $a_xml_writer->xmlStartTag(
"flow_mat");
449 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
450 $a_xml_writer->xmlEndTag(
"flow_mat");
451 $a_xml_writer->xmlEndTag(
"itemfeedback");
454 $a_xml_writer->xmlEndTag(
"item");
455 $a_xml_writer->xmlEndTag(
"questestinterop");
457 $xml = $a_xml_writer->xmlDumpMem(
false);
458 if (!$a_include_header) {
459 $pos = strpos(
$xml,
"?>");
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.
Class for question exports.
Class for imagemap question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
xmlHeader()
Writes xml header public.
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
const IMAGEMAP_QUESTION_IDENTIFIER