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/Math/classes/class.EvalMath.php";
32 $eval->suppress_errors = TRUE;
33 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
37 $a_xml_writer->xmlStartTag(
"questestinterop");
39 "ident" =>
"il_".IL_INST_ID.
"_qst_".$this->object->getId(),
40 "title" => $this->
object->getTitle(),
41 "maxattempts" => $this->
object->getNrOfTries()
43 $a_xml_writer->xmlStartTag(
"item", $attrs);
45 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->
object->getComment());
47 $workingtime = $this->
object->getEstimatedWorkingTime();
48 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
49 $a_xml_writer->xmlElement(
"duration", NULL,
$duration);
51 $a_xml_writer->xmlStartTag(
"itemmetadata");
52 $a_xml_writer->xmlStartTag(
"qtimetadata");
53 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
54 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
55 $a_xml_writer->xmlElement(
"fieldentry", NULL, $ilias->getSetting(
"ilias_version"));
56 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
57 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
58 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"QUESTIONTYPE");
60 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
61 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
62 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"AUTHOR");
63 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getAuthor());
64 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
70 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
71 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"textgaprating");
72 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getTextgapRating());
73 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
75 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
76 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"fixedTextLength");
77 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getFixedTextLength());
78 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
80 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
81 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"identicalScoring");
82 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getIdenticalScoring());
83 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
85 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
86 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"combinations");
87 $a_xml_writer->xmlElement(
"fieldentry", NULL, base64_encode(json_encode($this->
object->getGapCombinations())));
88 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
90 $a_xml_writer->xmlEndTag(
"qtimetadata");
91 $a_xml_writer->xmlEndTag(
"itemmetadata");
95 "label" => $this->
object->getTitle()
97 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
99 $a_xml_writer->xmlStartTag(
"flow");
101 $questionText = $this->
object->getQuestion() ? $this->
object->getQuestion() :
' ';
102 $this->
object->addQTIMaterial($a_xml_writer, $questionText);
104 $text_parts = preg_split(
"/\[gap.*?\[\/gap\]/", $this->
object->getClozeText());
107 for ($i = 0; $i <= $this->
object->getGapCount(); $i++)
109 $this->
object->addQTIMaterial($a_xml_writer, $text_parts[$i]);
111 if ($i < $this->
object->getGapCount())
114 $gap = $this->
object->getGap($i);
115 switch ($gap->getType())
121 "rcardinality" =>
"Single" 123 $a_xml_writer->xmlStartTag(
"response_str", $attrs);
124 $solution = $this->
object->getSuggestedSolution($i);
125 if (count($solution))
127 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
130 "label" =>
"suggested_solution" 132 $a_xml_writer->xmlStartTag(
"material", $attrs);
133 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
134 if (strcmp($matches[1],
"") != 0)
136 $intlink = $solution[
"internal_link"];
138 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
139 $a_xml_writer->xmlEndTag(
"material");
143 $attrs =
array(
"shuffle" => ($gap->getShuffle() ?
"Yes" :
"No"));
144 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
150 "ident" => $answeritem->getOrder()
152 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
153 $a_xml_writer->xmlStartTag(
"material");
154 $a_xml_writer->xmlElement(
"mattext", NULL, $answeritem->getAnswertext());
155 $a_xml_writer->xmlEndTag(
"material");
156 $a_xml_writer->xmlEndTag(
"response_label");
158 $a_xml_writer->xmlEndTag(
"render_choice");
159 $a_xml_writer->xmlEndTag(
"response_str");
165 "rcardinality" =>
"Single" 167 $a_xml_writer->xmlStartTag(
"response_str", $attrs);
168 $solution = $this->
object->getSuggestedSolution($i);
169 if (count($solution))
171 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
174 "label" =>
"suggested_solution" 176 $a_xml_writer->xmlStartTag(
"material", $attrs);
177 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
178 if (strcmp($matches[1],
"") != 0)
180 $intlink = $solution[
"internal_link"];
182 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
183 $a_xml_writer->xmlEndTag(
"material");
187 "fibtype" =>
"String",
189 "columns" => $gap->getMaxWidth(),
190 "maxchars" => $gap->getGapSize()
192 $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
193 $a_xml_writer->xmlEndTag(
"render_fib");
194 $a_xml_writer->xmlEndTag(
"response_str");
200 "numtype" =>
"Decimal",
201 "rcardinality" =>
"Single" 203 $a_xml_writer->xmlStartTag(
"response_num", $attrs);
204 $solution = $this->
object->getSuggestedSolution($i);
205 if (count($solution))
207 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
210 "label" =>
"suggested_solution" 212 $a_xml_writer->xmlStartTag(
"material", $attrs);
213 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
214 if (strcmp($matches[1],
"") != 0)
216 $intlink = $solution[
"internal_link"];
218 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
219 $a_xml_writer->xmlEndTag(
"material");
222 $answeritem = $gap->getItem(0);
224 "fibtype" =>
"Decimal",
226 "columns" => $gap->getMaxWidth(),
227 "maxchars" => $gap->getGapSize()
229 if (is_object($answeritem))
231 if ($eval->e($answeritem->getLowerBound()) !== FALSE)
233 $attrs[
"minnumber"] = $answeritem->getLowerBound();
235 if ($eval->e($answeritem->getUpperBound()) !== FALSE)
237 $attrs[
"maxnumber"] = $answeritem->getUpperBound();
240 $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
241 $a_xml_writer->xmlEndTag(
"render_fib");
242 $a_xml_writer->xmlEndTag(
"response_num");
247 $a_xml_writer->xmlEndTag(
"flow");
248 $a_xml_writer->xmlEndTag(
"presentation");
251 $a_xml_writer->xmlStartTag(
"resprocessing");
252 $a_xml_writer->xmlStartTag(
"outcomes");
253 $a_xml_writer->xmlStartTag(
"decvar");
254 $a_xml_writer->xmlEndTag(
"decvar");
255 $a_xml_writer->xmlEndTag(
"outcomes");
258 for ($i = 0; $i < $this->
object->getGapCount(); $i++)
260 $gap = $this->
object->getGap($i);
261 switch ($gap->getType())
269 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
271 $a_xml_writer->xmlStartTag(
"conditionvar");
274 "respident" =>
"gap_$i" 276 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
277 $a_xml_writer->xmlEndTag(
"conditionvar");
282 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
285 $linkrefid =
"$i" .
"_Response_" . $answer->getOrder();
287 "feedbacktype" =>
"Response",
288 "linkrefid" => $linkrefid
290 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
291 $a_xml_writer->xmlEndTag(
"respcondition");
300 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
302 $a_xml_writer->xmlStartTag(
"conditionvar");
304 "respident" =>
"gap_$i" 306 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
307 $a_xml_writer->xmlEndTag(
"conditionvar");
312 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
314 $linkrefid =
"$i" .
"_Response_" . $answer->getOrder();
316 "feedbacktype" =>
"Response",
317 "linkrefid" => $linkrefid
319 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
320 $a_xml_writer->xmlEndTag(
"respcondition");
329 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
331 $a_xml_writer->xmlStartTag(
"conditionvar");
333 "respident" =>
"gap_$i" 335 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
336 $a_xml_writer->xmlEndTag(
"conditionvar");
341 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
343 $linkrefid =
"$i" .
"_Response_" . $answer->getOrder();
345 "feedbacktype" =>
"Response",
346 "linkrefid" => $linkrefid
348 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
349 $a_xml_writer->xmlEndTag(
"respcondition");
355 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
356 $this->
object->getId(), true
358 if (strlen($feedback_allcorrect))
363 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
365 $a_xml_writer->xmlStartTag(
"conditionvar");
367 for ($i = 0; $i < $this->
object->getGapCount(); $i++)
369 $gap = $this->
object->getGap($i);
370 $indexes = $gap->getBestSolutionIndexes();
373 $a_xml_writer->xmlStartTag(
"and");
375 switch ($gap->getType())
379 foreach ($indexes as $key)
383 $a_xml_writer->xmlStartTag(
"or");
386 "respident" =>
"gap_$i" 388 $answer = $gap->getItem($key);
389 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
392 $a_xml_writer->xmlEndTag(
"or");
399 foreach ($indexes as $key)
403 $a_xml_writer->xmlStartTag(
"or");
406 "respident" =>
"gap_$i" 408 $answer = $gap->getItem($key);
409 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
412 $a_xml_writer->xmlEndTag(
"or");
419 foreach ($indexes as $key)
423 $a_xml_writer->xmlStartTag(
"or");
426 "respident" =>
"gap_$i" 428 $answer = $gap->getItem($key);
429 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
432 $a_xml_writer->xmlEndTag(
"or");
440 $a_xml_writer->xmlEndTag(
"and");
443 $a_xml_writer->xmlEndTag(
"conditionvar");
446 "feedbacktype" =>
"Response",
447 "linkrefid" =>
"response_allcorrect" 449 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
450 $a_xml_writer->xmlEndTag(
"respcondition");
452 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
453 $this->
object->getId(), false
455 if (strlen($feedback_onenotcorrect))
460 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
462 $a_xml_writer->xmlStartTag(
"conditionvar");
464 $a_xml_writer->xmlStartTag(
"not");
465 for ($i = 0; $i < $this->
object->getGapCount(); $i++)
467 $gap = $this->
object->getGap($i);
468 $indexes = $gap->getBestSolutionIndexes();
471 $a_xml_writer->xmlStartTag(
"and");
473 switch ($gap->getType())
477 foreach ($indexes as $key)
481 $a_xml_writer->xmlStartTag(
"or");
484 "respident" =>
"gap_$i" 486 $answer = $gap->getItem($key);
487 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
490 $a_xml_writer->xmlEndTag(
"or");
497 foreach ($indexes as $key)
501 $a_xml_writer->xmlStartTag(
"or");
504 "respident" =>
"gap_$i" 506 $answer = $gap->getItem($key);
507 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
510 $a_xml_writer->xmlEndTag(
"or");
517 foreach ($indexes as $key)
521 $a_xml_writer->xmlStartTag(
"or");
524 "respident" =>
"gap_$i" 526 $answer = $gap->getItem($key);
527 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
530 $a_xml_writer->xmlEndTag(
"or");
538 $a_xml_writer->xmlEndTag(
"and");
541 $a_xml_writer->xmlEndTag(
"not");
542 $a_xml_writer->xmlEndTag(
"conditionvar");
545 "feedbacktype" =>
"Response",
546 "linkrefid" =>
"response_onenotcorrect" 548 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
549 $a_xml_writer->xmlEndTag(
"respcondition");
552 $a_xml_writer->xmlEndTag(
"resprocessing");
555 for ($i = 0; $i < $this->
object->getGapCount(); $i++)
557 $gap = $this->
object->getGap($i);
558 switch ($gap->getType())
592 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
594 $a_xml_writer->xmlStartTag(
"flow_mat");
598 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
599 $this->
object->getId(), $i
601 $this->
object->addQTIMaterial($a_xml_writer, $fb);
602 $a_xml_writer->xmlEndTag(
"flow_mat");
603 $a_xml_writer->xmlEndTag(
"itemfeedback");
606 if (strlen($feedback_allcorrect))
609 "ident" =>
"response_allcorrect",
612 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
614 $a_xml_writer->xmlStartTag(
"flow_mat");
615 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
616 $a_xml_writer->xmlEndTag(
"flow_mat");
617 $a_xml_writer->xmlEndTag(
"itemfeedback");
619 if (strlen($feedback_onenotcorrect))
622 "ident" =>
"response_onenotcorrect",
625 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
627 $a_xml_writer->xmlStartTag(
"flow_mat");
628 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
629 $a_xml_writer->xmlEndTag(
"flow_mat");
630 $a_xml_writer->xmlEndTag(
"itemfeedback");
633 $a_xml_writer->xmlEndTag(
"item");
634 $a_xml_writer->xmlEndTag(
"questestinterop");
636 $xml = $a_xml_writer->xmlDumpMem(FALSE);
637 if (!$a_include_header)
639 $pos = strpos($xml,
"?>");
640 $xml = substr($xml, $pos + 2);
const CLOZE_TEXT
Cloze question constants.
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
Class for cloze question exports.
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
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.
const CLOZE_TEST_IDENTIFIER
Question identifier constants.