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
32 {
34 $ilias =
$DIC[
'ilias'];
35
36 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
38
40 $a_xml_writer->xmlStartTag("questestinterop");
41 $attrs = array(
42 "ident" =>
"il_" .
IL_INST_ID .
"_qst_" . $this->object->getId(),
43 "title" => $this->object->getTitle(),
44 "maxattempts" => $this->object->getNrOfTries()
45 );
46 $a_xml_writer->xmlStartTag("item", $attrs);
47
48 $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
49
50 $workingtime = $this->object->getEstimatedWorkingTime();
51 $duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
52 $a_xml_writer->xmlElement("duration", null, $duration);
53
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 $this->
addQtiMetaDataField($a_xml_writer,
'wordcounter', (
int) $this->object->isWordCounterEnabled());
74
75 $a_xml_writer->xmlStartTag("qtimetadatafield");
76 $a_xml_writer->xmlElement("fieldlabel", null, "textrating");
77 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getTextRating());
78 $a_xml_writer->xmlEndTag("qtimetadatafield");
79
80
81
82
83
84
85
86
87 $a_xml_writer->xmlStartTag("qtimetadatafield");
88 $a_xml_writer->xmlElement("fieldlabel", null, "matchcondition");
89 $a_xml_writer->xmlElement("fieldentry", null, $this->object->matchcondition);
90 $a_xml_writer->xmlEndTag("qtimetadatafield");
91
92 $a_xml_writer->xmlStartTag("qtimetadatafield");
93 $a_xml_writer->xmlElement("fieldlabel", null, "termscoring");
94 $scores = base64_encode(serialize($this->object->getAnswers()));
95 $a_xml_writer->xmlElement("fieldentry", null, $scores);
96 $a_xml_writer->xmlEndTag("qtimetadatafield");
97
98 $a_xml_writer->xmlStartTag("qtimetadatafield");
99 $a_xml_writer->xmlElement("fieldlabel", null, "termrelation");
100 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getKeywordRelation());
101 $a_xml_writer->xmlEndTag("qtimetadatafield");
102
103 $a_xml_writer->xmlStartTag("qtimetadatafield");
104 $a_xml_writer->xmlElement("fieldlabel", null, "specificfeedback");
105 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getKeywordRelation());
106 $a_xml_writer->xmlEndTag("qtimetadatafield");
107
108 $a_xml_writer->xmlEndTag("qtimetadata");
109 $a_xml_writer->xmlEndTag("itemmetadata");
110
111
112 $attrs = array(
113 "label" => $this->object->getTitle()
114 );
115 $a_xml_writer->xmlStartTag("presentation", $attrs);
116
117 $a_xml_writer->xmlStartTag("flow");
118
119 $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
120
121 $attrs = array(
122 "ident" => "TEXT",
123 "rcardinality" => "Ordered"
124 );
125 $a_xml_writer->xmlStartTag("response_str", $attrs);
126 $attrs = array(
127 "fibtype" => "String",
128 "prompt" => "Box"
129 );
130 if ($this->object->getMaxNumOfChars() > 0) {
131 $attrs["maxchars"] = $this->object->getMaxNumOfChars();
132 }
133 $a_xml_writer->xmlStartTag("render_fib", $attrs);
134 $attrs = array(
135 "ident" => "A"
136 );
137 $a_xml_writer->xmlStartTag("response_label", $attrs);
138 $a_xml_writer->xmlEndTag("response_label");
139 $a_xml_writer->xmlEndTag("render_fib");
140
141 $solution = $this->object->getSuggestedSolution(0);
142 if (count($solution)) {
143 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) {
144 $a_xml_writer->xmlStartTag("material");
145 $intlink =
"il_" .
IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
146 if (strcmp($matches[1], "") != 0) {
147 $intlink = $solution["internal_link"];
148 }
149 $attrs = array(
150 "label" => "suggested_solution"
151 );
152 $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
153 $a_xml_writer->xmlEndTag("material");
154 }
155 }
156 $a_xml_writer->xmlEndTag("response_str");
157 $a_xml_writer->xmlEndTag("flow");
158 $a_xml_writer->xmlEndTag("presentation");
159
160
161 $attrs = array(
162 "scoremodel" => "HumanRater"
163 );
164 $a_xml_writer->xmlStartTag("resprocessing", $attrs);
165 $a_xml_writer->xmlStartTag("outcomes");
166 $attrs = array(
167 "varname" => "WritingScore",
168 "vartype" => "Integer",
169 "minvalue" => "0",
170 "maxvalue" => $this->object->getPoints()
171 );
172 $a_xml_writer->xmlStartTag("decvar", $attrs);
173 $a_xml_writer->xmlEndTag("decvar");
174 $a_xml_writer->xmlEndTag("outcomes");
175
176 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
177 $this->object->getId(),
178 true
179 );
180 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
181 $this->object->getId(),
182 false
183 );
184 if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
185 if (strlen($feedback_allcorrect)) {
186 $attrs = array(
187 "continue" => "Yes"
188 );
189 $a_xml_writer->xmlStartTag("respcondition", $attrs);
190
191 $a_xml_writer->xmlStartTag("conditionvar");
192 $attrs = array(
193 "respident" => "points"
194 );
195 $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
196 $a_xml_writer->xmlEndTag("conditionvar");
197
198 $attrs = array(
199 "feedbacktype" => "Response",
200 "linkrefid" => "response_allcorrect"
201 );
202 $a_xml_writer->xmlElement("displayfeedback", $attrs);
203 $a_xml_writer->xmlEndTag("respcondition");
204 }
205
206 if (strlen($feedback_onenotcorrect)) {
207 $attrs = array(
208 "continue" => "Yes"
209 );
210 $a_xml_writer->xmlStartTag("respcondition", $attrs);
211
212 $a_xml_writer->xmlStartTag("conditionvar");
213 $a_xml_writer->xmlStartTag("not");
214 $attrs = array(
215 "respident" => "points"
216 );
217 $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
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->xmlStartTag("respcondition");
231 $a_xml_writer->xmlStartTag("conditionvar");
232 $a_xml_writer->xmlElement("other", null, "tutor_rated");
233 $a_xml_writer->xmlEndTag("conditionvar");
234 $a_xml_writer->xmlEndTag("respcondition");
235 $a_xml_writer->xmlEndTag("resprocessing");
236
238
239 if (strlen($feedback_allcorrect)) {
240 $attrs = array(
241 "ident" => "response_allcorrect",
242 "view" => "All"
243 );
244 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
245
246 $a_xml_writer->xmlStartTag("flow_mat");
247 $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
248 $a_xml_writer->xmlEndTag("flow_mat");
249 $a_xml_writer->xmlEndTag("itemfeedback");
250 }
251 if (strlen($feedback_onenotcorrect)) {
252 $attrs = array(
253 "ident" => "response_onenotcorrect",
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_onenotcorrect);
260 $a_xml_writer->xmlEndTag("flow_mat");
261 $a_xml_writer->xmlEndTag("itemfeedback");
262 }
263
265
266 $a_xml_writer->xmlEndTag("item");
267 $a_xml_writer->xmlEndTag("questestinterop");
268
269 $xml = $a_xml_writer->xmlDumpMem(
false);
270 if (!$a_include_header) {
271 $pos = strpos(
$xml,
"?>");
273 }
275 }
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...
xmlHeader()
Writes xml header @access public.
const TEXT_QUESTION_IDENTIFIER