4 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
26 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
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,
"IS_MULTIPLE_CHOICE");
60 $a_xml_writer->xmlElement(
"fieldentry", null, ($this->
object->getIsMultipleChoice())?
"1":
"0");
61 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
62 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
63 $a_xml_writer->xmlElement(
"fieldlabel", null,
"AUTHOR");
64 $a_xml_writer->xmlElement(
"fieldentry", null, $this->
object->getAuthor());
65 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
71 $a_xml_writer->xmlEndTag(
"qtimetadata");
72 $a_xml_writer->xmlEndTag(
"itemmetadata");
76 "label" => $this->
object->getTitle()
78 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
80 $a_xml_writer->xmlStartTag(
"flow");
82 $this->
object->addQTIMaterial($a_xml_writer, $this->
object->getQuestion());
86 "rcardinality" =>
"Single" 88 $a_xml_writer->xmlStartTag(
"response_xy", $attrs);
89 $solution = $this->
object->getSuggestedSolution(0);
90 if (count($solution)) {
91 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
92 $a_xml_writer->xmlStartTag(
"material");
93 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
94 if (strcmp($matches[1],
"") != 0) {
95 $intlink = $solution[
"internal_link"];
98 "label" =>
"suggested_solution" 100 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
101 $a_xml_writer->xmlEndTag(
"material");
104 $a_xml_writer->xmlStartTag(
"render_hotspot");
105 $a_xml_writer->xmlStartTag(
"material");
106 $imagetype =
"image/jpeg";
107 if (preg_match(
"/.*\.(png|gif)$/i", $this->
object->getImageFilename(), $matches)) {
108 $imagetype =
"image/" . strtolower($matches[1]);
111 "imagtype" => $imagetype,
112 "label" => $this->
object->getImageFilename()
114 if ($a_include_binary) {
115 if ($force_image_references) {
116 $attrs[
"uri"] = $this->
object->getImagePathWeb() . $this->
object->getImageFilename();
117 $a_xml_writer->xmlElement(
"matimage", $attrs);
119 $attrs[
"embedded"] =
"base64";
120 $imagepath = $this->
object->getImagePath() . $this->
object->getImageFilename();
121 $fh = fopen($imagepath,
"rb");
124 $ilErr->raiseError(
$GLOBALS[
'lng']->txt(
"error_open_image_file"), $ilErr->MESSAGE);
127 $imagefile = fread(
$fh, filesize($imagepath));
129 $base64 = base64_encode($imagefile);
130 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
133 $a_xml_writer->xmlElement(
"matimage", $attrs);
135 $a_xml_writer->xmlEndTag(
"material");
138 foreach ($this->
object->getAnswers() as
$index => $answer) {
140 switch ($answer->getArea()) {
142 $rarea =
"Rectangle";
155 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
156 $a_xml_writer->xmlData($answer->getCoords());
157 $a_xml_writer->xmlStartTag(
"material");
158 $a_xml_writer->xmlElement(
"mattext", null, $answer->getAnswertext());
159 $a_xml_writer->xmlEndTag(
"material");
160 $a_xml_writer->xmlEndTag(
"response_label");
162 $a_xml_writer->xmlEndTag(
"render_hotspot");
163 $a_xml_writer->xmlEndTag(
"response_xy");
164 $a_xml_writer->xmlEndTag(
"flow");
165 $a_xml_writer->xmlEndTag(
"presentation");
168 $a_xml_writer->xmlStartTag(
"resprocessing");
169 $a_xml_writer->xmlStartTag(
"outcomes");
170 $a_xml_writer->xmlStartTag(
"decvar");
171 $a_xml_writer->xmlEndTag(
"decvar");
172 $a_xml_writer->xmlEndTag(
"outcomes");
174 foreach ($this->
object->getAnswers() as $index => $answer) {
178 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
180 $a_xml_writer->xmlStartTag(
"conditionvar");
181 if (!$answer->isStateSet()) {
182 $a_xml_writer->xmlStartTag(
"not");
185 switch ($answer->getArea()) {
187 $areatype =
"Rectangle";
190 $areatype =
"Ellipse";
193 $areatype =
"Bounded";
198 "areatype" => $areatype
200 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getCoords());
201 if (!$answer->isStateSet()) {
202 $a_xml_writer->xmlEndTag(
"not");
204 $a_xml_writer->xmlEndTag(
"conditionvar");
209 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
210 $linkrefid =
"response_$index";
212 "feedbacktype" =>
"Response",
213 "linkrefid" => $linkrefid
215 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
216 $a_xml_writer->xmlEndTag(
"respcondition");
220 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
222 $a_xml_writer->xmlStartTag(
"conditionvar");
226 $a_xml_writer->xmlStartTag(
"not");
227 $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getCoords());
228 $a_xml_writer->xmlEndTag(
"not");
229 $a_xml_writer->xmlEndTag(
"conditionvar");
234 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPointsUnchecked());
235 $a_xml_writer->xmlEndTag(
"respcondition");
238 $answers = $this->
object->getAnswers();
239 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
243 if (strlen($feedback_allcorrect)) {
247 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
249 $a_xml_writer->xmlStartTag(
"conditionvar");
250 if (!$this->
object->getIsMultipleChoice()) {
253 foreach ($answers as $index => $answer) {
254 if ($answer->getPoints() > $maxpoints) {
255 $maxpoints = $answer->getPoints();
264 $answer = $answers[$bestindex];
265 switch ($answer->getArea()) {
267 $areatype =
"Rectangle";
270 $areatype =
"Ellipse";
273 $areatype =
"Bounded";
278 "areatype" => $areatype
280 $a_xml_writer->xmlElement(
"varinside", $attrs, $answer->getCoords());
282 foreach ($answers as $index => $answer) {
283 if ($answer->getPoints() < $answer->getPointsUnchecked()) {
284 $a_xml_writer->xmlStartTag(
"not");
286 switch ($answer->getArea()) {
288 $areatype =
"Rectangle";
291 $areatype =
"Ellipse";
294 $areatype =
"Bounded";
299 "areatype" => $areatype
301 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
302 if ($answer->getPoints() < $answer->getPointsUnchecked()) {
303 $a_xml_writer->xmlEndTag(
"not");
308 $a_xml_writer->xmlEndTag(
"conditionvar");
311 "feedbacktype" =>
"Response",
312 "linkrefid" =>
"response_allcorrect" 314 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
315 $a_xml_writer->xmlEndTag(
"respcondition");
318 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
322 if (strlen($feedback_onenotcorrect)) {
326 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
328 $a_xml_writer->xmlStartTag(
"conditionvar");
329 if (!$this->
object->getIsMultipleChoice()) {
332 foreach ($answers as $index => $answer) {
333 if ($answer->getPoints() > $maxpoints) {
334 $maxpoints = $answer->getPoints();
341 $a_xml_writer->xmlStartTag(
"not");
344 $answer = $answers[$bestindex];
345 switch ($answer->getArea()) {
347 $areatype =
"Rectangle";
350 $areatype =
"Ellipse";
353 $areatype =
"Bounded";
358 "areatype" => $areatype
360 $a_xml_writer->xmlElement(
"varinside", $attrs, $answer->getCoords());
362 $a_xml_writer->xmlEndTag(
"not");
364 foreach ($answers as $index => $answer) {
366 $a_xml_writer->xmlStartTag(
"or");
368 if ($answer->getPoints() >= $answer->getPointsUnchecked()) {
369 $a_xml_writer->xmlStartTag(
"not");
371 switch ($answer->getArea()) {
373 $areatype =
"Rectangle";
376 $areatype =
"Ellipse";
379 $areatype =
"Bounded";
384 "areatype" => $areatype
386 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
387 if ($answer->getPoints() >= $answer->getPointsUnchecked()) {
388 $a_xml_writer->xmlEndTag(
"not");
391 $a_xml_writer->xmlEndTag(
"or");
395 $a_xml_writer->xmlEndTag(
"conditionvar");
398 "feedbacktype" =>
"Response",
399 "linkrefid" =>
"response_onenotcorrect" 401 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
402 $a_xml_writer->xmlEndTag(
"respcondition");
405 $a_xml_writer->xmlEndTag(
"resprocessing");
408 foreach ($this->
object->getAnswers() as $index => $answer) {
410 $linkrefid =
"response_$index";
412 "ident" => $linkrefid,
415 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
417 $a_xml_writer->xmlStartTag(
"flow_mat");
418 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
422 $this->
object->addQTIMaterial($a_xml_writer, $fb);
423 $a_xml_writer->xmlEndTag(
"flow_mat");
424 $a_xml_writer->xmlEndTag(
"itemfeedback");
426 if (strlen($feedback_allcorrect)) {
428 "ident" =>
"response_allcorrect",
431 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
433 $a_xml_writer->xmlStartTag(
"flow_mat");
434 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
435 $a_xml_writer->xmlEndTag(
"flow_mat");
436 $a_xml_writer->xmlEndTag(
"itemfeedback");
438 if (strlen($feedback_onenotcorrect)) {
440 "ident" =>
"response_onenotcorrect",
443 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
445 $a_xml_writer->xmlStartTag(
"flow_mat");
446 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
447 $a_xml_writer->xmlEndTag(
"flow_mat");
448 $a_xml_writer->xmlEndTag(
"itemfeedback");
451 $a_xml_writer->xmlEndTag(
"item");
452 $a_xml_writer->xmlEndTag(
"questestinterop");
454 $xml = $a_xml_writer->xmlDumpMem(
false);
455 if (!$a_include_header) {
456 $pos = strpos(
$xml,
"?>");
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Class for question exports.
Class for imagemap question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
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
const IMAGEMAP_QUESTION_IDENTIFIER