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
29 $ilias = $DIC[
'ilias'];
31 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
35 $a_xml_writer->xmlStartTag(
"questestinterop");
37 "ident" =>
"il_" . IL_INST_ID .
"_qst_" . $this->object->getId(),
38 "title" => $this->
object->getTitle(),
39 "maxattempts" => $this->
object->getNrOfTries()
41 $a_xml_writer->xmlStartTag(
"item", $attrs);
43 $a_xml_writer->xmlElement(
"qticomment", null, $this->object->getComment());
45 $workingtime = $this->
object->getEstimatedWorkingTime();
46 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
47 $a_xml_writer->xmlElement(
"duration", null, $duration);
49 $a_xml_writer->xmlStartTag(
"itemmetadata");
50 $a_xml_writer->xmlStartTag(
"qtimetadata");
51 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
52 $a_xml_writer->xmlElement(
"fieldlabel", null,
"ILIAS_VERSION");
53 $a_xml_writer->xmlElement(
"fieldentry", null, $ilias->getSetting(
"ilias_version"));
54 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
55 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
56 $a_xml_writer->xmlElement(
"fieldlabel", null,
"QUESTIONTYPE");
58 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
59 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
60 $a_xml_writer->xmlElement(
"fieldlabel", null,
"AUTHOR");
61 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getAuthor());
62 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
68 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
69 $a_xml_writer->xmlElement(
"fieldlabel", null,
"shuffle");
70 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getShuffle());
71 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
72 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
73 $a_xml_writer->xmlElement(
"fieldlabel", null,
"thumb_geometry");
74 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getThumbGeometry());
75 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
76 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
77 $a_xml_writer->xmlElement(
"fieldlabel", null,
'matching_mode');
78 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getMatchingMode());
79 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
80 $a_xml_writer->xmlEndTag(
"qtimetadata");
81 $a_xml_writer->xmlEndTag(
"itemmetadata");
85 "label" => $this->object->getTitle()
87 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
89 $a_xml_writer->xmlStartTag(
"flow");
91 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
95 "rcardinality" =>
"Multiple" 97 $a_xml_writer->xmlStartTag(
"response_grp", $attrs);
98 $solution = $this->
object->getSuggestedSolution(0);
99 if (count($solution)) {
100 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) {
104 $intlink = $solution[
"internal_link"];
107 "label" =>
"suggested_solution" 109 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
110 $a_xml_writer->xmlEndTag(
"material");
115 if ($this->object->getShuffle()) {
124 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
126 $matchingtext_orders = array();
127 foreach ($this->object->getMatchingPairs() as
$index => $matchingpair) {
128 array_push($matchingtext_orders, $matchingpair->term->identifier);
132 foreach ($this->object->getTerms() as $term) {
133 array_push($termids, $term->identifier);
136 foreach ($this->object->getDefinitions() as $definition) {
138 "ident" => $definition->identifier,
140 "match_group" => join(
",", $termids)
142 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
143 $a_xml_writer->xmlStartTag(
"material");
144 if (strlen($definition->picture)) {
145 if ($force_image_references) {
147 "imagtype" =>
"image/jpeg",
148 "label" => $definition->picture,
149 "uri" => $this->object->getImagePathWeb() . $definition->picture
151 $a_xml_writer->xmlElement(
"matimage", $attrs);
153 $imagepath = $this->
object->getImagePath() . $definition->picture;
154 $fh = @
fopen($imagepath,
"rb");
156 $imagefile = fread($fh, filesize($imagepath));
158 $base64 = base64_encode($imagefile);
160 "imagtype" =>
"image/jpeg",
161 "label" => $definition->picture,
162 "embedded" =>
"base64" 164 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
168 if (strlen($definition->text)) {
170 "texttype" =>
"text/plain" 172 if ($this->object->isHTML($definition->text)) {
173 $attrs[
"texttype"] =
"text/xhtml";
175 $a_xml_writer->xmlElement(
"mattext", $attrs, $definition->text);
177 $a_xml_writer->xmlEndTag(
"material");
178 $a_xml_writer->xmlEndTag(
"response_label");
181 foreach ($this->object->getTerms() as $term) {
183 "ident" => $term->identifier
185 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
186 $a_xml_writer->xmlStartTag(
"material");
187 if (strlen($term->picture)) {
188 if ($force_image_references) {
190 "imagtype" =>
"image/jpeg",
191 "label" => $term->picture,
192 "uri" => $this->object->getImagePathWeb() . $term->picture
194 $a_xml_writer->xmlElement(
"matimage", $attrs);
196 $imagepath = $this->
object->getImagePath() . $term->picture;
197 $fh = @
fopen($imagepath,
"rb");
199 $imagefile = fread($fh, filesize($imagepath));
201 $base64 = base64_encode($imagefile);
203 "imagtype" =>
"image/jpeg",
204 "label" => $term->picture,
205 "embedded" =>
"base64" 207 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
211 if (strlen($term->text)) {
213 "texttype" =>
"text/plain" 215 if ($this->object->isHTML($term->text)) {
216 $attrs[
"texttype"] =
"text/xhtml";
218 $a_xml_writer->xmlElement(
"mattext", $attrs, $term->text);
220 $a_xml_writer->xmlEndTag(
"material");
221 $a_xml_writer->xmlEndTag(
"response_label");
223 $a_xml_writer->xmlEndTag(
"render_choice");
224 $a_xml_writer->xmlEndTag(
"response_grp");
225 $a_xml_writer->xmlEndTag(
"flow");
226 $a_xml_writer->xmlEndTag(
"presentation");
229 $a_xml_writer->xmlStartTag(
"resprocessing");
230 $a_xml_writer->xmlStartTag(
"outcomes");
231 $a_xml_writer->xmlStartTag(
"decvar");
232 $a_xml_writer->xmlEndTag(
"decvar");
233 $a_xml_writer->xmlEndTag(
"outcomes");
235 foreach ($this->object->getMatchingPairs() as $matchingpair) {
239 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
241 $a_xml_writer->xmlStartTag(
"conditionvar");
245 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->term->identifier .
"," . $matchingpair->definition->identifier);
246 $a_xml_writer->xmlEndTag(
"conditionvar");
252 $a_xml_writer->xmlElement(
"setvar", $attrs, $matchingpair->points);
255 "feedbacktype" =>
"Response",
256 "linkrefid" =>
"correct_" . $matchingpair->term->identifier .
"_" . $matchingpair->definition_identifier
258 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
259 $a_xml_writer->xmlEndTag(
"respcondition");
262 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
263 $this->object->getId(),
266 if (strlen($feedback_allcorrect)) {
270 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
272 $a_xml_writer->xmlStartTag(
"conditionvar");
274 foreach ($this->object->getMatchingPairs() as $matchingpair) {
278 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->term->identifier .
"," . $matchingpair->definition->identifier);
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");
289 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
290 $this->object->getId(),
293 if (strlen($feedback_onenotcorrect)) {
297 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
299 $a_xml_writer->xmlStartTag(
"conditionvar");
300 $a_xml_writer->xmlStartTag(
"not");
301 foreach ($this->object->getMatchingPairs() as $matchingpair) {
305 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->term->identifier .
"," . $matchingpair->definition->identifier);
307 $a_xml_writer->xmlEndTag(
"not");
308 $a_xml_writer->xmlEndTag(
"conditionvar");
311 "feedbacktype" =>
"Response",
312 "linkrefid" =>
"response_onenotcorrect" 314 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
315 $a_xml_writer->xmlEndTag(
"respcondition");
318 $a_xml_writer->xmlEndTag(
"resprocessing");
321 foreach ($this->object->getMatchingPairs() as $index => $matchingpair) {
323 "ident" =>
"correct_" . $matchingpair->term->identifier .
"_" . $matchingpair->definition->identifier,
326 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
328 $a_xml_writer->xmlStartTag(
"flow_mat");
329 $a_xml_writer->xmlStartTag(
"material");
330 $a_xml_writer->xmlElement(
"mattext", null, $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
331 $this->object->getId(),
335 $a_xml_writer->xmlEndTag(
"material");
336 $a_xml_writer->xmlEndTag(
"flow_mat");
337 $a_xml_writer->xmlEndTag(
"itemfeedback");
340 if (strlen($feedback_allcorrect)) {
342 "ident" =>
"response_allcorrect",
345 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
347 $a_xml_writer->xmlStartTag(
"flow_mat");
348 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
349 $a_xml_writer->xmlEndTag(
"flow_mat");
350 $a_xml_writer->xmlEndTag(
"itemfeedback");
352 if (strlen($feedback_onenotcorrect)) {
354 "ident" =>
"response_onenotcorrect",
357 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
359 $a_xml_writer->xmlStartTag(
"flow_mat");
360 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
361 $a_xml_writer->xmlEndTag(
"flow_mat");
362 $a_xml_writer->xmlEndTag(
"itemfeedback");
365 $a_xml_writer->xmlEndTag(
"item");
366 $a_xml_writer->xmlEndTag(
"questestinterop");
368 $xml = $a_xml_writer->xmlDumpMem(
false);
369 if (!$a_include_header) {
370 $pos = strpos(
$xml,
"?>");
const MATCHING_QUESTION_IDENTIFIER
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...