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