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
30 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
34 $a_xml_writer->xmlStartTag(
"questestinterop");
36 "ident" =>
"il_".IL_INST_ID.
"_qst_".$this->object->getId(),
37 "title" => $this->
object->getTitle(),
38 "maxattempts" => $this->
object->getNrOfTries()
40 $a_xml_writer->xmlStartTag(
"item", $attrs);
42 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->object->getComment());
44 $workingtime = $this->
object->getEstimatedWorkingTime();
45 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
46 $a_xml_writer->xmlElement(
"duration", NULL, $duration);
48 $a_xml_writer->xmlStartTag(
"itemmetadata");
49 $a_xml_writer->xmlStartTag(
"qtimetadata");
50 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
51 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
52 $a_xml_writer->xmlElement(
"fieldentry", NULL, $ilias->getSetting(
"ilias_version"));
53 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
54 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
55 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"QUESTIONTYPE");
57 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
58 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
59 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"AUTHOR");
60 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getAuthor());
61 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
67 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
68 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"thumb_size");
69 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getThumbSize());
70 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
72 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
73 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"feedback_setting");
74 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getSpecificFeedbackSetting());
75 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
77 $a_xml_writer->xmlEndTag(
"qtimetadata");
78 $a_xml_writer->xmlEndTag(
"itemmetadata");
82 "label" => $this->object->getTitle()
84 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
86 $a_xml_writer->xmlStartTag(
"flow");
88 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
93 "rcardinality" =>
"Single" 95 $a_xml_writer->xmlStartTag(
"response_lid", $attrs);
96 $solution = $this->
object->getSuggestedSolution(0);
99 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
101 $a_xml_writer->xmlStartTag(
"material");
102 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
103 if (strcmp($matches[1],
"") != 0)
105 $intlink = $solution[
"internal_link"];
108 "label" =>
"suggested_solution" 110 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
111 $a_xml_writer->xmlEndTag(
"material");
116 if ($this->object->getShuffle())
128 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
129 $answers =& $this->
object->getAnswers();
130 $akeys = array_keys($answers);
131 if ($this->object->getShuffle() && $a_shuffle)
133 $akeys = $this->
object->pcArrayShuffle($akeys);
136 foreach ($akeys as $index)
138 $answer = $answers[$index];
142 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
144 if (strlen($answer->getImage()))
146 $this->
object->addQTIMaterial($a_xml_writer, $answer->getAnswertext(), FALSE, FALSE);
147 $imagetype =
"image/jpeg";
148 if (preg_match(
"/.*\.(png|gif)$/", $answer->getImage(), $matches))
150 $imagetype =
"image/" . $matches[1];
152 if ($force_image_references)
155 "imagtype" => $imagetype,
156 "label" => $answer->getImage(),
157 "uri" => $this->
object->getImagePathWeb() . $answer->getImage()
159 $a_xml_writer->xmlElement(
"matimage", $attrs);
163 $imagepath = $this->
object->getImagePath() . $answer->getImage();
164 $fh = @fopen($imagepath,
"rb");
167 $imagefile = fread($fh, filesize($imagepath));
169 $base64 = base64_encode($imagefile);
171 "imagtype" => $imagetype,
172 "label" => $answer->getImage(),
173 "embedded" =>
"base64" 175 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, FALSE, FALSE);
178 $a_xml_writer->xmlEndTag(
"material");
182 $this->
object->addQTIMaterial($a_xml_writer, $answer->getAnswertext());
184 $a_xml_writer->xmlEndTag(
"response_label");
186 $a_xml_writer->xmlEndTag(
"render_choice");
187 $a_xml_writer->xmlEndTag(
"response_lid");
188 $a_xml_writer->xmlEndTag(
"flow");
189 $a_xml_writer->xmlEndTag(
"presentation");
192 $a_xml_writer->xmlStartTag(
"resprocessing");
193 $a_xml_writer->xmlStartTag(
"outcomes");
194 $a_xml_writer->xmlStartTag(
"decvar");
195 $a_xml_writer->xmlEndTag(
"decvar");
196 $a_xml_writer->xmlEndTag(
"outcomes");
198 foreach ($answers as $index => $answer)
203 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
205 $a_xml_writer->xmlStartTag(
"conditionvar");
208 "respident" =>
"MCSR" 210 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
211 $a_xml_writer->xmlEndTag(
"conditionvar");
216 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
218 $linkrefid =
"response_$index";
220 "feedbacktype" =>
"Response",
221 "linkrefid" => $linkrefid
223 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
224 $a_xml_writer->xmlEndTag(
"respcondition");
227 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
228 $this->object->getId(), true
230 if (strlen($feedback_allcorrect))
235 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
237 $a_xml_writer->xmlStartTag(
"conditionvar");
240 foreach ($answers as $index => $answer)
242 if ($answer->getPoints() > $maxpoints)
244 $maxpoints = $answer->getPoints();
249 "respident" =>
"MCSR" 251 $a_xml_writer->xmlElement(
"varequal", $attrs, $bestindex);
252 $a_xml_writer->xmlEndTag(
"conditionvar");
255 "feedbacktype" =>
"Response",
256 "linkrefid" =>
"response_allcorrect" 258 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
259 $a_xml_writer->xmlEndTag(
"respcondition");
262 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
263 $this->object->getId(), false
265 if (strlen($feedback_onenotcorrect))
270 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
272 $a_xml_writer->xmlStartTag(
"conditionvar");
275 foreach ($answers as $index => $answer)
277 if ($answer->getPoints() > $maxpoints)
279 $maxpoints = $answer->getPoints();
284 "respident" =>
"MCSR" 286 $a_xml_writer->xmlStartTag(
"not");
287 $a_xml_writer->xmlElement(
"varequal", $attrs, $bestindex);
288 $a_xml_writer->xmlEndTag(
"not");
289 $a_xml_writer->xmlEndTag(
"conditionvar");
292 "feedbacktype" =>
"Response",
293 "linkrefid" =>
"response_onenotcorrect" 295 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
296 $a_xml_writer->xmlEndTag(
"respcondition");
299 $a_xml_writer->xmlEndTag(
"resprocessing");
302 foreach ($answers as $index => $answer)
304 $linkrefid =
"response_$index";
306 "ident" => $linkrefid,
309 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
311 $a_xml_writer->xmlStartTag(
"flow_mat");
312 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
313 $this->object->getId(), $index
315 $this->
object->addQTIMaterial($a_xml_writer, $fb);
316 $a_xml_writer->xmlEndTag(
"flow_mat");
317 $a_xml_writer->xmlEndTag(
"itemfeedback");
319 if (strlen($feedback_allcorrect))
322 "ident" =>
"response_allcorrect",
325 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
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");
332 if (strlen($feedback_onenotcorrect))
335 "ident" =>
"response_onenotcorrect",
338 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
340 $a_xml_writer->xmlStartTag(
"flow_mat");
341 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
342 $a_xml_writer->xmlEndTag(
"flow_mat");
343 $a_xml_writer->xmlEndTag(
"itemfeedback");
346 $a_xml_writer->xmlEndTag(
"item");
347 $a_xml_writer->xmlEndTag(
"questestinterop");
349 $xml = $a_xml_writer->xmlDumpMem(FALSE);
350 if (!$a_include_header)
352 $pos = strpos($xml,
"?>");
353 $xml = substr($xml, $pos + 2);
addGeneralMetadata(ilXmlWriter $xmlwriter)
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...
const SINGLE_CHOICE_QUESTION_IDENTIFIER