25 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false): string
28 $ilias = $DIC[
'ilias'];
30 $correct_answers = $this->
object->getCorrectAnswers();
31 $answers = $this->
object->getAnswers();
33 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
37 $xml->xmlStartTag(
"questestinterop");
41 "title" => $this->
object->getTitle(),
42 "maxattempts" => $this->
object->getNrOfTries()
44 $xml->xmlStartTag(
"item", $attrs);
46 $xml->xmlElement(
"qticomment", null, $this->
object->getComment());
47 $xml->xmlStartTag(
"itemmetadata");
48 $xml->xmlStartTag(
"qtimetadata");
49 $xml->xmlStartTag(
"qtimetadatafield");
50 $xml->xmlElement(
"fieldlabel", null,
"ILIAS_VERSION");
51 $xml->xmlElement(
"fieldentry", null, $ilias->getSetting(
"ilias_version"));
52 $xml->xmlEndTag(
"qtimetadatafield");
53 $xml->xmlStartTag(
"qtimetadatafield");
54 $xml->xmlElement(
"fieldlabel", null,
"QUESTIONTYPE");
56 $xml->xmlEndTag(
"qtimetadatafield");
57 $xml->xmlStartTag(
"qtimetadatafield");
58 $xml->xmlElement(
"fieldlabel", null,
"AUTHOR");
59 $xml->xmlElement(
"fieldentry", null, $this->
object->getAuthor());
60 $xml->xmlEndTag(
"qtimetadatafield");
62 $xml->xmlStartTag(
"qtimetadatafield");
63 $xml->xmlElement(
"fieldlabel", null,
"minAutoCompleteLength");
64 $xml->xmlElement(
"fieldentry", null, $this->
object->getMinAutoComplete());
65 $xml->xmlEndTag(
"qtimetadatafield");
66 $xml->xmlStartTag(
"qtimetadatafield");
67 $xml->xmlElement(
"fieldlabel", null,
"identical_scoring");
68 $xml->xmlElement(
"fieldentry", null, $this->
object->getIdenticalScoring());
69 $xml->xmlEndTag(
"qtimetadatafield");
71 $xml->xmlStartTag(
"qtimetadatafield");
72 $xml->xmlElement(
"fieldlabel", null,
"gapTypes");
74 if (is_array($correct_answers)) {
75 foreach ($correct_answers as
$key => $value) {
76 $gap_types[] = $value[2];
79 $xml->xmlElement(
"fieldentry", null, json_encode($gap_types));
80 $xml->xmlEndTag(
"qtimetadatafield");
86 $xml->xmlStartTag(
"qtimetadatafield");
87 $xml->xmlElement(
"fieldlabel", null,
"feedback_setting");
88 $xml->xmlElement(
"fieldentry", null, $this->
object->getSpecificFeedbackSetting());
89 $xml->xmlEndTag(
"qtimetadatafield");
91 $xml->xmlEndTag(
"qtimetadata");
92 $xml->xmlEndTag(
"itemmetadata");
93 $xml->xmlStartTag(
"presentation");
95 $xml->xmlStartTag(
"flow");
98 $this->
object->addQTIMaterial(
$xml, $this->
object->getQuestion());
99 $this->
object->addQTIMaterial(
$xml, $this->
object->getLongMenuTextValue());
101 foreach ($answers as
$key => $values) {
104 "ident" =>
"LongMenu_" . $real_id,
105 "rcardinality" =>
"Single" 107 $xml->xmlStartTag(
"response_str", $attrs);
108 foreach ($values as
$index => $value) {
109 $xml->xmlStartTag(
"response_label", array(
'ident' =>
$index));
110 $xml->xmlStartTag(
"material");
111 $xml->xmlElement(
"fieldentry", null, $value);
112 $xml->xmlEndTag(
"material");
113 $xml->xmlEndTag(
"response_label");
115 $xml->xmlEndTag(
"response_str");
117 $xml->xmlEndTag(
"flow");
118 $xml->xmlEndTag(
"presentation");
120 $xml->xmlStartTag(
"resprocessing");
121 $xml->xmlStartTag(
"outcomes");
122 $xml->xmlElement(
"decvar");
123 $xml->xmlEndTag(
"outcomes");
124 foreach ($answers as
$key => $values) {
126 foreach ($values as
$index => $value) {
127 $xml->xmlStartTag(
"respcondition", array(
'continue' =>
'Yes'));
128 $xml->xmlStartTag(
"conditionvar");
129 $xml->xmlElement(
"varequal", array(
'respident' =>
"LongMenu_" . $real_id), $value);
130 $xml->xmlEndTag(
"conditionvar");
132 if (in_array($value, $correct_answers[
$key][0])) {
133 $xml->xmlElement(
"setvar", array(
'action' =>
"Add"), $correct_answers[$key][1]);
135 $xml->xmlElement(
"setvar", array(
'action' =>
"Add"), 0);
137 $xml->xmlElement(
"displayfeedback", array(
'feedbacktype' =>
"Response",
'linkrefid' => $key .
'_Response_' .
$index));
138 $xml->xmlEndTag(
"respcondition");
141 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
145 if (strlen($feedback_allcorrect) > 0) {
146 $xml->xmlStartTag(
"respcondition", array(
'continue' =>
'Yes'));
147 $xml->xmlStartTag(
"conditionvar");
148 foreach ($correct_answers as
$key => $values) {
151 $xml->xmlStartTag(
"and");
154 foreach ($values[0] as
$index => $value) {
156 $xml->xmlStartTag(
"or");
158 $xml->xmlElement(
"varequal", array(
'respident' =>
"LongMenu_" . $real_id), $value);
160 $xml->xmlEndTag(
"or");
164 $xml->xmlEndTag(
"and");
167 $xml->xmlEndTag(
"conditionvar");
168 $xml->xmlElement(
"displayfeedback", array(
'feedbacktype' =>
"Response",
'linkrefid' =>
'response_allcorrect'));
169 $xml->xmlEndTag(
"respcondition");
172 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
176 if (strlen($feedback_onenotcorrect)) {
177 $xml->xmlStartTag(
"respcondition", array(
'continue' =>
'Yes'));
178 $xml->xmlStartTag(
"conditionvar");
179 $xml->xmlStartTag(
"not");
180 foreach ($correct_answers as
$key => $values) {
183 $xml->xmlStartTag(
"and");
186 foreach ($values[0] as
$index => $value) {
188 $xml->xmlStartTag(
"or");
190 $xml->xmlElement(
"varequal", array(
'respident' =>
"LongMenu_" . $real_id), $value);
192 $xml->xmlEndTag(
"or");
196 $xml->xmlEndTag(
"and");
199 $xml->xmlEndTag(
"not");
200 $xml->xmlEndTag(
"conditionvar");
201 $xml->xmlElement(
"displayfeedback", array(
'feedbacktype' =>
"Response",
'linkrefid' =>
'response_onenotcorrect'));
202 $xml->xmlEndTag(
"respcondition");
205 $xml->xmlEndTag(
"resprocessing");
210 for (
$i = 0;
$i <
sizeof($correct_answers);
$i++) {
215 $xml->xmlStartTag(
"itemfeedback", $attrs);
217 $xml->xmlStartTag(
"flow_mat");
218 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
223 $this->
object->addQTIMaterial(
$xml, $fb);
224 $xml->xmlEndTag(
"flow_mat");
225 $xml->xmlEndTag(
"itemfeedback");
228 if (strlen($feedback_allcorrect) > 0) {
229 $xml->xmlStartTag(
"itemfeedback", array(
'ident' =>
'response_allcorrect',
'view' =>
'All'));
230 $xml->xmlStartTag(
"flow_mat");
231 $xml->xmlStartTag(
"material");
232 $xml->xmlElement(
"mattext", array(
'texttype' =>
'text/xhtml'), $feedback_allcorrect);
233 $xml->xmlEndTag(
"material");
234 $xml->xmlEndTag(
"flow_mat");
235 $xml->xmlEndTag(
"itemfeedback");
237 if (strlen($feedback_onenotcorrect) > 0) {
238 $xml->xmlStartTag(
"itemfeedback", array(
'ident' =>
'response_onenotcorrect',
'view' =>
'All'));
239 $xml->xmlStartTag(
"flow_mat");
240 $xml->xmlStartTag(
"material");
241 $xml->xmlElement(
"mattext", array(
'texttype' =>
'text/xhtml'), $feedback_onenotcorrect);
242 $xml->xmlEndTag(
"material");
243 $xml->xmlEndTag(
"flow_mat");
244 $xml->xmlEndTag(
"itemfeedback");
249 $xml->xmlEndTag(
"item");
250 $xml->xmlEndTag(
"questestinterop");
253 if (!$a_include_header) {
254 $pos = strpos(
$xml,
"?>");
const LONG_MENU_QUESTION_IDENTIFIER
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addGeneralMetadata(ilXmlWriter $xmlwriter)
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
addSolutionHints(ilXmlWriter $writer)