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
32 {
35 global $ilias;
36
37 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
39
41 $a_xml_writer->xmlStartTag("questestinterop");
42 $attrs = array(
43 "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
44 "title" => $this->object->getTitle(),
45 "maxattempts" => $this->object->getNrOfTries()
46 );
47 $a_xml_writer->xmlStartTag("item", $attrs);
48
49 $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
50
51 $workingtime = $this->object->getEstimatedWorkingTime();
52 $duration =
sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
53 $a_xml_writer->xmlElement("duration", null, $duration);
54
55 $a_xml_writer->xmlStartTag("itemmetadata");
56 $a_xml_writer->xmlStartTag("qtimetadata");
57 $a_xml_writer->xmlStartTag("qtimetadatafield");
58 $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
59 $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
60 $a_xml_writer->xmlEndTag("qtimetadatafield");
61 $a_xml_writer->xmlStartTag("qtimetadatafield");
62 $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
64 $a_xml_writer->xmlEndTag("qtimetadatafield");
65 $a_xml_writer->xmlStartTag("qtimetadatafield");
66 $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
67 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getAuthor());
68 $a_xml_writer->xmlEndTag("qtimetadatafield");
69
70
73
74 $a_xml_writer->xmlStartTag("qtimetadatafield");
75 $a_xml_writer->xmlElement("fieldlabel", null, "thumb_geometry");
76 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getThumbGeometry());
77 $a_xml_writer->xmlEndTag("qtimetadatafield");
78 $a_xml_writer->xmlStartTag("qtimetadatafield");
79 $a_xml_writer->xmlElement("fieldlabel", null, "element_height");
80 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getElementHeight());
81 $a_xml_writer->xmlEndTag("qtimetadatafield");
82 $a_xml_writer->xmlStartTag("qtimetadatafield");
83 $a_xml_writer->xmlElement("fieldlabel", null, "points");
84 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getPoints());
85 $a_xml_writer->xmlEndTag("qtimetadatafield");
86 $a_xml_writer->xmlEndTag("qtimetadata");
87 $a_xml_writer->xmlEndTag("itemmetadata");
88
89
90 $attrs = array(
91 "label" => $this->object->getTitle()
92 );
93 $a_xml_writer->xmlStartTag("presentation", $attrs);
94
95 $a_xml_writer->xmlStartTag("flow");
96
97 $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
98
99 $attrs = array();
100
101 if ($this->object->getOrderingType() ==
OQ_PICTURES) {
102 $ordering_type ='OQP';
104 $ordering_type ='OQNP';
106 $ordering_type ='OQNT';
107 } elseif ($this->object->getOrderingType() ==
OQ_TERMS) {
108 $ordering_type ='OQT';
109 }
110
111 $attrs = array(
112 "ident" => $ordering_type,
113 "rcardinality" => "Ordered"
114 );
115
117 $attrs["output"] = "javascript";
118 }
119 $a_xml_writer->xmlStartTag("response_lid", $attrs);
120 $solution = $this->object->getSuggestedSolution(0);
121 if (count($solution)) {
122 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) {
123 $a_xml_writer->xmlStartTag("material");
124 $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
125 if (strcmp($matches[1], "") != 0) {
126 $intlink = $solution["internal_link"];
127 }
128 $attrs = array(
129 "label" => "suggested_solution"
130 );
131 $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
132 $a_xml_writer->xmlEndTag("material");
133 }
134 }
135
136 $attrs = array();
137 if ($this->object->getShuffle()) {
138 $attrs = array(
139 "shuffle" => "Yes"
140 );
141 } else {
142 $attrs = array(
143 "shuffle" => "No"
144 );
145 }
146 $a_xml_writer->xmlStartTag("render_choice", $attrs);
147
148
149 foreach ($this->object->getOrderingElementList() as $element) {
150 $attrs = array(
151 'ident' => $element->getExportIdent()
152 );
153 $a_xml_writer->xmlStartTag("response_label", $attrs);
154 if ($this->object->getOrderingType() ==
OQ_PICTURES
156 $imagetype = "image/jpeg";
157
158 $a_xml_writer->xmlStartTag("material");
159 if ($force_image_references) {
160 $attrs = array(
161 "imagtype" => $imagetype,
162 "label" => $element->getContent(),
163 "uri" => $this->object->getImagePathWeb() . $element->getContent()
164 );
165 $a_xml_writer->xmlElement("matimage", $attrs);
166 } else {
167 $imagepath = $this->object->getImagePath() . $element->getContent();
168 $fh = @fopen($imagepath,
"rb");
170 $imagefile = fread(
$fh, filesize($imagepath));
172 $base64 = base64_encode($imagefile);
173
174 if (preg_match("/.*\.(png|gif)$/", $element->getContent(), $matches)) {
175 $imagetype = "image/" . $matches[1];
176 }
177 $attrs = array(
178 "imagtype" => $imagetype,
179 "label" => $element->getContent(),
180 "embedded" => "base64"
181 );
182 $a_xml_writer->xmlElement("matimage", $attrs, $base64, false, false);
183 }
184 }
185 $a_xml_writer->xmlEndTag("material");
186 } elseif ($this->object->getOrderingType() ==
OQ_TERMS
188 $a_xml_writer->xmlStartTag("material");
189 $this->object->addQTIMaterial($a_xml_writer, $element->getContent(), true, false);
190 $a_xml_writer->xmlEndTag("material");
191 $a_xml_writer->xmlStartTag("material");
192 $attrs = array("label" => "answerdepth");
193 $a_xml_writer->xmlElement("mattext", $attrs, $element->getIndentation());
194 $a_xml_writer->xmlEndTag("material");
195 }
196 $a_xml_writer->xmlEndTag("response_label");
197 }
198 $a_xml_writer->xmlEndTag("render_choice");
199 $a_xml_writer->xmlEndTag("response_lid");
200 $a_xml_writer->xmlEndTag("flow");
201 $a_xml_writer->xmlEndTag("presentation");
202
203
204 $a_xml_writer->xmlStartTag("resprocessing");
205 $a_xml_writer->xmlStartTag("outcomes");
206 $a_xml_writer->xmlStartTag("decvar");
207 $a_xml_writer->xmlEndTag("decvar");
208 $a_xml_writer->xmlEndTag("outcomes");
209
210 foreach ($this->object->getOrderingElementList() as $element) {
211 $attrs = array(
212 "continue" => "Yes"
213 );
214 $a_xml_writer->xmlStartTag("respcondition", $attrs);
215
216 $a_xml_writer->xmlStartTag("conditionvar");
217 $attrs = array();
218
219 if ($this->object->getOrderingType() ==
OQ_PICTURES) {
220 $ordering_type ='OQP';
222 $ordering_type ='OQNP';
224 $ordering_type ='OQNT';
225 } elseif ($this->object->getOrderingType() ==
OQ_TERMS) {
226 $ordering_type ='OQT';
227 }
228
229 $attrs = array("respident" => $ordering_type);
230
231 $attrs["index"] = $element->getPosition();
232 $a_xml_writer->xmlElement("varequal", $attrs, $element->getPosition());
233 $a_xml_writer->xmlEndTag("conditionvar");
234
235 $attrs = array(
236 "action" => "Add"
237 );
238 $points = $this->object->getPoints() / $this->object->getOrderingElementList()->countElements();
239 $a_xml_writer->xmlElement("setvar", $attrs, $points);
240
241 $attrs = array(
242 "feedbacktype" => "Response",
243 "linkrefid" => "link_" . $element->getPosition()
244 );
245 $a_xml_writer->xmlElement("displayfeedback", $attrs);
246 $a_xml_writer->xmlEndTag("respcondition");
247 }
248
249 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
250 $this->object->getId(),
251 true
252 );
253 if (strlen($feedback_allcorrect)) {
254 $attrs = array(
255 "continue" => "Yes"
256 );
257 $a_xml_writer->xmlStartTag("respcondition", $attrs);
258
259 $a_xml_writer->xmlStartTag("conditionvar");
260
261 foreach ($this->object->getOrderingElementList() as $element) {
262 $attrs = array();
263
264 if ($this->object->getOrderingType() ==
OQ_PICTURES) {
265 $ordering_type ='OQP';
267 $ordering_type ='OQNP';
269 $ordering_type ='OQNT';
270 } elseif ($this->object->getOrderingType() ==
OQ_TERMS) {
271 $ordering_type ='OQT';
272 }
273
274 $attrs = array("respident" => $ordering_type);
275
276 $attrs["index"] = $element->getPosition();
277 $a_xml_writer->xmlElement("varequal", $attrs, $element->getPosition());
278 }
279
280 $a_xml_writer->xmlEndTag("conditionvar");
281
282 $attrs = array(
283 "feedbacktype" => "Response",
284 "linkrefid" => "response_allcorrect"
285 );
286 $a_xml_writer->xmlElement("displayfeedback", $attrs);
287 $a_xml_writer->xmlEndTag("respcondition");
288 }
289
290 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
291 $this->object->getId(),
292 false
293 );
294 if (strlen($feedback_onenotcorrect)) {
295 $attrs = array(
296 "continue" => "Yes"
297 );
298 $a_xml_writer->xmlStartTag("respcondition", $attrs);
299
300 $a_xml_writer->xmlStartTag("conditionvar");
301 $a_xml_writer->xmlStartTag("not");
302
303 foreach ($this->object->getOrderingElementList() as $element) {
304 $attrs = array();
305 if ($this->object->getOrderingType() ==
OQ_PICTURES) {
306 $ordering_type ='OQP';
308 $ordering_type ='OQNP';
310 $ordering_type ='OQNT';
311 } elseif ($this->object->getOrderingType() ==
OQ_TERMS) {
312 $ordering_type ='OQT';
313 }
314
315 $attrs = array("respident" => $ordering_type);
316
317 $attrs["index"] = $element->getPosition();
318 $a_xml_writer->xmlElement("varequal", $attrs, $element->getPosition());
319 }
320
321 $a_xml_writer->xmlEndTag("not");
322 $a_xml_writer->xmlEndTag("conditionvar");
323
324 $attrs = array(
325 "feedbacktype" => "Response",
326 "linkrefid" => "response_onenotcorrect"
327 );
328 $a_xml_writer->xmlElement("displayfeedback", $attrs);
329 $a_xml_writer->xmlEndTag("respcondition");
330 }
331
332 $a_xml_writer->xmlEndTag("resprocessing");
333
334
335 foreach ($this->object->getOrderingElementList() as $element) {
336 $attrs = array(
337 "ident" => "link_" . $element->getPosition(),
338 "view" => "All"
339 );
340 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
341
342 $a_xml_writer->xmlStartTag("flow_mat");
343 $a_xml_writer->xmlStartTag("material");
344 $a_xml_writer->xmlElement("mattext", null, $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
345 $this->object->getId(),
346 $element->getPosition()
347 ));
348 $a_xml_writer->xmlEndTag("material");
349 $a_xml_writer->xmlEndTag("flow_mat");
350 $a_xml_writer->xmlEndTag("itemfeedback");
351 }
352
353 if (strlen($feedback_allcorrect)) {
354 $attrs = array(
355 "ident" => "response_allcorrect",
356 "view" => "All"
357 );
358 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
359
360 $a_xml_writer->xmlStartTag("flow_mat");
361 $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
362 $a_xml_writer->xmlEndTag("flow_mat");
363 $a_xml_writer->xmlEndTag("itemfeedback");
364 }
365 if (strlen($feedback_onenotcorrect)) {
366 $attrs = array(
367 "ident" => "response_onenotcorrect",
368 "view" => "All"
369 );
370 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
371
372 $a_xml_writer->xmlStartTag("flow_mat");
373 $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
374 $a_xml_writer->xmlEndTag("flow_mat");
375 $a_xml_writer->xmlEndTag("itemfeedback");
376 }
377
378 $a_xml_writer->xmlEndTag("item");
379 $a_xml_writer->xmlEndTag("questestinterop");
380
381 $xml = $a_xml_writer->xmlDumpMem(
false);
382 if (!$a_include_header) {
383 $pos = strpos(
$xml,
"?>");
385 }
387 }
sprintf('%.4f', $callTime)
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...
xmlHeader()
Writes xml header @access public.
const OQ_PICTURES
Ordering question constants.
const ORDERING_QUESTION_IDENTIFIER