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");
74 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
75 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"fixedTextLength");
76 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getFixedTextLength());
77 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
78 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
79 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"identicalScoring");
80 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getIdenticalScoring());
81 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
82 $a_xml_writer->xmlEndTag(
"qtimetadata");
83 $a_xml_writer->xmlEndTag(
"itemmetadata");
87 "label" => $this->object->getTitle()
89 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
91 $a_xml_writer->xmlStartTag(
"flow");
92 $text_parts = preg_split(
"/\[gap.*?\[\/gap\]/", $this->object->getClozeText());
94 for ($i = 0; $i <= $this->
object->getGapCount(); $i++)
99 $this->
object->addQTIMaterial($a_xml_writer, $text_parts[$i]);
103 $this->
object->addQTIMaterial($a_xml_writer, $text_parts[$i], TRUE, FALSE);
106 if ($i < $this->object->getGapCount())
109 $gap = $this->
object->getGap($i);
110 switch ($gap->getType())
116 "rcardinality" =>
"Single" 118 $a_xml_writer->xmlStartTag(
"response_str", $attrs);
119 $solution = $this->
object->getSuggestedSolution($i);
120 if (count($solution))
122 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
125 "label" =>
"suggested_solution" 127 $a_xml_writer->xmlStartTag(
"material", $attrs);
128 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
129 if (strcmp($matches[1],
"") != 0)
131 $intlink = $solution[
"internal_link"];
133 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
134 $a_xml_writer->xmlEndTag(
"material");
138 $attrs = array(
"shuffle" => ($gap->getShuffle() ?
"Yes" :
"No"));
139 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
142 foreach ($gap->getItems() as $answeritem)
145 "ident" => $answeritem->getOrder()
147 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
148 $a_xml_writer->xmlStartTag(
"material");
149 $a_xml_writer->xmlElement(
"mattext", NULL, $answeritem->getAnswertext());
150 $a_xml_writer->xmlEndTag(
"material");
151 $a_xml_writer->xmlEndTag(
"response_label");
153 $a_xml_writer->xmlEndTag(
"render_choice");
154 $a_xml_writer->xmlEndTag(
"response_str");
160 "rcardinality" =>
"Single" 162 $a_xml_writer->xmlStartTag(
"response_str", $attrs);
163 $solution = $this->
object->getSuggestedSolution($i);
164 if (count($solution))
166 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
169 "label" =>
"suggested_solution" 171 $a_xml_writer->xmlStartTag(
"material", $attrs);
172 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
173 if (strcmp($matches[1],
"") != 0)
175 $intlink = $solution[
"internal_link"];
177 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
178 $a_xml_writer->xmlEndTag(
"material");
182 "fibtype" =>
"String",
184 "columns" => $gap->getMaxWidth()
186 $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
187 $a_xml_writer->xmlEndTag(
"render_fib");
188 $a_xml_writer->xmlEndTag(
"response_str");
194 "numtype" =>
"Decimal",
195 "rcardinality" =>
"Single" 197 $a_xml_writer->xmlStartTag(
"response_num", $attrs);
198 $solution = $this->
object->getSuggestedSolution($i);
199 if (count($solution))
201 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
204 "label" =>
"suggested_solution" 206 $a_xml_writer->xmlStartTag(
"material", $attrs);
207 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
208 if (strcmp($matches[1],
"") != 0)
210 $intlink = $solution[
"internal_link"];
212 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
213 $a_xml_writer->xmlEndTag(
"material");
216 $answeritem = $gap->getItem(0);
218 "fibtype" =>
"Decimal",
220 "columns" => $gap->getMaxWidth()
222 if (is_object($answeritem))
224 if ($eval->e($answeritem->getLowerBound()) !== FALSE)
226 $attrs[
"minnumber"] = $answeritem->getLowerBound();
228 if ($eval->e($answeritem->getUpperBound()) !== FALSE)
230 $attrs[
"maxnumber"] = $answeritem->getUpperBound();
233 $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
234 $a_xml_writer->xmlEndTag(
"render_fib");
235 $a_xml_writer->xmlEndTag(
"response_num");
240 $a_xml_writer->xmlEndTag(
"flow");
241 $a_xml_writer->xmlEndTag(
"presentation");
244 $a_xml_writer->xmlStartTag(
"resprocessing");
245 $a_xml_writer->xmlStartTag(
"outcomes");
246 $a_xml_writer->xmlStartTag(
"decvar");
247 $a_xml_writer->xmlEndTag(
"decvar");
248 $a_xml_writer->xmlEndTag(
"outcomes");
251 for ($i = 0; $i < $this->
object->getGapCount(); $i++)
253 $gap = $this->
object->getGap($i);
254 switch ($gap->getType())
257 foreach ($gap->getItems() as $answer)
262 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
264 $a_xml_writer->xmlStartTag(
"conditionvar");
267 "respident" =>
"gap_$i" 269 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
270 $a_xml_writer->xmlEndTag(
"conditionvar");
275 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
278 $linkrefid =
"$i" .
"_Response_" . $answer->getOrder();
280 "feedbacktype" =>
"Response",
281 "linkrefid" => $linkrefid
283 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
284 $a_xml_writer->xmlEndTag(
"respcondition");
288 foreach ($gap->getItems() as $answer)
293 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
295 $a_xml_writer->xmlStartTag(
"conditionvar");
297 "respident" =>
"gap_$i" 299 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
300 $a_xml_writer->xmlEndTag(
"conditionvar");
305 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
307 $linkrefid =
"$i" .
"_Response_" . $answer->getOrder();
309 "feedbacktype" =>
"Response",
310 "linkrefid" => $linkrefid
312 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
313 $a_xml_writer->xmlEndTag(
"respcondition");
317 foreach ($gap->getItems() as $answer)
322 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
324 $a_xml_writer->xmlStartTag(
"conditionvar");
326 "respident" =>
"gap_$i" 328 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
329 $a_xml_writer->xmlEndTag(
"conditionvar");
334 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
336 $linkrefid =
"$i" .
"_Response_" . $answer->getOrder();
338 "feedbacktype" =>
"Response",
339 "linkrefid" => $linkrefid
341 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
342 $a_xml_writer->xmlEndTag(
"respcondition");
348 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
349 $this->object->getId(), true
351 if (strlen($feedback_allcorrect))
356 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
358 $a_xml_writer->xmlStartTag(
"conditionvar");
360 for ($i = 0; $i < $this->
object->getGapCount(); $i++)
362 $gap = $this->
object->getGap($i);
363 $indexes = $gap->getBestSolutionIndexes();
366 $a_xml_writer->xmlStartTag(
"and");
368 switch ($gap->getType())
372 foreach ($indexes as $key)
376 $a_xml_writer->xmlStartTag(
"or");
379 "respident" =>
"gap_$i" 381 $answer = $gap->getItem($key);
382 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
385 $a_xml_writer->xmlEndTag(
"or");
392 foreach ($indexes as $key)
396 $a_xml_writer->xmlStartTag(
"or");
399 "respident" =>
"gap_$i" 401 $answer = $gap->getItem($key);
402 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
405 $a_xml_writer->xmlEndTag(
"or");
412 foreach ($indexes as $key)
416 $a_xml_writer->xmlStartTag(
"or");
419 "respident" =>
"gap_$i" 421 $answer = $gap->getItem($key);
422 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
425 $a_xml_writer->xmlEndTag(
"or");
433 $a_xml_writer->xmlEndTag(
"and");
436 $a_xml_writer->xmlEndTag(
"conditionvar");
439 "feedbacktype" =>
"Response",
440 "linkrefid" =>
"response_allcorrect" 442 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
443 $a_xml_writer->xmlEndTag(
"respcondition");
445 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
446 $this->object->getId(), false
448 if (strlen($feedback_onenotcorrect))
453 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
455 $a_xml_writer->xmlStartTag(
"conditionvar");
457 $a_xml_writer->xmlStartTag(
"not");
458 for ($i = 0; $i < $this->
object->getGapCount(); $i++)
460 $gap = $this->
object->getGap($i);
461 $indexes = $gap->getBestSolutionIndexes();
464 $a_xml_writer->xmlStartTag(
"and");
466 switch ($gap->getType())
470 foreach ($indexes as $key)
474 $a_xml_writer->xmlStartTag(
"or");
477 "respident" =>
"gap_$i" 479 $answer = $gap->getItem($key);
480 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
483 $a_xml_writer->xmlEndTag(
"or");
490 foreach ($indexes as $key)
494 $a_xml_writer->xmlStartTag(
"or");
497 "respident" =>
"gap_$i" 499 $answer = $gap->getItem($key);
500 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
503 $a_xml_writer->xmlEndTag(
"or");
510 foreach ($indexes as $key)
514 $a_xml_writer->xmlStartTag(
"or");
517 "respident" =>
"gap_$i" 519 $answer = $gap->getItem($key);
520 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
523 $a_xml_writer->xmlEndTag(
"or");
531 $a_xml_writer->xmlEndTag(
"and");
534 $a_xml_writer->xmlEndTag(
"not");
535 $a_xml_writer->xmlEndTag(
"conditionvar");
538 "feedbacktype" =>
"Response",
539 "linkrefid" =>
"response_onenotcorrect" 541 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
542 $a_xml_writer->xmlEndTag(
"respcondition");
545 $a_xml_writer->xmlEndTag(
"resprocessing");
548 for ($i = 0; $i < $this->
object->getGapCount(); $i++)
550 $gap = $this->
object->getGap($i);
551 switch ($gap->getType())
585 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
587 $a_xml_writer->xmlStartTag(
"flow_mat");
591 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
592 $this->object->getId(), $i
594 $this->
object->addQTIMaterial($a_xml_writer, $fb);
595 $a_xml_writer->xmlEndTag(
"flow_mat");
596 $a_xml_writer->xmlEndTag(
"itemfeedback");
599 if (strlen($feedback_allcorrect))
602 "ident" =>
"response_allcorrect",
605 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
607 $a_xml_writer->xmlStartTag(
"flow_mat");
608 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
609 $a_xml_writer->xmlEndTag(
"flow_mat");
610 $a_xml_writer->xmlEndTag(
"itemfeedback");
612 if (strlen($feedback_onenotcorrect))
615 "ident" =>
"response_onenotcorrect",
618 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
620 $a_xml_writer->xmlStartTag(
"flow_mat");
621 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
622 $a_xml_writer->xmlEndTag(
"flow_mat");
623 $a_xml_writer->xmlEndTag(
"itemfeedback");
626 $a_xml_writer->xmlEndTag(
"item");
627 $a_xml_writer->xmlEndTag(
"questestinterop");
629 $xml = $a_xml_writer->xmlDumpMem(FALSE);
630 if (!$a_include_header)
632 $pos = strpos($xml,
"?>");
633 $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.
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
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.