4 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
26 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,
"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,
"shuffle");
69 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getShuffle());
70 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
71 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
72 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"thumb_geometry");
73 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getThumbGeometry());
74 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
75 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
76 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
'matching_mode');
77 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getMatchingMode());
78 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
79 $a_xml_writer->xmlEndTag(
"qtimetadata");
80 $a_xml_writer->xmlEndTag(
"itemmetadata");
84 "label" => $this->
object->getTitle()
86 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
88 $a_xml_writer->xmlStartTag(
"flow");
90 $this->
object->addQTIMaterial($a_xml_writer, $this->
object->getQuestion());
94 "rcardinality" =>
"Multiple" 96 $a_xml_writer->xmlStartTag(
"response_grp", $attrs);
97 $solution = $this->
object->getSuggestedSolution(0);
100 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
102 $a_xml_writer->xmlStartTag(
"material");
103 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
104 if (strcmp($matches[1],
"") != 0)
106 $intlink = $solution[
"internal_link"];
109 "label" =>
"suggested_solution" 111 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
112 $a_xml_writer->xmlEndTag(
"material");
117 if ($this->
object->getShuffle())
129 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
131 $matchingtext_orders =
array();
132 foreach ($this->
object->getMatchingPairs() as $index => $matchingpair)
134 array_push($matchingtext_orders, $matchingpair->term->identifier);
138 foreach ($this->
object->getTerms() as $term)
140 array_push($termids, $term->identifier);
143 foreach ($this->
object->getDefinitions() as $definition)
146 "ident" => $definition->identifier,
148 "match_group" => join($termids,
",")
150 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
151 $a_xml_writer->xmlStartTag(
"material");
152 if (strlen($definition->picture))
154 if ($force_image_references)
157 "imagtype" =>
"image/jpeg",
158 "label" => $definition->picture,
159 "uri" => $this->object->getImagePathWeb() . $definition->picture
161 $a_xml_writer->xmlElement(
"matimage", $attrs);
165 $imagepath = $this->
object->getImagePath() . $definition->picture;
166 $fh = @fopen($imagepath,
"rb");
169 $imagefile = fread(
$fh, filesize($imagepath));
171 $base64 = base64_encode($imagefile);
173 "imagtype" =>
"image/jpeg",
174 "label" => $definition->picture,
175 "embedded" =>
"base64" 177 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, FALSE, FALSE);
181 if (strlen($definition->text))
184 "texttype" =>
"text/plain" 186 if ($this->
object->isHTML($definition->text))
188 $attrs[
"texttype"] =
"text/xhtml";
190 $a_xml_writer->xmlElement(
"mattext", $attrs, $definition->text);
192 $a_xml_writer->xmlEndTag(
"material");
193 $a_xml_writer->xmlEndTag(
"response_label");
196 foreach ($this->
object->getTerms() as $term)
199 "ident" => $term->identifier
201 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
202 $a_xml_writer->xmlStartTag(
"material");
203 if (strlen($term->picture))
205 if ($force_image_references)
208 "imagtype" =>
"image/jpeg",
209 "label" => $term->picture,
210 "uri" => $this->object->getImagePathWeb() . $term->picture
212 $a_xml_writer->xmlElement(
"matimage", $attrs);
216 $imagepath = $this->
object->getImagePath() . $term->picture;
217 $fh = @fopen($imagepath,
"rb");
220 $imagefile = fread(
$fh, filesize($imagepath));
222 $base64 = base64_encode($imagefile);
224 "imagtype" =>
"image/jpeg",
225 "label" => $term->picture,
226 "embedded" =>
"base64" 228 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, FALSE, FALSE);
232 if (strlen($term->text))
235 "texttype" =>
"text/plain" 237 if ($this->
object->isHTML($term->text))
239 $attrs[
"texttype"] =
"text/xhtml";
241 $a_xml_writer->xmlElement(
"mattext", $attrs, $term->text);
243 $a_xml_writer->xmlEndTag(
"material");
244 $a_xml_writer->xmlEndTag(
"response_label");
246 $a_xml_writer->xmlEndTag(
"render_choice");
247 $a_xml_writer->xmlEndTag(
"response_grp");
248 $a_xml_writer->xmlEndTag(
"flow");
249 $a_xml_writer->xmlEndTag(
"presentation");
252 $a_xml_writer->xmlStartTag(
"resprocessing");
253 $a_xml_writer->xmlStartTag(
"outcomes");
254 $a_xml_writer->xmlStartTag(
"decvar");
255 $a_xml_writer->xmlEndTag(
"decvar");
256 $a_xml_writer->xmlEndTag(
"outcomes");
258 foreach ($this->
object->getMatchingPairs() as $matchingpair)
263 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
265 $a_xml_writer->xmlStartTag(
"conditionvar");
269 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->term->identifier .
"," . $matchingpair->definition->identifier);
270 $a_xml_writer->xmlEndTag(
"conditionvar");
276 $a_xml_writer->xmlElement(
"setvar", $attrs, $matchingpair->points);
279 "feedbacktype" =>
"Response",
280 "linkrefid" =>
"correct_" . $matchingpair->term->identifier .
"_" . $matchingpair->definition_identifier
282 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
283 $a_xml_writer->xmlEndTag(
"respcondition");
286 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
287 $this->
object->getId(), true
289 if (strlen($feedback_allcorrect))
294 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
296 $a_xml_writer->xmlStartTag(
"conditionvar");
298 foreach ($this->
object->getMatchingPairs() as $matchingpair)
303 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->term->identifier .
"," . $matchingpair->definition->identifier);
305 $a_xml_writer->xmlEndTag(
"conditionvar");
308 "feedbacktype" =>
"Response",
309 "linkrefid" =>
"response_allcorrect" 311 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
312 $a_xml_writer->xmlEndTag(
"respcondition");
314 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
315 $this->
object->getId(), false
317 if (strlen($feedback_onenotcorrect))
322 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
324 $a_xml_writer->xmlStartTag(
"conditionvar");
325 $a_xml_writer->xmlStartTag(
"not");
326 foreach ($this->
object->getMatchingPairs() as $matchingpair)
331 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->term->identifier .
"," . $matchingpair->definition->identifier);
333 $a_xml_writer->xmlEndTag(
"not");
334 $a_xml_writer->xmlEndTag(
"conditionvar");
337 "feedbacktype" =>
"Response",
338 "linkrefid" =>
"response_onenotcorrect" 340 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
341 $a_xml_writer->xmlEndTag(
"respcondition");
344 $a_xml_writer->xmlEndTag(
"resprocessing");
347 foreach ($this->
object->getMatchingPairs() as $index => $matchingpair)
350 "ident" =>
"correct_" . $matchingpair->term->identifier .
"_" . $matchingpair->definition->identifier,
353 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
355 $a_xml_writer->xmlStartTag(
"flow_mat");
356 $a_xml_writer->xmlStartTag(
"material");
357 $a_xml_writer->xmlElement(
"mattext", null, $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
358 $this->object->getId(), $index
360 $a_xml_writer->xmlEndTag(
"material");
361 $a_xml_writer->xmlEndTag(
"flow_mat");
362 $a_xml_writer->xmlEndTag(
"itemfeedback");
365 if (strlen($feedback_allcorrect))
368 "ident" =>
"response_allcorrect",
371 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
373 $a_xml_writer->xmlStartTag(
"flow_mat");
374 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
375 $a_xml_writer->xmlEndTag(
"flow_mat");
376 $a_xml_writer->xmlEndTag(
"itemfeedback");
378 if (strlen($feedback_onenotcorrect))
381 "ident" =>
"response_onenotcorrect",
384 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
386 $a_xml_writer->xmlStartTag(
"flow_mat");
387 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
388 $a_xml_writer->xmlEndTag(
"flow_mat");
389 $a_xml_writer->xmlEndTag(
"itemfeedback");
392 $a_xml_writer->xmlEndTag(
"item");
393 $a_xml_writer->xmlEndTag(
"questestinterop");
395 $xml = $a_xml_writer->xmlDumpMem(FALSE);
396 if (!$a_include_header)
398 $pos = strpos($xml,
"?>");
399 $xml = substr($xml, $pos + 2);
const MATCHING_QUESTION_IDENTIFIER
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
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
Class for matching question exports.