Returns a QTI xml representation of the question Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation @access public.
35 : string
36 {
38 $ilias =
$DIC[
'ilias'];
39
40 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
42
43 $a_xml_writer->xmlHeader();
44 $a_xml_writer->xmlStartTag("questestinterop");
45 $attrs = array(
47 "title" => $this->object->getTitle(),
48 "maxattempts" => $this->object->getNrOfTries()
49 );
50 $a_xml_writer->xmlStartTag("item", $attrs);
51
52 $a_xml_writer->xmlElement(
"qticomment",
null, $this->
object->getComment());
53 $a_xml_writer->xmlStartTag("itemmetadata");
54 $a_xml_writer->xmlStartTag("qtimetadata");
55 $a_xml_writer->xmlStartTag("qtimetadatafield");
56 $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
57 $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
58 $a_xml_writer->xmlEndTag("qtimetadatafield");
59 $a_xml_writer->xmlStartTag("qtimetadatafield");
60 $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
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");
67
68
71
72 $a_xml_writer->xmlStartTag("qtimetadatafield");
73 $a_xml_writer->xmlElement("fieldlabel", null, "thumb_size");
74 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getThumbSize());
75 $a_xml_writer->xmlEndTag("qtimetadatafield");
76
77 $a_xml_writer->xmlStartTag("qtimetadatafield");
78 $a_xml_writer->xmlElement("fieldlabel", null, "feedback_setting");
79 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getSpecificFeedbackSetting());
80 $a_xml_writer->xmlEndTag("qtimetadatafield");
81
83
84 $a_xml_writer->xmlEndTag("qtimetadata");
85 $a_xml_writer->xmlEndTag("itemmetadata");
86
87
88 $attrs = array(
89 "label" => $this->
object->getTitle()
90 );
91 $a_xml_writer->xmlStartTag("presentation", $attrs);
92
93 $a_xml_writer->xmlStartTag("flow");
94
95 $this->
object->addQTIMaterial($a_xml_writer, $this->
object->getQuestion());
96
97 $attrs = array(
98 "ident" => "MCMR",
99 "rcardinality" => "Multiple"
100 );
101 $a_xml_writer->xmlStartTag("response_lid", $attrs);
102 $solution = $this->object->getSuggestedSolution(0);
103 if ($solution !== null && count($solution)) {
104 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) {
105 $a_xml_writer->xmlStartTag("material");
106 $intlink =
"il_" .
IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
107 if (strcmp($matches[1], "") != 0) {
108 $intlink = $solution["internal_link"];
109 }
110 $attrs = array(
111 "label" => "suggested_solution"
112 );
113 $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
114 $a_xml_writer->xmlEndTag("material");
115 }
116 }
117
118 $attrs = array(
'shuffle' => $this->
object->getShuffle() ?
'Yes' :
'No');
119 if ($this->
object->getSelectionLimit()) {
120 $attrs['minnumber'] = '0';
121 $attrs[
'maxnumber'] = (string) $this->
object->getSelectionLimit();
122 }
123 $a_xml_writer->xmlStartTag("render_choice", $attrs);
124 $answers = &$this->object->getAnswers();
125 $akeys = array_keys($answers);
126 if ($this->
object->getShuffle() && $a_shuffle) {
127 $akeys = shuffle($akeys);
128 }
129
130 foreach ($akeys as
$index) {
131 $answer = $answers[
$index];
132 $attrs = array(
134 );
135 $a_xml_writer->xmlStartTag("response_label", $attrs);
136
137 if (strlen($answer->getImage())) {
138 $this->object->addQTIMaterial($a_xml_writer, $answer->getAnswertext(), false, false);
139 $imagetype = "image/jpeg";
140 if (preg_match("/.*\.(png|gif)$/", $answer->getImage(), $matches)) {
141 $imagetype = "image/" . $matches[1];
142 }
143 if ($force_image_references) {
144 $attrs = array(
145 "imagtype" => $imagetype,
146 "label" => $answer->getImage(),
147 "uri" => $this->object->getImagePathWeb() . $answer->getImage()
148 );
149 $a_xml_writer->xmlElement("matimage", $attrs);
150 } else {
151 $imagepath = $this->object->getImagePath() . $answer->getImage();
152 $fh = @fopen($imagepath, "rb");
153 if ($fh != false) {
154 $imagefile = fread($fh, filesize($imagepath));
155 fclose($fh);
156 $base64 = base64_encode($imagefile);
157 $attrs = array(
158 "imagtype" => $imagetype,
159 "label" => $answer->getImage(),
160 "embedded" => "base64"
161 );
162 $a_xml_writer->xmlElement("matimage", $attrs, $base64, false, false);
163 }
164 }
165 $a_xml_writer->xmlEndTag("material");
166 } else {
167 $this->object->addQTIMaterial($a_xml_writer, $answer->getAnswertext());
168 }
169 $a_xml_writer->xmlEndTag("response_label");
170 }
171 $a_xml_writer->xmlEndTag("render_choice");
172 $a_xml_writer->xmlEndTag("response_lid");
173 $a_xml_writer->xmlEndTag("flow");
174 $a_xml_writer->xmlEndTag("presentation");
175
176
177 $a_xml_writer->xmlStartTag("resprocessing");
178 $a_xml_writer->xmlStartTag("outcomes");
179 $a_xml_writer->xmlStartTag("decvar");
180 $a_xml_writer->xmlEndTag("decvar");
181 $a_xml_writer->xmlEndTag("outcomes");
182
183 foreach ($answers as
$index => $answer) {
184 $attrs = array(
185 "continue" => "Yes"
186 );
187 $a_xml_writer->xmlStartTag("respcondition", $attrs);
188
189 $a_xml_writer->xmlStartTag("conditionvar");
190 $attrs = array(
191 "respident" => "MCMR"
192 );
193 $a_xml_writer->xmlElement(
"varequal", $attrs,
$index);
194 $a_xml_writer->xmlEndTag("conditionvar");
195
196 $attrs = array(
197 "action" => "Add"
198 );
199 $a_xml_writer->xmlElement("setvar", $attrs, $answer->getPoints());
200
201 $linkrefid = "response_$index";
202 $attrs = array(
203 "feedbacktype" => "Response",
204 "linkrefid" => $linkrefid
205 );
206 $a_xml_writer->xmlElement("displayfeedback", $attrs);
207 $a_xml_writer->xmlEndTag("respcondition");
208 $attrs = array(
209 "continue" => "Yes"
210 );
211 $a_xml_writer->xmlStartTag("respcondition", $attrs);
212
213
214 $a_xml_writer->xmlStartTag("conditionvar");
215 $attrs = array(
216 "respident" => "MCMR"
217 );
218 $a_xml_writer->xmlStartTag("not");
219 $a_xml_writer->xmlElement(
"varequal", $attrs,
$index);
220 $a_xml_writer->xmlEndTag("not");
221 $a_xml_writer->xmlEndTag("conditionvar");
222
223 $attrs = array(
224 "action" => "Add"
225 );
226 $a_xml_writer->xmlElement("setvar", $attrs, $answer->getPointsUnchecked());
227 $a_xml_writer->xmlEndTag("respcondition");
228 }
229 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
231 true
232 );
233 if (strlen($feedback_allcorrect)) {
234 $attrs = array(
235 "continue" => "Yes"
236 );
237 $a_xml_writer->xmlStartTag("respcondition", $attrs);
238
239 $a_xml_writer->xmlStartTag("conditionvar");
240 foreach ($answers as
$index => $answer) {
241 if ($answer->getPointsChecked() < $answer->getPointsUnchecked()) {
242 $a_xml_writer->xmlStartTag("not");
243 }
244 $attrs = array(
245 "respident" => "MCMR"
246 );
247 $a_xml_writer->xmlElement(
"varequal", $attrs,
$index);
248 if ($answer->getPointsChecked() < $answer->getPointsUnchecked()) {
249 $a_xml_writer->xmlEndTag("not");
250 }
251 }
252 $a_xml_writer->xmlEndTag("conditionvar");
253
254 $attrs = array(
255 "feedbacktype" => "Response",
256 "linkrefid" => "response_allcorrect"
257 );
258 $a_xml_writer->xmlElement("displayfeedback", $attrs);
259 $a_xml_writer->xmlEndTag("respcondition");
260 }
261 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
263 false
264 );
265 if (strlen($feedback_onenotcorrect)) {
266 $attrs = array(
267 "continue" => "Yes"
268 );
269 $a_xml_writer->xmlStartTag("respcondition", $attrs);
270
271 $a_xml_writer->xmlStartTag("conditionvar");
272 foreach ($answers as
$index => $answer) {
274 $a_xml_writer->xmlStartTag("or");
275 }
276 if ($answer->getPointsChecked() >= $answer->getPointsUnchecked()) {
277 $a_xml_writer->xmlStartTag("not");
278 }
279 $attrs = array(
280 "respident" => "MCMR"
281 );
282 $a_xml_writer->xmlElement(
"varequal", $attrs,
$index);
283 if ($answer->getPointsChecked() >= $answer->getPointsUnchecked()) {
284 $a_xml_writer->xmlEndTag("not");
285 }
287 $a_xml_writer->xmlEndTag("or");
288 }
289 }
290 $a_xml_writer->xmlEndTag("conditionvar");
291
292 $attrs = array(
293 "feedbacktype" => "Response",
294 "linkrefid" => "response_onenotcorrect"
295 );
296 $a_xml_writer->xmlElement("displayfeedback", $attrs);
297 $a_xml_writer->xmlEndTag("respcondition");
298 }
299 $a_xml_writer->xmlEndTag("resprocessing");
300
301
302 foreach ($answers as
$index => $answer) {
303 $linkrefid = "response_$index";
304 $attrs = array(
305 "ident" => $linkrefid,
306 "view" => "All"
307 );
308 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
309
310 $a_xml_writer->xmlStartTag("flow_mat");
311 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
313 0,
314 $index
315 );
316 $this->object->addQTIMaterial($a_xml_writer, $fb);
317 $a_xml_writer->xmlEndTag("flow_mat");
318 $a_xml_writer->xmlEndTag("itemfeedback");
319 }
320 if (strlen($feedback_allcorrect)) {
321 $attrs = array(
322 "ident" => "response_allcorrect",
323 "view" => "All"
324 );
325 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
326
327 $a_xml_writer->xmlStartTag("flow_mat");
328 $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
329 $a_xml_writer->xmlEndTag("flow_mat");
330 $a_xml_writer->xmlEndTag("itemfeedback");
331 }
332 if (strlen($feedback_onenotcorrect)) {
333 $attrs = array(
334 "ident" => "response_onenotcorrect",
335 "view" => "All"
336 );
337 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
338
339 $a_xml_writer->xmlStartTag("flow_mat");
340 $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
341 $a_xml_writer->xmlEndTag("flow_mat");
342 $a_xml_writer->xmlEndTag("itemfeedback");
343 }
344
346
347 $a_xml_writer->xmlEndTag("item");
348 $a_xml_writer->xmlEndTag("questestinterop");
349
350 $xml = $a_xml_writer->xmlDumpMem(
false);
351 if (!$a_include_header) {
352 $pos = strpos(
$xml,
"?>");
354 }
356 }
addGeneralMetadata(ilXmlWriter $xmlwriter)
addQtiMetaDataField(ilXmlWriter $a_xml_writer, $fieldLabel, $fieldValue)
adds a qti meta data field with given name and value to the passed xml writer (xml writer must be in ...
addSolutionHints(ilXmlWriter $writer)
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER