4 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
31 function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
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';
111 "ident" => $ordering_type,
112 "rcardinality" =>
"Ordered" 117 $attrs[
"output"] =
"javascript";
119 $a_xml_writer->xmlStartTag(
"response_lid", $attrs);
120 $solution = $this->
object->getSuggestedSolution(0);
121 if (count($solution))
123 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
125 $a_xml_writer->xmlStartTag(
"material");
126 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
127 if (strcmp($matches[1],
"") != 0)
129 $intlink = $solution[
"internal_link"];
132 "label" =>
"suggested_solution" 134 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
135 $a_xml_writer->xmlEndTag(
"material");
140 if ($this->
object->getShuffle())
152 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
155 foreach ($this->
object->getOrderingElementList() as $element)
158 'ident' => $element->getExportIdent()
160 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
164 $imagetype =
"image/jpeg";
166 $a_xml_writer->xmlStartTag(
"material");
167 if ($force_image_references)
170 "imagtype" => $imagetype,
171 "label" => $element->getContent(),
172 "uri" => $this->
object->getImagePathWeb() . $element->getContent()
174 $a_xml_writer->xmlElement(
"matimage", $attrs);
178 $imagepath = $this->
object->getImagePath() . $element->getContent();
179 $fh = @fopen($imagepath,
"rb");
182 $imagefile = fread(
$fh, filesize($imagepath));
184 $base64 = base64_encode($imagefile);
186 if (preg_match(
"/.*\.(png|gif)$/", $element->getContent(), $matches))
188 $imagetype =
"image/".$matches[1];
191 "imagtype" => $imagetype,
192 "label" => $element->getContent(),
193 "embedded" =>
"base64" 195 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, FALSE, FALSE);
198 $a_xml_writer->xmlEndTag(
"material");
203 $a_xml_writer->xmlStartTag(
"material");
204 $this->
object->addQTIMaterial($a_xml_writer, $element->getContent(), TRUE, FALSE);
205 $a_xml_writer->xmlEndTag(
"material");
206 $a_xml_writer->xmlStartTag(
"material");
207 $attrs =
array(
"label" =>
"answerdepth");
208 $a_xml_writer->xmlElement(
"mattext", $attrs, $element->getIndentation());
209 $a_xml_writer->xmlEndTag(
"material");
211 $a_xml_writer->xmlEndTag(
"response_label");
213 $a_xml_writer->xmlEndTag(
"render_choice");
214 $a_xml_writer->xmlEndTag(
"response_lid");
215 $a_xml_writer->xmlEndTag(
"flow");
216 $a_xml_writer->xmlEndTag(
"presentation");
219 $a_xml_writer->xmlStartTag(
"resprocessing");
220 $a_xml_writer->xmlStartTag(
"outcomes");
221 $a_xml_writer->xmlStartTag(
"decvar");
222 $a_xml_writer->xmlEndTag(
"decvar");
223 $a_xml_writer->xmlEndTag(
"outcomes");
225 foreach ($this->
object->getOrderingElementList() as $element)
230 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
232 $a_xml_writer->xmlStartTag(
"conditionvar");
236 $ordering_type =
'OQP';
238 $ordering_type =
'OQNP';
240 $ordering_type =
'OQNT';
242 $ordering_type =
'OQT';
244 $attrs =
array(
"respident" => $ordering_type);
246 $attrs[
"index"] = $element->getPosition();
247 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
248 $a_xml_writer->xmlEndTag(
"conditionvar");
253 $points = $this->
object->getPoints() / $this->
object->getOrderingElementList()->countElements();
254 $a_xml_writer->xmlElement(
"setvar", $attrs, $points);
257 "feedbacktype" =>
"Response",
258 "linkrefid" =>
"link_".$element->getPosition()
260 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
261 $a_xml_writer->xmlEndTag(
"respcondition");
264 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
265 $this->
object->getId(), true
267 if (strlen($feedback_allcorrect))
272 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
274 $a_xml_writer->xmlStartTag(
"conditionvar");
276 foreach ($this->
object->getOrderingElementList() as $element)
281 $ordering_type =
'OQP';
283 $ordering_type =
'OQNP';
285 $ordering_type =
'OQNT';
287 $ordering_type =
'OQT';
289 $attrs =
array(
"respident" => $ordering_type);
291 $attrs[
"index"] = $element->getPosition();
292 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
295 $a_xml_writer->xmlEndTag(
"conditionvar");
298 "feedbacktype" =>
"Response",
299 "linkrefid" =>
"response_allcorrect" 301 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
302 $a_xml_writer->xmlEndTag(
"respcondition");
305 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
306 $this->
object->getId(), false
308 if (strlen($feedback_onenotcorrect))
313 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
315 $a_xml_writer->xmlStartTag(
"conditionvar");
316 $a_xml_writer->xmlStartTag(
"not");
318 foreach ($this->
object->getOrderingElementList() as $element)
322 $ordering_type =
'OQP';
324 $ordering_type =
'OQNP';
326 $ordering_type =
'OQNT';
328 $ordering_type =
'OQT';
330 $attrs =
array(
"respident" => $ordering_type);
332 $attrs[
"index"] = $element->getPosition();
333 $a_xml_writer->xmlElement(
"varequal", $attrs, $element->getPosition());
336 $a_xml_writer->xmlEndTag(
"not");
337 $a_xml_writer->xmlEndTag(
"conditionvar");
340 "feedbacktype" =>
"Response",
341 "linkrefid" =>
"response_onenotcorrect" 343 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
344 $a_xml_writer->xmlEndTag(
"respcondition");
347 $a_xml_writer->xmlEndTag(
"resprocessing");
350 foreach ($this->
object->getOrderingElementList() as $element)
353 "ident" =>
"link_".$element->getPosition(),
356 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
358 $a_xml_writer->xmlStartTag(
"flow_mat");
359 $a_xml_writer->xmlStartTag(
"material");
360 $a_xml_writer->xmlElement(
"mattext", null, $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
361 $this->object->getId(), $element->getPosition()
363 $a_xml_writer->xmlEndTag(
"material");
364 $a_xml_writer->xmlEndTag(
"flow_mat");
365 $a_xml_writer->xmlEndTag(
"itemfeedback");
368 if (strlen($feedback_allcorrect))
371 "ident" =>
"response_allcorrect",
374 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
376 $a_xml_writer->xmlStartTag(
"flow_mat");
377 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
378 $a_xml_writer->xmlEndTag(
"flow_mat");
379 $a_xml_writer->xmlEndTag(
"itemfeedback");
381 if (strlen($feedback_onenotcorrect))
384 "ident" =>
"response_onenotcorrect",
387 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
389 $a_xml_writer->xmlStartTag(
"flow_mat");
390 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
391 $a_xml_writer->xmlEndTag(
"flow_mat");
392 $a_xml_writer->xmlEndTag(
"itemfeedback");
395 $a_xml_writer->xmlEndTag(
"item");
396 $a_xml_writer->xmlEndTag(
"questestinterop");
398 $xml = $a_xml_writer->xmlDumpMem(FALSE);
399 if (!$a_include_header)
401 $pos = strpos($xml,
"?>");
402 $xml = substr($xml, $pos + 2);
Class for ordering question exports.
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
const OQ_PICTURES
Ordering question constants.
const ORDERING_QUESTION_IDENTIFIER
toXML($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
Returns a QTI xml representation of the question.
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