36 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false): string
39 $ilias = $DIC[
'ilias'];
43 $a_xml_writer->xmlHeader();
44 $a_xml_writer->xmlStartTag(
"questestinterop");
46 "ident" =>
"il_" .
IL_INST_ID .
"_qst_" . $this->
object->getId(),
47 "title" => $this->
object->getTitle(),
48 "maxattempts" => $this->
object->getNrOfTries()
50 $a_xml_writer->xmlStartTag(
"item", $attrs);
52 $a_xml_writer->xmlElement(
"qticomment",
null, $this->
object->getComment());
53 $a_xml_writer->xmlStartTag(
"itemmetadata");
54 $a_xml_writer->xmlStartTag(
"qtimetadata");
55 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
56 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"ILIAS_VERSION");
57 $a_xml_writer->xmlElement(
"fieldentry",
null, $ilias->getSetting(
"ilias_version"));
58 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
59 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
60 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"QUESTIONTYPE");
61 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getQuestionType());
62 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
63 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
64 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"AUTHOR");
65 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getAuthor());
66 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
72 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
73 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"thumb_size");
74 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getThumbSize());
75 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
77 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
78 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"feedback_setting");
79 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getSpecificFeedbackSetting());
80 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
84 $a_xml_writer->xmlEndTag(
"qtimetadata");
85 $a_xml_writer->xmlEndTag(
"itemmetadata");
89 "label" => $this->
object->getTitle()
91 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
93 $a_xml_writer->xmlStartTag(
"flow");
99 "rcardinality" =>
"Multiple" 101 $a_xml_writer->xmlStartTag(
"response_lid", $attrs);
104 $attrs = [
'shuffle' => $this->
object->getShuffle() ?
'Yes' :
'No'];
105 if ($this->
object->getSelectionLimit()) {
106 $attrs[
'minnumber'] =
'0';
107 $attrs[
'maxnumber'] = (string) $this->
object->getSelectionLimit();
109 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
110 $answers = $this->
object->getAnswers();
111 $akeys = array_keys($answers);
112 if ($this->
object->getShuffle() && $a_shuffle) {
113 $akeys = shuffle($akeys);
116 foreach ($akeys as $index) {
117 $answer = $answers[$index];
121 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
123 if ($answer->hasImage()) {
124 $this->
addQTIMaterial($a_xml_writer, $answer->getAnswertext(),
false,
false);
125 $imagetype =
"image/jpeg";
126 if (preg_match(
"/.*\.(png|gif)$/", $answer->getImage(), $matches)) {
127 $imagetype =
"image/" . $matches[1];
129 if ($force_image_references) {
131 "imagtype" => $imagetype,
132 "label" => $answer->getImage(),
133 "uri" => $this->
object->getImagePathWeb() . $answer->getImage()
135 $a_xml_writer->xmlElement(
"matimage", $attrs);
137 $imagepath = $this->
object->getImagePath() . $answer->getImage();
138 $fh = @fopen($imagepath,
"rb");
140 $imagefile = fread($fh, filesize($imagepath));
142 $base64 = base64_encode($imagefile);
144 "imagtype" => $imagetype,
145 "label" => $answer->getImage(),
146 "embedded" =>
"base64" 148 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
151 $a_xml_writer->xmlEndTag(
"material");
155 $a_xml_writer->xmlEndTag(
"response_label");
157 $a_xml_writer->xmlEndTag(
"render_choice");
158 $a_xml_writer->xmlEndTag(
"response_lid");
159 $a_xml_writer->xmlEndTag(
"flow");
160 $a_xml_writer->xmlEndTag(
"presentation");
163 $a_xml_writer->xmlStartTag(
"resprocessing");
164 $a_xml_writer->xmlStartTag(
"outcomes");
165 $a_xml_writer->xmlStartTag(
"decvar");
166 $a_xml_writer->xmlEndTag(
"decvar");
167 $a_xml_writer->xmlEndTag(
"outcomes");
169 foreach ($answers as $index => $answer) {
173 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
175 $a_xml_writer->xmlStartTag(
"conditionvar");
177 "respident" =>
"MCMR" 179 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
180 $a_xml_writer->xmlEndTag(
"conditionvar");
185 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
187 $linkrefid =
"response_$index";
189 "feedbacktype" =>
"Response",
190 "linkrefid" => $linkrefid
192 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
193 $a_xml_writer->xmlEndTag(
"respcondition");
197 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
200 $a_xml_writer->xmlStartTag(
"conditionvar");
202 "respident" =>
"MCMR" 204 $a_xml_writer->xmlStartTag(
"not");
205 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
206 $a_xml_writer->xmlEndTag(
"not");
207 $a_xml_writer->xmlEndTag(
"conditionvar");
212 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPointsUnchecked());
213 $a_xml_writer->xmlEndTag(
"respcondition");
215 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
219 if (strlen($feedback_allcorrect)) {
223 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
225 $a_xml_writer->xmlStartTag(
"conditionvar");
226 foreach ($answers as $index => $answer) {
227 if ($answer->getPointsChecked() < $answer->getPointsUnchecked()) {
228 $a_xml_writer->xmlStartTag(
"not");
231 "respident" =>
"MCMR" 233 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
234 if ($answer->getPointsChecked() < $answer->getPointsUnchecked()) {
235 $a_xml_writer->xmlEndTag(
"not");
238 $a_xml_writer->xmlEndTag(
"conditionvar");
241 "feedbacktype" =>
"Response",
242 "linkrefid" =>
"response_allcorrect" 244 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
245 $a_xml_writer->xmlEndTag(
"respcondition");
247 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
251 if (strlen($feedback_onenotcorrect)) {
255 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
257 $a_xml_writer->xmlStartTag(
"conditionvar");
258 foreach ($answers as $index => $answer) {
260 $a_xml_writer->xmlStartTag(
"or");
262 if ($answer->getPointsChecked() >= $answer->getPointsUnchecked()) {
263 $a_xml_writer->xmlStartTag(
"not");
266 "respident" =>
"MCMR" 268 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
269 if ($answer->getPointsChecked() >= $answer->getPointsUnchecked()) {
270 $a_xml_writer->xmlEndTag(
"not");
273 $a_xml_writer->xmlEndTag(
"or");
276 $a_xml_writer->xmlEndTag(
"conditionvar");
279 "feedbacktype" =>
"Response",
280 "linkrefid" =>
"response_onenotcorrect" 282 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
283 $a_xml_writer->xmlEndTag(
"respcondition");
285 $a_xml_writer->xmlEndTag(
"resprocessing");
288 foreach ($answers as $index => $answer) {
289 $linkrefid =
"response_$index";
291 "ident" => $linkrefid,
294 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
296 $a_xml_writer->xmlStartTag(
"flow_mat");
297 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
303 $a_xml_writer->xmlEndTag(
"flow_mat");
304 $a_xml_writer->xmlEndTag(
"itemfeedback");
306 if (strlen($feedback_allcorrect)) {
308 "ident" =>
"response_allcorrect",
311 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
313 $a_xml_writer->xmlStartTag(
"flow_mat");
315 $a_xml_writer->xmlEndTag(
"flow_mat");
316 $a_xml_writer->xmlEndTag(
"itemfeedback");
318 if (strlen($feedback_onenotcorrect)) {
320 "ident" =>
"response_onenotcorrect",
323 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
325 $a_xml_writer->xmlStartTag(
"flow_mat");
327 $a_xml_writer->xmlEndTag(
"flow_mat");
328 $a_xml_writer->xmlEndTag(
"itemfeedback");
333 $a_xml_writer->xmlEndTag(
"item");
334 $a_xml_writer->xmlEndTag(
"questestinterop");
336 $xml = $a_xml_writer->xmlDumpMem(
false);
337 if (!$a_include_header) {
338 $pos = strpos($xml,
"?>");
339 $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
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)
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...