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
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);
98 if (count($solution)) {
99 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
100 $a_xml_writer->xmlStartTag(
"material");
101 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
102 if (strcmp($matches[1],
"") != 0) {
103 $intlink = $solution[
"internal_link"];
106 "label" =>
"suggested_solution" 108 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
109 $a_xml_writer->xmlEndTag(
"material");
114 if ($this->
object->getShuffle()) {
123 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
125 $matchingtext_orders =
array();
126 foreach ($this->
object->getMatchingPairs() as
$index => $matchingpair) {
127 array_push($matchingtext_orders, $matchingpair->term->identifier);
131 foreach ($this->
object->getTerms() as $term) {
132 array_push($termids, $term->identifier);
135 foreach ($this->
object->getDefinitions() as $definition) {
137 "ident" => $definition->identifier,
139 "match_group" => join($termids,
",")
141 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
142 $a_xml_writer->xmlStartTag(
"material");
143 if (strlen($definition->picture)) {
144 if ($force_image_references) {
146 "imagtype" =>
"image/jpeg",
147 "label" => $definition->picture,
148 "uri" => $this->object->getImagePathWeb() . $definition->picture
150 $a_xml_writer->xmlElement(
"matimage", $attrs);
152 $imagepath = $this->
object->getImagePath() . $definition->picture;
153 $fh = @fopen($imagepath,
"rb");
155 $imagefile = fread(
$fh, filesize($imagepath));
157 $base64 = base64_encode($imagefile);
159 "imagtype" =>
"image/jpeg",
160 "label" => $definition->picture,
161 "embedded" =>
"base64" 163 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
167 if (strlen($definition->text)) {
169 "texttype" =>
"text/plain" 171 if ($this->
object->isHTML($definition->text)) {
172 $attrs[
"texttype"] =
"text/xhtml";
174 $a_xml_writer->xmlElement(
"mattext", $attrs, $definition->text);
176 $a_xml_writer->xmlEndTag(
"material");
177 $a_xml_writer->xmlEndTag(
"response_label");
180 foreach ($this->
object->getTerms() as $term) {
182 "ident" => $term->identifier
184 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
185 $a_xml_writer->xmlStartTag(
"material");
186 if (strlen($term->picture)) {
187 if ($force_image_references) {
189 "imagtype" =>
"image/jpeg",
190 "label" => $term->picture,
191 "uri" => $this->object->getImagePathWeb() . $term->picture
193 $a_xml_writer->xmlElement(
"matimage", $attrs);
195 $imagepath = $this->
object->getImagePath() . $term->picture;
196 $fh = @fopen($imagepath,
"rb");
198 $imagefile = fread(
$fh, filesize($imagepath));
200 $base64 = base64_encode($imagefile);
202 "imagtype" =>
"image/jpeg",
203 "label" => $term->picture,
204 "embedded" =>
"base64" 206 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
210 if (strlen($term->text)) {
212 "texttype" =>
"text/plain" 214 if ($this->
object->isHTML($term->text)) {
215 $attrs[
"texttype"] =
"text/xhtml";
217 $a_xml_writer->xmlElement(
"mattext", $attrs, $term->text);
219 $a_xml_writer->xmlEndTag(
"material");
220 $a_xml_writer->xmlEndTag(
"response_label");
222 $a_xml_writer->xmlEndTag(
"render_choice");
223 $a_xml_writer->xmlEndTag(
"response_grp");
224 $a_xml_writer->xmlEndTag(
"flow");
225 $a_xml_writer->xmlEndTag(
"presentation");
228 $a_xml_writer->xmlStartTag(
"resprocessing");
229 $a_xml_writer->xmlStartTag(
"outcomes");
230 $a_xml_writer->xmlStartTag(
"decvar");
231 $a_xml_writer->xmlEndTag(
"decvar");
232 $a_xml_writer->xmlEndTag(
"outcomes");
234 foreach ($this->
object->getMatchingPairs() as $matchingpair) {
238 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
240 $a_xml_writer->xmlStartTag(
"conditionvar");
244 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->term->identifier .
"," . $matchingpair->definition->identifier);
245 $a_xml_writer->xmlEndTag(
"conditionvar");
251 $a_xml_writer->xmlElement(
"setvar", $attrs, $matchingpair->points);
254 "feedbacktype" =>
"Response",
255 "linkrefid" =>
"correct_" . $matchingpair->term->identifier .
"_" . $matchingpair->definition_identifier
257 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
258 $a_xml_writer->xmlEndTag(
"respcondition");
261 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
265 if (strlen($feedback_allcorrect)) {
269 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
271 $a_xml_writer->xmlStartTag(
"conditionvar");
273 foreach ($this->
object->getMatchingPairs() as $matchingpair) {
277 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->term->identifier .
"," . $matchingpair->definition->identifier);
279 $a_xml_writer->xmlEndTag(
"conditionvar");
282 "feedbacktype" =>
"Response",
283 "linkrefid" =>
"response_allcorrect" 285 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
286 $a_xml_writer->xmlEndTag(
"respcondition");
288 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
292 if (strlen($feedback_onenotcorrect)) {
296 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
298 $a_xml_writer->xmlStartTag(
"conditionvar");
299 $a_xml_writer->xmlStartTag(
"not");
300 foreach ($this->
object->getMatchingPairs() as $matchingpair) {
304 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->term->identifier .
"," . $matchingpair->definition->identifier);
306 $a_xml_writer->xmlEndTag(
"not");
307 $a_xml_writer->xmlEndTag(
"conditionvar");
310 "feedbacktype" =>
"Response",
311 "linkrefid" =>
"response_onenotcorrect" 313 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
314 $a_xml_writer->xmlEndTag(
"respcondition");
317 $a_xml_writer->xmlEndTag(
"resprocessing");
320 foreach ($this->
object->getMatchingPairs() as $index => $matchingpair) {
322 "ident" =>
"correct_" . $matchingpair->term->identifier .
"_" . $matchingpair->definition->identifier,
325 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
327 $a_xml_writer->xmlStartTag(
"flow_mat");
328 $a_xml_writer->xmlStartTag(
"material");
329 $a_xml_writer->xmlElement(
"mattext", null, $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
330 $this->object->getId(),
333 $a_xml_writer->xmlEndTag(
"material");
334 $a_xml_writer->xmlEndTag(
"flow_mat");
335 $a_xml_writer->xmlEndTag(
"itemfeedback");
338 if (strlen($feedback_allcorrect)) {
340 "ident" =>
"response_allcorrect",
343 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
345 $a_xml_writer->xmlStartTag(
"flow_mat");
346 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
347 $a_xml_writer->xmlEndTag(
"flow_mat");
348 $a_xml_writer->xmlEndTag(
"itemfeedback");
350 if (strlen($feedback_onenotcorrect)) {
352 "ident" =>
"response_onenotcorrect",
355 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
357 $a_xml_writer->xmlStartTag(
"flow_mat");
358 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
359 $a_xml_writer->xmlEndTag(
"flow_mat");
360 $a_xml_writer->xmlEndTag(
"itemfeedback");
363 $a_xml_writer->xmlEndTag(
"item");
364 $a_xml_writer->xmlEndTag(
"questestinterop");
366 $xml = $a_xml_writer->xmlDumpMem(
false);
367 if (!$a_include_header) {
368 $pos = strpos(
$xml,
"?>");
const MATCHING_QUESTION_IDENTIFIER
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