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
27 {
28 global $ilias;
29
30 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
32
34 $a_xml_writer->xmlStartTag("questestinterop");
35 $attrs = array(
36 "ident" => "il_".IL_INST_ID."_qst_".$this->object->getId(),
37 "title" => $this->object->getTitle(),
38 "maxattempts" => $this->object->getNrOfTries()
39 );
40 $a_xml_writer->xmlStartTag("item", $attrs);
41
42 $a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
43
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);
47
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");
62
63
66
67 $a_xml_writer->xmlStartTag("qtimetadatafield");
68 $a_xml_writer->xmlElement("fieldlabel", NULL, "textrating");
69 $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getTextRating());
70 $a_xml_writer->xmlEndTag("qtimetadatafield");
71 $a_xml_writer->xmlStartTag("qtimetadatafield");
72 $a_xml_writer->xmlElement("fieldlabel", NULL, "correctanswers");
73 $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getCorrectAnswers());
74 $a_xml_writer->xmlEndTag("qtimetadatafield");
75 $a_xml_writer->xmlStartTag("qtimetadatafield");
76 $a_xml_writer->xmlElement("fieldlabel", NULL, "points");
77 $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getPoints());
78 $a_xml_writer->xmlEndTag("qtimetadatafield");
79 $a_xml_writer->xmlEndTag("qtimetadata");
80 $a_xml_writer->xmlEndTag("itemmetadata");
81
82
83 $attrs = array(
84 "label" => $this->object->getTitle()
85 );
86 $a_xml_writer->xmlStartTag("presentation", $attrs);
87
88 $a_xml_writer->xmlStartTag("flow");
89
90 $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
91
92 for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++)
93 {
94 $attrs = array(
95 "ident" => "TEXTSUBSET_" . sprintf("%02d", $counter),
96 "rcardinality" => "Single"
97 );
98 $a_xml_writer->xmlStartTag("response_str", $attrs);
99 $solution = $this->object->getSuggestedSolution(0);
100 if (count($solution))
101 {
102 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches))
103 {
104 $a_xml_writer->xmlStartTag("material");
105 $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
106 if (strcmp($matches[1], "") != 0)
107 {
108 $intlink = $solution["internal_link"];
109 }
110 $attrs = array(
111 "label" => "suggested_solution"
112 );
113 $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
114 $a_xml_writer->xmlEndTag("material");
115 }
116 }
117
118 $attrs = array(
119 "fibtype" => "String",
120 "columns" => $this->object->getMaxTextboxWidth()
121 );
122 $a_xml_writer->xmlStartTag("render_fib", $attrs);
123 $a_xml_writer->xmlEndTag("render_fib");
124 $a_xml_writer->xmlEndTag("response_str");
125 }
126
127 $a_xml_writer->xmlEndTag("flow");
128 $a_xml_writer->xmlEndTag("presentation");
129
130
131 $a_xml_writer->xmlStartTag("resprocessing");
132 $a_xml_writer->xmlStartTag("outcomes");
133 $a_xml_writer->xmlStartTag("decvar");
134 $a_xml_writer->xmlEndTag("decvar");
135 $attribs = array(
136 "varname" => "matches",
137 "defaultval" => "0"
138 );
139 $a_xml_writer->xmlElement("decvar", $attribs, NULL);
140 $a_xml_writer->xmlEndTag("outcomes");
141
142 for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++)
143 {
144 $scoregroups =& $this->object->joinAnswers();
145 foreach ($scoregroups as $points => $scoreanswers)
146 {
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_" . sprintf("%02d", $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_" . sprintf("%02d", $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(
175 $this->object->getId(), true
176 );
177 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
178 $this->object->getId(), false
179 );
180 if (strlen($feedback_allcorrect . $feedback_onenotcorrect))
181 {
182 if (strlen($feedback_allcorrect))
183 {
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 {
206 $attrs = array(
207 "continue" => "Yes"
208 );
209 $a_xml_writer->xmlStartTag("respcondition", $attrs);
210
211 $a_xml_writer->xmlStartTag("conditionvar");
212 $a_xml_writer->xmlStartTag("not");
213
214 $attrs = array(
215 "respident" => "points"
216 );
217 $a_xml_writer->xmlElement("varsubset", $attrs, $this->object->getMaximumPoints());
218
219 $a_xml_writer->xmlEndTag("not");
220 $a_xml_writer->xmlEndTag("conditionvar");
221
222 $attrs = array(
223 "feedbacktype" => "Response",
224 "linkrefid" => "response_onenotcorrect"
225 );
226 $a_xml_writer->xmlElement("displayfeedback", $attrs);
227 $a_xml_writer->xmlEndTag("respcondition");
228 }
229 }
230
231 $a_xml_writer->xmlEndTag("resprocessing");
232
233
234 for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++)
235 {
236 $attrs = array(
237 "ident" => "Matches_" . sprintf("%02d", $counter),
238 "view" => "All"
239 );
240 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
241
242 $a_xml_writer->xmlStartTag("flow_mat");
243 $a_xml_writer->xmlStartTag("material");
244 $a_xml_writer->xmlElement("mattext");
245 $a_xml_writer->xmlEndTag("material");
246 $a_xml_writer->xmlEndTag("flow_mat");
247 $a_xml_writer->xmlEndTag("itemfeedback");
248 }
249
250 if (strlen($feedback_allcorrect))
251 {
252 $attrs = array(
253 "ident" => "response_allcorrect",
254 "view" => "All"
255 );
256 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
257
258 $a_xml_writer->xmlStartTag("flow_mat");
259 $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
260 $a_xml_writer->xmlEndTag("flow_mat");
261 $a_xml_writer->xmlEndTag("itemfeedback");
262 }
263 if (strlen($feedback_onenotcorrect))
264 {
265 $attrs = array(
266 "ident" => "response_onenotcorrect",
267 "view" => "All"
268 );
269 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
270
271 $a_xml_writer->xmlStartTag("flow_mat");
272 $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
273 $a_xml_writer->xmlEndTag("flow_mat");
274 $a_xml_writer->xmlEndTag("itemfeedback");
275 }
276
277 $a_xml_writer->xmlEndTag("item");
278 $a_xml_writer->xmlEndTag("questestinterop");
279
280 $xml = $a_xml_writer->xmlDumpMem(FALSE);
281 if (!$a_include_header)
282 {
283 $pos = strpos($xml, "?>");
284 $xml = substr($xml, $pos + 2);
285 }
286 return $xml;
287 }
addGeneralMetadata(ilXmlWriter $xmlwriter)
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
xmlHeader()
Writes xml header @access public.
const TEXTSUBSET_QUESTION_IDENTIFIER