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.
36 : string
37 {
39 $ilias =
$DIC[
'ilias'];
40
41 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
43
44 $a_xml_writer->xmlHeader();
45 $a_xml_writer->xmlStartTag("questestinterop");
46 $attrs = array(
48 "title" => $this->object->getTitle(),
49 "maxattempts" => $this->object->getNrOfTries()
50 );
51 $a_xml_writer->xmlStartTag("item", $attrs);
52
53 $a_xml_writer->xmlElement(
"qticomment",
null, $this->
object->getComment());
54 $a_xml_writer->xmlStartTag("itemmetadata");
55 $a_xml_writer->xmlStartTag("qtimetadata");
56 $a_xml_writer->xmlStartTag("qtimetadatafield");
57 $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
58 $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
59 $a_xml_writer->xmlEndTag("qtimetadatafield");
60 $a_xml_writer->xmlStartTag("qtimetadatafield");
61 $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
63 $a_xml_writer->xmlEndTag("qtimetadatafield");
64 $a_xml_writer->xmlStartTag("qtimetadatafield");
65 $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
66 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getAuthor());
67 $a_xml_writer->xmlEndTag("qtimetadatafield");
68
69
72
73 $a_xml_writer->xmlStartTag("qtimetadatafield");
74 $a_xml_writer->xmlElement("fieldlabel", null, "textrating");
75 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getTextRating());
76 $a_xml_writer->xmlEndTag("qtimetadatafield");
77 $a_xml_writer->xmlStartTag("qtimetadatafield");
78 $a_xml_writer->xmlElement("fieldlabel", null, "correctanswers");
79 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getCorrectAnswers());
80 $a_xml_writer->xmlEndTag("qtimetadatafield");
81 $a_xml_writer->xmlStartTag("qtimetadatafield");
82 $a_xml_writer->xmlElement("fieldlabel", null, "points");
83 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getPoints());
84 $a_xml_writer->xmlEndTag("qtimetadatafield");
85 $a_xml_writer->xmlEndTag("qtimetadata");
86 $a_xml_writer->xmlEndTag("itemmetadata");
87
88
89 $attrs = array(
90 "label" => $this->
object->getTitle()
91 );
92 $a_xml_writer->xmlStartTag("presentation", $attrs);
93
94 $a_xml_writer->xmlStartTag("flow");
95
96 $this->
object->addQTIMaterial($a_xml_writer, $this->
object->getQuestion());
97
98 for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
99 $attrs = array(
100 "ident" => "TEXTSUBSET_$counter",
101 "rcardinality" => "Single"
102 );
103 $a_xml_writer->xmlStartTag("response_str", $attrs);
104 $solution = $this->object->getSuggestedSolution(0);
105 if ($solution !== null && count($solution)) {
106 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) {
107 $a_xml_writer->xmlStartTag("material");
108 $intlink =
"il_" .
IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
109 if (strcmp($matches[1], "") != 0) {
110 $intlink = $solution["internal_link"];
111 }
112 $attrs = array(
113 "label" => "suggested_solution"
114 );
115 $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
116 $a_xml_writer->xmlEndTag("material");
117 }
118 }
119
120 $attrs = array(
121 "fibtype" => "String",
122 "columns" => $this->
object->getMaxTextboxWidth()
123 );
124 $a_xml_writer->xmlStartTag("render_fib", $attrs);
125 $a_xml_writer->xmlEndTag("render_fib");
126 $a_xml_writer->xmlEndTag("response_str");
127 }
128
129 $a_xml_writer->xmlEndTag("flow");
130 $a_xml_writer->xmlEndTag("presentation");
131
132
133 $a_xml_writer->xmlStartTag("resprocessing");
134 $a_xml_writer->xmlStartTag("outcomes");
135 $a_xml_writer->xmlStartTag("decvar");
136 $a_xml_writer->xmlEndTag("decvar");
137 $attribs = array(
138 "varname" => "matches",
139 "defaultval" => "0"
140 );
141 $a_xml_writer->xmlElement("decvar", $attribs, null);
142 $a_xml_writer->xmlEndTag("outcomes");
143
144 for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
145 $scoregroups = &$this->object->joinAnswers();
146 foreach ($scoregroups as $points => $scoreanswers) {
147 $attrs = array(
148 "continue" => "Yes"
149 );
150 $a_xml_writer->xmlStartTag("respcondition", $attrs);
151
152 $a_xml_writer->xmlStartTag("conditionvar");
153 $attrs = array(
154 "respident" => "TEXTSUBSET_$counter"
155 );
156 $a_xml_writer->xmlElement("varsubset", $attrs, join(",", $scoreanswers));
157 $a_xml_writer->xmlEndTag("conditionvar");
158
159 $attrs = array(
160 "varname" => "matches",
161 "action" => "Add"
162 );
163 $a_xml_writer->xmlElement("setvar", $attrs, $points);
164
165 $attrs = array(
166 "feedbacktype" => "Response",
167 "linkrefid" => "Matches_$counter"
168 );
169 $a_xml_writer->xmlElement("displayfeedback", $attrs);
170 $a_xml_writer->xmlEndTag("respcondition");
171 }
172 }
173
174 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
176 true
177 );
178 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
180 false
181 );
182 if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
183 if (strlen($feedback_allcorrect)) {
184 $attrs = array(
185 "continue" => "Yes"
186 );
187 $a_xml_writer->xmlStartTag("respcondition", $attrs);
188
189 $a_xml_writer->xmlStartTag("conditionvar");
190 $attrs = array(
191 "respident" => "points"
192 );
193 $a_xml_writer->xmlElement(
"varsubset", $attrs, $this->
object->getMaximumPoints());
194 $a_xml_writer->xmlEndTag("conditionvar");
195
196 $attrs = array(
197 "feedbacktype" => "Response",
198 "linkrefid" => "response_allcorrect"
199 );
200 $a_xml_writer->xmlElement("displayfeedback", $attrs);
201 $a_xml_writer->xmlEndTag("respcondition");
202 }
203
204 if (strlen($feedback_onenotcorrect)) {
205 $attrs = array(
206 "continue" => "Yes"
207 );
208 $a_xml_writer->xmlStartTag("respcondition", $attrs);
209
210 $a_xml_writer->xmlStartTag("conditionvar");
211 $a_xml_writer->xmlStartTag("not");
212
213 $attrs = array(
214 "respident" => "points"
215 );
216 $a_xml_writer->xmlElement(
"varsubset", $attrs, $this->
object->getMaximumPoints());
217
218 $a_xml_writer->xmlEndTag("not");
219 $a_xml_writer->xmlEndTag("conditionvar");
220
221 $attrs = array(
222 "feedbacktype" => "Response",
223 "linkrefid" => "response_onenotcorrect"
224 );
225 $a_xml_writer->xmlElement("displayfeedback", $attrs);
226 $a_xml_writer->xmlEndTag("respcondition");
227 }
228 }
229
230 $a_xml_writer->xmlEndTag("resprocessing");
231
232
233 for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
234 $attrs = array(
235 "ident" => "Matches_$counter",
236 "view" => "All"
237 );
238 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
239
240 $a_xml_writer->xmlStartTag("flow_mat");
241 $a_xml_writer->xmlStartTag("material");
242 $a_xml_writer->xmlElement("mattext");
243 $a_xml_writer->xmlEndTag("material");
244 $a_xml_writer->xmlEndTag("flow_mat");
245 $a_xml_writer->xmlEndTag("itemfeedback");
246 }
247
248 if (strlen($feedback_allcorrect)) {
249 $attrs = array(
250 "ident" => "response_allcorrect",
251 "view" => "All"
252 );
253 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
254
255 $a_xml_writer->xmlStartTag("flow_mat");
256 $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
257 $a_xml_writer->xmlEndTag("flow_mat");
258 $a_xml_writer->xmlEndTag("itemfeedback");
259 }
260 if (strlen($feedback_onenotcorrect)) {
261 $attrs = array(
262 "ident" => "response_onenotcorrect",
263 "view" => "All"
264 );
265 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
266
267 $a_xml_writer->xmlStartTag("flow_mat");
268 $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
269 $a_xml_writer->xmlEndTag("flow_mat");
270 $a_xml_writer->xmlEndTag("itemfeedback");
271 }
272
274
275 $a_xml_writer->xmlEndTag("item");
276 $a_xml_writer->xmlEndTag("questestinterop");
277
278 $xml = $a_xml_writer->xmlDumpMem(
false);
279 if (!$a_include_header) {
280 $pos = strpos(
$xml,
"?>");
282 }
284 }
addGeneralMetadata(ilXmlWriter $xmlwriter)
addSolutionHints(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 TEXTSUBSET_QUESTION_IDENTIFIER