35 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false): string
38 $ilias = $DIC[
'ilias'];
42 $a_xml_writer->xmlHeader();
43 $a_xml_writer->xmlStartTag(
"questestinterop");
45 "ident" =>
"il_" .
IL_INST_ID .
"_qst_" . $this->
object->getId(),
46 "title" => $this->
object->getTitle(),
47 "maxattempts" => $this->
object->getNrOfTries()
49 $a_xml_writer->xmlStartTag(
"item", $attrs);
51 $a_xml_writer->xmlElement(
"qticomment",
null, $this->
object->getComment());
52 $a_xml_writer->xmlStartTag(
"itemmetadata");
53 $a_xml_writer->xmlStartTag(
"qtimetadata");
54 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
55 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"ILIAS_VERSION");
56 $a_xml_writer->xmlElement(
"fieldentry",
null, $ilias->getSetting(
"ilias_version"));
57 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
58 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
59 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"QUESTIONTYPE");
60 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getQuestionType());
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->xmlStartTag(
"qtimetadatafield");
72 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"thumb_size");
73 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getThumbSize());
74 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
76 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
77 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"feedback_setting");
78 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getSpecificFeedbackSetting());
79 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
83 $a_xml_writer->xmlEndTag(
"qtimetadata");
84 $a_xml_writer->xmlEndTag(
"itemmetadata");
88 "label" => $this->
object->getTitle()
90 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
92 $a_xml_writer->xmlStartTag(
"flow");
98 "rcardinality" =>
"Single" 100 $a_xml_writer->xmlStartTag(
"response_lid", $attrs);
104 if ($this->
object->getShuffle()) {
113 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
114 $answers = $this->
object->getAnswers();
115 $akeys = array_keys($answers);
116 if ($this->
object->getShuffle() && $a_shuffle) {
117 $akeys = shuffle($akeys);
120 foreach ($akeys as $index) {
121 $answer = $answers[$index];
125 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
127 if ($answer->hasImage()) {
128 $this->
addQTIMaterial($a_xml_writer, $answer->getAnswertext(),
false,
false);
129 $imagetype =
"image/jpeg";
130 if (preg_match(
"/.*\.(png|gif)$/", $answer->getImage(), $matches)) {
131 $imagetype =
"image/" . $matches[1];
133 if ($force_image_references) {
135 "imagtype" => $imagetype,
136 "label" => $answer->getImage(),
137 "uri" => $this->
object->getImagePathWeb() . $answer->getImage()
139 $a_xml_writer->xmlElement(
"matimage", $attrs);
141 $imagepath = $this->
object->getImagePath() . $answer->getImage();
142 $fh = @fopen($imagepath,
"rb");
144 $imagefile = fread($fh, filesize($imagepath));
146 $base64 = base64_encode($imagefile);
148 "imagtype" => $imagetype,
149 "label" => $answer->getImage(),
150 "embedded" =>
"base64" 152 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
155 $a_xml_writer->xmlEndTag(
"material");
159 $a_xml_writer->xmlEndTag(
"response_label");
161 $a_xml_writer->xmlEndTag(
"render_choice");
162 $a_xml_writer->xmlEndTag(
"response_lid");
163 $a_xml_writer->xmlEndTag(
"flow");
164 $a_xml_writer->xmlEndTag(
"presentation");
167 $a_xml_writer->xmlStartTag(
"resprocessing");
168 $a_xml_writer->xmlStartTag(
"outcomes");
169 $a_xml_writer->xmlStartTag(
"decvar");
170 $a_xml_writer->xmlEndTag(
"decvar");
171 $a_xml_writer->xmlEndTag(
"outcomes");
173 foreach ($answers as $index => $answer) {
177 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
179 $a_xml_writer->xmlStartTag(
"conditionvar");
181 "respident" =>
"MCSR" 183 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
184 $a_xml_writer->xmlEndTag(
"conditionvar");
189 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
191 $linkrefid =
"response_$index";
193 "feedbacktype" =>
"Response",
194 "linkrefid" => $linkrefid
196 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
197 $a_xml_writer->xmlEndTag(
"respcondition");
200 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
204 if (strlen($feedback_allcorrect)) {
208 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
210 $a_xml_writer->xmlStartTag(
"conditionvar");
213 foreach ($answers as $index => $answer) {
214 if ($answer->getPoints() > $maxpoints) {
215 $maxpoints = $answer->getPoints();
220 "respident" =>
"MCSR" 222 $a_xml_writer->xmlElement(
"varequal", $attrs, $bestindex);
223 $a_xml_writer->xmlEndTag(
"conditionvar");
226 "feedbacktype" =>
"Response",
227 "linkrefid" =>
"response_allcorrect" 229 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
230 $a_xml_writer->xmlEndTag(
"respcondition");
233 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
237 if (strlen($feedback_onenotcorrect)) {
241 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
243 $a_xml_writer->xmlStartTag(
"conditionvar");
246 foreach ($answers as $index => $answer) {
247 if ($answer->getPoints() > $maxpoints) {
248 $maxpoints = $answer->getPoints();
253 "respident" =>
"MCSR" 255 $a_xml_writer->xmlStartTag(
"not");
256 $a_xml_writer->xmlElement(
"varequal", $attrs, $bestindex);
257 $a_xml_writer->xmlEndTag(
"not");
258 $a_xml_writer->xmlEndTag(
"conditionvar");
261 "feedbacktype" =>
"Response",
262 "linkrefid" =>
"response_onenotcorrect" 264 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
265 $a_xml_writer->xmlEndTag(
"respcondition");
268 $a_xml_writer->xmlEndTag(
"resprocessing");
271 foreach ($answers as $index => $answer) {
272 $linkrefid =
"response_$index";
274 "ident" => $linkrefid,
277 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
279 $a_xml_writer->xmlStartTag(
"flow_mat");
280 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
286 $a_xml_writer->xmlEndTag(
"flow_mat");
287 $a_xml_writer->xmlEndTag(
"itemfeedback");
289 if (strlen($feedback_allcorrect)) {
291 "ident" =>
"response_allcorrect",
294 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
296 $a_xml_writer->xmlStartTag(
"flow_mat");
298 $a_xml_writer->xmlEndTag(
"flow_mat");
299 $a_xml_writer->xmlEndTag(
"itemfeedback");
301 if (strlen($feedback_onenotcorrect)) {
303 "ident" =>
"response_onenotcorrect",
306 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
308 $a_xml_writer->xmlStartTag(
"flow_mat");
310 $a_xml_writer->xmlEndTag(
"flow_mat");
311 $a_xml_writer->xmlEndTag(
"itemfeedback");
316 $a_xml_writer->xmlEndTag(
"item");
317 $a_xml_writer->xmlEndTag(
"questestinterop");
318 $xml = $a_xml_writer->xmlDumpMem(
false);
319 if (!$a_include_header) {
320 $pos = strpos($xml,
"?>");
321 $xml = substr($xml, $pos + 2);
addQTIMaterial(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
Class for question exports.
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 ...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 Returns a QTI xml representation of the question and...
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
addSuggestedSolution(ilXmlWriter $writer)
addSolutionHints(ilXmlWriter $writer)