ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.assNumericExport.php
Go to the documentation of this file.
1<?php
2
29{
36 public function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false): string
37 {
38 global $DIC;
39 $ilias = $DIC['ilias'];
40
41 $a_xml_writer = new ilXmlWriter();
42 // set xml header
43 $a_xml_writer->xmlHeader();
44 $a_xml_writer->xmlStartTag("questestinterop");
45 $attrs = [
46 "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
47 "title" => $this->object->getTitle(),
48 "maxattempts" => $this->object->getNrOfTries()
49 ];
50 $a_xml_writer->xmlStartTag("item", $attrs);
51 // add question description
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");
67
68 // additional content editing information
70 $this->addGeneralMetadata($a_xml_writer);
71
72 $a_xml_writer->xmlEndTag("qtimetadata");
73 $a_xml_writer->xmlEndTag("itemmetadata");
74
75 // PART I: qti presentation
76 $attrs = [
77 "label" => $this->object->getTitle()
78 ];
79 $a_xml_writer->xmlStartTag("presentation", $attrs);
80 // add flow to presentation
81 $a_xml_writer->xmlStartTag("flow");
82 // add material with question text to presentation
83 $this->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
84 // add answers to presentation
85 $attrs = [
86 "ident" => "NUM",
87 "rcardinality" => "Single",
88 "numtype" => "Decimal"
89 ];
90 $a_xml_writer->xmlStartTag("response_num", $attrs);
91 $a_xml_writer = $this->addSuggestedSolution($a_xml_writer);
92 // shuffle output
93 $attrs = [
94 "fibtype" => "Decimal",
95 "maxchars" => $this->object->getMaxChars()
96 ];
97 $a_xml_writer->xmlStartTag("render_fib", $attrs);
98 $a_xml_writer->xmlEndTag("render_fib");
99 $a_xml_writer->xmlEndTag("response_num");
100 $a_xml_writer->xmlEndTag("flow");
101 $a_xml_writer->xmlEndTag("presentation");
102
103 // PART II: qti resprocessing
104 $a_xml_writer->xmlStartTag("resprocessing");
105 $a_xml_writer->xmlStartTag("outcomes");
106 $a_xml_writer->xmlStartTag("decvar");
107 $a_xml_writer->xmlEndTag("decvar");
108 $a_xml_writer->xmlEndTag("outcomes");
109 // add response conditions
110 $a_xml_writer->xmlStartTag("respcondition");
111 // qti conditionvar
112 $a_xml_writer->xmlStartTag("conditionvar");
113 $attrs = [
114 "respident" => "NUM"
115 ];
116 $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
117 $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
118 $a_xml_writer->xmlEndTag("conditionvar");
119 // qti setvar
120 $attrs = [
121 "action" => "Add"
122 ];
123 $a_xml_writer->xmlElement("setvar", $attrs, $this->object->getPoints());
124 // qti displayfeedback
125 $attrs = [
126 "feedbacktype" => "Response",
127 "linkrefid" => "Correct"
128 ];
129 $a_xml_writer->xmlElement("displayfeedback", $attrs);
130 $a_xml_writer->xmlEndTag("respcondition");
131
132 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
133 $this->object->getId(),
134 true
135 );
136 if (strlen($feedback_allcorrect)) {
137 $attrs = [
138 "continue" => "Yes"
139 ];
140 $a_xml_writer->xmlStartTag("respcondition", $attrs);
141 // qti conditionvar
142 $a_xml_writer->xmlStartTag("conditionvar");
143 $attrs = [
144 "respident" => "NUM"
145 ];
146 $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
147 $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
148 $a_xml_writer->xmlEndTag("conditionvar");
149 // qti displayfeedback
150 $attrs = [
151 "feedbacktype" => "Response",
152 "linkrefid" => "response_allcorrect"
153 ];
154 $a_xml_writer->xmlElement("displayfeedback", $attrs);
155 $a_xml_writer->xmlEndTag("respcondition");
156 }
157
158 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
159 $this->object->getId(),
160 false
161 );
162 if (strlen($feedback_onenotcorrect)) {
163 $attrs = [
164 "continue" => "Yes"
165 ];
166 $a_xml_writer->xmlStartTag("respcondition", $attrs);
167 // qti conditionvar
168 $a_xml_writer->xmlStartTag("conditionvar");
169 $a_xml_writer->xmlStartTag("not");
170 $attrs = [
171 "respident" => "NUM"
172 ];
173 $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
174 $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
175 $a_xml_writer->xmlEndTag("not");
176 $a_xml_writer->xmlEndTag("conditionvar");
177 // qti displayfeedback
178 $attrs = [
179 "feedbacktype" => "Response",
180 "linkrefid" => "response_onenotcorrect"
181 ];
182 $a_xml_writer->xmlElement("displayfeedback", $attrs);
183 $a_xml_writer->xmlEndTag("respcondition");
184 }
185
186 $a_xml_writer->xmlEndTag("resprocessing");
187
188 // PART III: qti itemfeedback
189 $attrs = [
190 "ident" => "Correct",
191 "view" => "All"
192 ];
193 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
194 // qti flow_mat
195 $a_xml_writer->xmlStartTag("flow_mat");
196 $a_xml_writer->xmlStartTag("material");
197 $a_xml_writer->xmlElement("mattext");
198 $a_xml_writer->xmlEndTag("material");
199 $a_xml_writer->xmlEndTag("flow_mat");
200 $a_xml_writer->xmlEndTag("itemfeedback");
201 if (strlen($feedback_allcorrect)) {
202 $attrs = [
203 "ident" => "response_allcorrect",
204 "view" => "All"
205 ];
206 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
207 // qti flow_mat
208 $a_xml_writer->xmlStartTag("flow_mat");
209 $this->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
210 $a_xml_writer->xmlEndTag("flow_mat");
211 $a_xml_writer->xmlEndTag("itemfeedback");
212 }
213 if (strlen($feedback_onenotcorrect)) {
214 $attrs = [
215 "ident" => "response_onenotcorrect",
216 "view" => "All"
217 ];
218 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
219 // qti flow_mat
220 $a_xml_writer->xmlStartTag("flow_mat");
221 $this->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
222 $a_xml_writer->xmlEndTag("flow_mat");
223 $a_xml_writer->xmlEndTag("itemfeedback");
224 }
225
226 $a_xml_writer->xmlEndTag("item");
227 $a_xml_writer->xmlEndTag("questestinterop");
228
229 $xml = $a_xml_writer->xmlDumpMem(false);
230 if (!$a_include_header) {
231 $pos = strpos($xml, "?>");
232 $xml = substr($xml, $pos + 2);
233 }
234 return $xml;
235 }
236}
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...
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
addQTIMaterial(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
addSuggestedSolution(ilXmlWriter $writer)
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: shib_login.php:26