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,
"thumb_size");
69 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getThumbSize());
70 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
72 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
73 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"feedback_setting");
74 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getSpecificFeedbackSetting());
75 $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());
95 "rcardinality" =>
"Multiple" 97 $a_xml_writer->xmlStartTag(
"response_lid", $attrs);
98 $solution = $this->
object->getSuggestedSolution(0);
101 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
103 $a_xml_writer->xmlStartTag(
"material");
104 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
105 if (strcmp($matches[1],
"") != 0)
107 $intlink = $solution[
"internal_link"];
110 "label" =>
"suggested_solution" 112 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
113 $a_xml_writer->xmlEndTag(
"material");
117 $attrs =
array(
'shuffle' => $this->
object->getShuffle() ?
'Yes' :
'No');
118 if($this->
object->getSelectionLimit())
120 $attrs[
'minnumber'] =
'0';
121 $attrs[
'maxnumber'] = (
string)$this->
object->getSelectionLimit();
123 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
124 $answers =& $this->
object->getAnswers();
125 $akeys = array_keys($answers);
126 if ($this->
object->getShuffle() && $a_shuffle)
128 $akeys = $this->
object->pcArrayShuffle($akeys);
131 foreach ($akeys as $index)
133 $answer = $answers[$index];
137 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
139 if (strlen($answer->getImage()))
141 $this->
object->addQTIMaterial($a_xml_writer, $answer->getAnswertext(), FALSE, FALSE);
142 $imagetype =
"image/jpeg";
143 if (preg_match(
"/.*\.(png|gif)$/", $answer->getImage(), $matches))
145 $imagetype =
"image/" . $matches[1];
147 if ($force_image_references)
150 "imagtype" => $imagetype,
151 "label" => $answer->getImage(),
152 "uri" => $this->
object->getImagePathWeb() . $answer->getImage()
154 $a_xml_writer->xmlElement(
"matimage", $attrs);
158 $imagepath = $this->
object->getImagePath() . $answer->getImage();
159 $fh = @fopen($imagepath,
"rb");
162 $imagefile = fread(
$fh, filesize($imagepath));
164 $base64 = base64_encode($imagefile);
166 "imagtype" => $imagetype,
167 "label" => $answer->getImage(),
168 "embedded" =>
"base64" 170 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, FALSE, FALSE);
173 $a_xml_writer->xmlEndTag(
"material");
177 $this->
object->addQTIMaterial($a_xml_writer, $answer->getAnswertext());
179 $a_xml_writer->xmlEndTag(
"response_label");
181 $a_xml_writer->xmlEndTag(
"render_choice");
182 $a_xml_writer->xmlEndTag(
"response_lid");
183 $a_xml_writer->xmlEndTag(
"flow");
184 $a_xml_writer->xmlEndTag(
"presentation");
187 $a_xml_writer->xmlStartTag(
"resprocessing");
188 $a_xml_writer->xmlStartTag(
"outcomes");
189 $a_xml_writer->xmlStartTag(
"decvar");
190 $a_xml_writer->xmlEndTag(
"decvar");
191 $a_xml_writer->xmlEndTag(
"outcomes");
193 foreach ($answers as $index => $answer)
198 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
200 $a_xml_writer->xmlStartTag(
"conditionvar");
203 "respident" =>
"MCMR" 205 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
206 $a_xml_writer->xmlEndTag(
"conditionvar");
211 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
213 $linkrefid =
"response_$index";
215 "feedbacktype" =>
"Response",
216 "linkrefid" => $linkrefid
218 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
219 $a_xml_writer->xmlEndTag(
"respcondition");
223 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
226 $a_xml_writer->xmlStartTag(
"conditionvar");
229 "respident" =>
"MCMR" 231 $a_xml_writer->xmlStartTag(
"not");
232 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
233 $a_xml_writer->xmlEndTag(
"not");
234 $a_xml_writer->xmlEndTag(
"conditionvar");
239 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPointsUnchecked());
240 $a_xml_writer->xmlEndTag(
"respcondition");
242 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
243 $this->
object->getId(), true
245 if (strlen($feedback_allcorrect))
250 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
252 $a_xml_writer->xmlStartTag(
"conditionvar");
253 foreach ($answers as $index => $answer)
255 if ($answer->getPointsChecked() < $answer->getPointsUnchecked())
257 $a_xml_writer->xmlStartTag(
"not");
260 "respident" =>
"MCMR" 262 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
263 if ($answer->getPointsChecked() < $answer->getPointsUnchecked())
265 $a_xml_writer->xmlEndTag(
"not");
268 $a_xml_writer->xmlEndTag(
"conditionvar");
271 "feedbacktype" =>
"Response",
272 "linkrefid" =>
"response_allcorrect" 274 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
275 $a_xml_writer->xmlEndTag(
"respcondition");
277 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
278 $this->
object->getId(), false
280 if (strlen($feedback_onenotcorrect))
285 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
287 $a_xml_writer->xmlStartTag(
"conditionvar");
288 foreach ($answers as $index => $answer)
292 $a_xml_writer->xmlStartTag(
"or");
294 if ($answer->getPointsChecked() >= $answer->getPointsUnchecked())
296 $a_xml_writer->xmlStartTag(
"not");
299 "respident" =>
"MCMR" 301 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
302 if ($answer->getPointsChecked() >= $answer->getPointsUnchecked())
304 $a_xml_writer->xmlEndTag(
"not");
308 $a_xml_writer->xmlEndTag(
"or");
311 $a_xml_writer->xmlEndTag(
"conditionvar");
314 "feedbacktype" =>
"Response",
315 "linkrefid" =>
"response_onenotcorrect" 317 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
318 $a_xml_writer->xmlEndTag(
"respcondition");
320 $a_xml_writer->xmlEndTag(
"resprocessing");
323 foreach ($answers as $index => $answer)
325 $linkrefid =
"response_$index";
327 "ident" => $linkrefid,
330 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
332 $a_xml_writer->xmlStartTag(
"flow_mat");
333 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
334 $this->
object->getId(), $index
336 $this->
object->addQTIMaterial($a_xml_writer, $fb);
337 $a_xml_writer->xmlEndTag(
"flow_mat");
338 $a_xml_writer->xmlEndTag(
"itemfeedback");
340 if (strlen($feedback_allcorrect))
343 "ident" =>
"response_allcorrect",
346 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
348 $a_xml_writer->xmlStartTag(
"flow_mat");
349 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
350 $a_xml_writer->xmlEndTag(
"flow_mat");
351 $a_xml_writer->xmlEndTag(
"itemfeedback");
353 if (strlen($feedback_onenotcorrect))
356 "ident" =>
"response_onenotcorrect",
359 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
361 $a_xml_writer->xmlStartTag(
"flow_mat");
362 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
363 $a_xml_writer->xmlEndTag(
"flow_mat");
364 $a_xml_writer->xmlEndTag(
"itemfeedback");
367 $a_xml_writer->xmlEndTag(
"item");
368 $a_xml_writer->xmlEndTag(
"questestinterop");
370 $xml = $a_xml_writer->xmlDumpMem(FALSE);
371 if (!$a_include_header)
373 $pos = strpos($xml,
"?>");
374 $xml = substr($xml, $pos + 2);
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER
Add rich text string
The name of the decorator.
addGeneralMetadata(ilXmlWriter $xmlwriter)
addQtiMetaDataField(ilXmlWriter $a_xml_writer, $fieldLabel, $fieldValue)
adds a qti meta data field with given name and value to the passed xml writer (xml writer must be in ...
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