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
36 $ilias = $DIC[
'ilias'];
38 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
42 $a_xml_writer->xmlStartTag(
"questestinterop");
44 "ident" =>
"il_" . IL_INST_ID .
"_qst_" . $this->object->getId(),
45 "title" => $this->
object->getTitle(),
46 "maxattempts" => $this->
object->getNrOfTries()
48 $a_xml_writer->xmlStartTag(
"item", $attrs);
50 $a_xml_writer->xmlElement(
"qticomment", null, $this->object->getComment());
52 $workingtime = $this->
object->getEstimatedWorkingTime();
53 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
54 $a_xml_writer->xmlElement(
"duration", null, $duration);
56 $a_xml_writer->xmlStartTag(
"itemmetadata");
57 $a_xml_writer->xmlStartTag(
"qtimetadata");
58 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
59 $a_xml_writer->xmlElement(
"fieldlabel", null,
"ILIAS_VERSION");
60 $a_xml_writer->xmlElement(
"fieldentry", null, $ilias->getSetting(
"ilias_version"));
61 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
62 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
63 $a_xml_writer->xmlElement(
"fieldlabel", null,
"QUESTIONTYPE");
65 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
66 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
67 $a_xml_writer->xmlElement(
"fieldlabel", null,
"AUTHOR");
68 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getAuthor());
69 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
75 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
76 $a_xml_writer->xmlElement(
"fieldlabel", null,
"thumb_geometry");
77 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getThumbGeometry());
78 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
79 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
80 $a_xml_writer->xmlElement(
"fieldlabel", null,
"element_height");
81 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getElementHeight());
82 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
83 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
84 $a_xml_writer->xmlElement(
"fieldlabel", null,
"points");
85 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getPoints());
86 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
87 $a_xml_writer->xmlEndTag(
"qtimetadata");
88 $a_xml_writer->xmlEndTag(
"itemmetadata");
92 "label" => $this->object->getTitle()
94 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
96 $a_xml_writer->xmlStartTag(
"flow");
98 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
102 if ($this->object->getOrderingType() ==
OQ_PICTURES) {
103 $ordering_type =
'OQP';
105 $ordering_type =
'OQNP';
107 $ordering_type =
'OQNT';
108 } elseif ($this->object->getOrderingType() ==
OQ_TERMS) {
109 $ordering_type =
'OQT';
113 "ident" => $ordering_type,
114 "rcardinality" =>
"Ordered" 118 $attrs[
"output"] =
"javascript";
120 $a_xml_writer->xmlStartTag(
"response_lid", $attrs);
121 $solution = $this->
object->getSuggestedSolution(0);
122 if (count($solution)) {
123 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
124 $a_xml_writer->xmlStartTag(
"material");
125 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
126 if (strcmp($matches[1],
"") != 0) {
127 $intlink = $solution[
"internal_link"];
130 "label" =>
"suggested_solution" 132 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
133 $a_xml_writer->xmlEndTag(
"material");
138 if ($this->object->getShuffle()) {
147 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
150 foreach ($this->object->getOrderingElementList() as $element) {
152 'ident' => $element->getExportIdent()
154 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
155 if ($this->object->getOrderingType() ==
OQ_PICTURES 157 $imagetype =
"image/jpeg";
159 $a_xml_writer->xmlStartTag(
"material");
160 if ($force_image_references) {
162 "imagtype" => $imagetype,
163 "label" => $element->getContent(),
164 "uri" => $this->
object->getImagePathWeb() . $element->getContent()
166 $a_xml_writer->xmlElement(
"matimage", $attrs);
168 $imagepath = $this->
object->getImagePath() . $element->getContent();
169 $fh = @
fopen($imagepath,
"rb");
171 $imagefile = fread($fh, filesize($imagepath));
173 $base64 = base64_encode($imagefile);
175 if (preg_match(
"/.*\.(png|gif)$/", $element->getContent(), $matches)) {
176 $imagetype =
"image/" . $matches[1];
179 "imagtype" => $imagetype,
180 "label" => $element->getContent(),
181 "embedded" =>
"base64" 183 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
186 $a_xml_writer->xmlEndTag(
"material");
187 } elseif ($this->object->getOrderingType() ==
OQ_TERMS 189 $a_xml_writer->xmlStartTag(
"material");
190 $this->
object->addQTIMaterial($a_xml_writer, $element->getContent(),
true,
false);
191 $a_xml_writer->xmlEndTag(
"material");
192 $a_xml_writer->xmlStartTag(
"material");
193 $attrs = array(
"label" =>
"answerdepth");
194 $a_xml_writer->xmlElement(
"mattext", $attrs, $element->getIndentation());
195 $a_xml_writer->xmlEndTag(
"material");
197 $a_xml_writer->xmlEndTag(
"response_label");
199 $a_xml_writer->xmlEndTag(
"render_choice");
200 $a_xml_writer->xmlEndTag(
"response_lid");
201 $a_xml_writer->xmlEndTag(
"flow");
202 $a_xml_writer->xmlEndTag(
"presentation");
205 $a_xml_writer->xmlStartTag(
"resprocessing");
206 $a_xml_writer->xmlStartTag(
"outcomes");
207 $a_xml_writer->xmlStartTag(
"decvar");
208 $a_xml_writer->xmlEndTag(
"decvar");
209 $a_xml_writer->xmlEndTag(
"outcomes");
211 foreach ($this->object->getOrderingElementList() as $element) {
215 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
217 $a_xml_writer->xmlStartTag(
"conditionvar");
220 if ($this->object->getOrderingType() ==
OQ_PICTURES) {
221 $ordering_type =
'OQP';
223 $ordering_type =
'OQNP';
225 $ordering_type =
'OQNT';
226 } elseif ($this->object->getOrderingType() ==
OQ_TERMS) {
227 $ordering_type =
'OQT';
230 $attrs = array(
"respident" => $ordering_type);
232 $attrs[
"index"] = $element->getPosition();
233 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
234 $a_xml_writer->xmlEndTag(
"conditionvar");
239 $points = $this->
object->getPoints() / $this->
object->getOrderingElementList()->countElements();
240 $a_xml_writer->xmlElement(
"setvar", $attrs, $points);
243 "feedbacktype" =>
"Response",
244 "linkrefid" =>
"link_" . $element->getPosition()
246 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
247 $a_xml_writer->xmlEndTag(
"respcondition");
250 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
251 $this->object->getId(),
254 if (strlen($feedback_allcorrect)) {
258 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
260 $a_xml_writer->xmlStartTag(
"conditionvar");
262 foreach ($this->object->getOrderingElementList() as $element) {
265 if ($this->object->getOrderingType() ==
OQ_PICTURES) {
266 $ordering_type =
'OQP';
268 $ordering_type =
'OQNP';
270 $ordering_type =
'OQNT';
271 } elseif ($this->object->getOrderingType() ==
OQ_TERMS) {
272 $ordering_type =
'OQT';
275 $attrs = array(
"respident" => $ordering_type);
277 $attrs[
"index"] = $element->getPosition();
278 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
281 $a_xml_writer->xmlEndTag(
"conditionvar");
284 "feedbacktype" =>
"Response",
285 "linkrefid" =>
"response_allcorrect" 287 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
288 $a_xml_writer->xmlEndTag(
"respcondition");
291 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
292 $this->object->getId(),
295 if (strlen($feedback_onenotcorrect)) {
299 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
301 $a_xml_writer->xmlStartTag(
"conditionvar");
302 $a_xml_writer->xmlStartTag(
"not");
304 foreach ($this->object->getOrderingElementList() as $element) {
306 if ($this->object->getOrderingType() ==
OQ_PICTURES) {
307 $ordering_type =
'OQP';
309 $ordering_type =
'OQNP';
311 $ordering_type =
'OQNT';
312 } elseif ($this->object->getOrderingType() ==
OQ_TERMS) {
313 $ordering_type =
'OQT';
316 $attrs = array(
"respident" => $ordering_type);
318 $attrs[
"index"] = $element->getPosition();
319 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
322 $a_xml_writer->xmlEndTag(
"not");
323 $a_xml_writer->xmlEndTag(
"conditionvar");
326 "feedbacktype" =>
"Response",
327 "linkrefid" =>
"response_onenotcorrect" 329 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
330 $a_xml_writer->xmlEndTag(
"respcondition");
333 $a_xml_writer->xmlEndTag(
"resprocessing");
336 foreach ($this->object->getOrderingElementList() as $element) {
338 "ident" =>
"link_" . $element->getPosition(),
341 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
343 $a_xml_writer->xmlStartTag(
"flow_mat");
344 $a_xml_writer->xmlStartTag(
"material");
345 $a_xml_writer->xmlElement(
"mattext", null, $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
346 $this->object->getId(),
348 $element->getPosition()
350 $a_xml_writer->xmlEndTag(
"material");
351 $a_xml_writer->xmlEndTag(
"flow_mat");
352 $a_xml_writer->xmlEndTag(
"itemfeedback");
355 if (strlen($feedback_allcorrect)) {
357 "ident" =>
"response_allcorrect",
360 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
362 $a_xml_writer->xmlStartTag(
"flow_mat");
363 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
364 $a_xml_writer->xmlEndTag(
"flow_mat");
365 $a_xml_writer->xmlEndTag(
"itemfeedback");
367 if (strlen($feedback_onenotcorrect)) {
369 "ident" =>
"response_onenotcorrect",
372 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
374 $a_xml_writer->xmlStartTag(
"flow_mat");
375 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
376 $a_xml_writer->xmlEndTag(
"flow_mat");
377 $a_xml_writer->xmlEndTag(
"itemfeedback");
380 $a_xml_writer->xmlEndTag(
"item");
381 $a_xml_writer->xmlEndTag(
"questestinterop");
383 $xml = $a_xml_writer->xmlDumpMem(
false);
384 if (!$a_include_header) {
385 $pos = strpos(
$xml,
"?>");
addGeneralMetadata(ilXmlWriter $xmlwriter)
const OQ_PICTURES
Ordering question constants.
const ORDERING_QUESTION_IDENTIFIER
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...