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
37 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
41 $a_xml_writer->xmlStartTag(
"questestinterop");
43 "ident" =>
"il_" . IL_INST_ID .
"_qst_" . $this->
object->getId(),
44 "title" => $this->
object->getTitle(),
45 "maxattempts" => $this->
object->getNrOfTries()
47 $a_xml_writer->xmlStartTag(
"item", $attrs);
49 $a_xml_writer->xmlElement(
"qticomment", null, $this->
object->getComment());
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);
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");
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");
91 "label" => $this->
object->getTitle()
93 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
95 $a_xml_writer->xmlStartTag(
"flow");
97 $this->
object->addQTIMaterial($a_xml_writer, $this->
object->getQuestion());
102 $ordering_type =
'OQP';
104 $ordering_type =
'OQNP';
106 $ordering_type =
'OQNT';
108 $ordering_type =
'OQT';
112 "ident" => $ordering_type,
113 "rcardinality" =>
"Ordered" 117 $attrs[
"output"] =
"javascript";
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"];
129 "label" =>
"suggested_solution" 131 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
132 $a_xml_writer->xmlEndTag(
"material");
137 if ($this->
object->getShuffle()) {
146 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
149 foreach ($this->
object->getOrderingElementList() as $element) {
151 'ident' => $element->getExportIdent()
153 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
156 $imagetype =
"image/jpeg";
158 $a_xml_writer->xmlStartTag(
"material");
159 if ($force_image_references) {
161 "imagtype" => $imagetype,
162 "label" => $element->getContent(),
163 "uri" => $this->
object->getImagePathWeb() . $element->getContent()
165 $a_xml_writer->xmlElement(
"matimage", $attrs);
167 $imagepath = $this->
object->getImagePath() . $element->getContent();
168 $fh = @fopen($imagepath,
"rb");
170 $imagefile = fread(
$fh, filesize($imagepath));
172 $base64 = base64_encode($imagefile);
174 if (preg_match(
"/.*\.(png|gif)$/", $element->getContent(), $matches)) {
175 $imagetype =
"image/" . $matches[1];
178 "imagtype" => $imagetype,
179 "label" => $element->getContent(),
180 "embedded" =>
"base64" 182 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
185 $a_xml_writer->xmlEndTag(
"material");
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");
196 $a_xml_writer->xmlEndTag(
"response_label");
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");
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");
210 foreach ($this->
object->getOrderingElementList() as $element) {
214 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
216 $a_xml_writer->xmlStartTag(
"conditionvar");
220 $ordering_type =
'OQP';
222 $ordering_type =
'OQNP';
224 $ordering_type =
'OQNT';
226 $ordering_type =
'OQT';
229 $attrs =
array(
"respident" => $ordering_type);
231 $attrs[
"index"] = $element->getPosition();
232 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
233 $a_xml_writer->xmlEndTag(
"conditionvar");
238 $points = $this->
object->getPoints() / $this->
object->getOrderingElementList()->countElements();
239 $a_xml_writer->xmlElement(
"setvar", $attrs, $points);
242 "feedbacktype" =>
"Response",
243 "linkrefid" =>
"link_" . $element->getPosition()
245 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
246 $a_xml_writer->xmlEndTag(
"respcondition");
249 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
253 if (strlen($feedback_allcorrect)) {
257 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
259 $a_xml_writer->xmlStartTag(
"conditionvar");
261 foreach ($this->
object->getOrderingElementList() as $element) {
265 $ordering_type =
'OQP';
267 $ordering_type =
'OQNP';
269 $ordering_type =
'OQNT';
271 $ordering_type =
'OQT';
274 $attrs =
array(
"respident" => $ordering_type);
276 $attrs[
"index"] = $element->getPosition();
277 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
280 $a_xml_writer->xmlEndTag(
"conditionvar");
283 "feedbacktype" =>
"Response",
284 "linkrefid" =>
"response_allcorrect" 286 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
287 $a_xml_writer->xmlEndTag(
"respcondition");
290 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
294 if (strlen($feedback_onenotcorrect)) {
298 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
300 $a_xml_writer->xmlStartTag(
"conditionvar");
301 $a_xml_writer->xmlStartTag(
"not");
303 foreach ($this->
object->getOrderingElementList() as $element) {
306 $ordering_type =
'OQP';
308 $ordering_type =
'OQNP';
310 $ordering_type =
'OQNT';
312 $ordering_type =
'OQT';
315 $attrs =
array(
"respident" => $ordering_type);
317 $attrs[
"index"] = $element->getPosition();
318 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
321 $a_xml_writer->xmlEndTag(
"not");
322 $a_xml_writer->xmlEndTag(
"conditionvar");
325 "feedbacktype" =>
"Response",
326 "linkrefid" =>
"response_onenotcorrect" 328 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
329 $a_xml_writer->xmlEndTag(
"respcondition");
332 $a_xml_writer->xmlEndTag(
"resprocessing");
335 foreach ($this->
object->getOrderingElementList() as $element) {
337 "ident" =>
"link_" . $element->getPosition(),
340 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
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()
348 $a_xml_writer->xmlEndTag(
"material");
349 $a_xml_writer->xmlEndTag(
"flow_mat");
350 $a_xml_writer->xmlEndTag(
"itemfeedback");
353 if (strlen($feedback_allcorrect)) {
355 "ident" =>
"response_allcorrect",
358 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
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");
365 if (strlen($feedback_onenotcorrect)) {
367 "ident" =>
"response_onenotcorrect",
370 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
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");
378 $a_xml_writer->xmlEndTag(
"item");
379 $a_xml_writer->xmlEndTag(
"questestinterop");
381 $xml = $a_xml_writer->xmlDumpMem(
false);
382 if (!$a_include_header) {
383 $pos = strpos(
$xml,
"?>");
addGeneralMetadata(ilXmlWriter $xmlwriter)
const OQ_PICTURES
Ordering question constants.
const ORDERING_QUESTION_IDENTIFIER
xmlHeader()
Writes xml header public.
Create styles array
The data for the language used.
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
Create new PHPExcel object
obj_idprivate