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
29 $ilias = $DIC[
'ilias'];
31 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
35 $a_xml_writer->xmlStartTag(
"questestinterop");
37 "ident" =>
"il_" . IL_INST_ID .
"_qst_" . $this->object->getId(),
38 "title" => $this->
object->getTitle(),
39 "maxattempts" => $this->
object->getNrOfTries()
41 $a_xml_writer->xmlStartTag(
"item", $attrs);
43 $a_xml_writer->xmlElement(
"qticomment", null, $this->object->getComment());
45 $workingtime = $this->
object->getEstimatedWorkingTime();
46 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
47 $a_xml_writer->xmlElement(
"duration", null, $duration);
49 $a_xml_writer->xmlStartTag(
"itemmetadata");
50 $a_xml_writer->xmlStartTag(
"qtimetadata");
51 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
52 $a_xml_writer->xmlElement(
"fieldlabel", null,
"ILIAS_VERSION");
53 $a_xml_writer->xmlElement(
"fieldentry", null, $ilias->getSetting(
"ilias_version"));
54 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
55 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
56 $a_xml_writer->xmlElement(
"fieldlabel", null,
"QUESTIONTYPE");
58 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
59 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
60 $a_xml_writer->xmlElement(
"fieldlabel", null,
"AUTHOR");
61 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getAuthor());
62 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
68 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
69 $a_xml_writer->xmlElement(
"fieldlabel", null,
"thumb_size");
70 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getThumbSize());
71 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
73 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
74 $a_xml_writer->xmlElement(
"fieldlabel", null,
"feedback_setting");
75 $a_xml_writer->xmlElement(
"fieldentry", null, $this->object->getSpecificFeedbackSetting());
76 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
78 $this->
addQtiMetaDataField($a_xml_writer,
'singleline', $this->object->isSingleline ? 1 : 0);
80 $a_xml_writer->xmlEndTag(
"qtimetadata");
81 $a_xml_writer->xmlEndTag(
"itemmetadata");
85 "label" => $this->object->getTitle()
87 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
89 $a_xml_writer->xmlStartTag(
"flow");
91 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
96 "rcardinality" =>
"Multiple" 98 $a_xml_writer->xmlStartTag(
"response_lid", $attrs);
99 $solution = $this->
object->getSuggestedSolution(0);
100 if (count($solution)) {
101 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
102 $a_xml_writer->xmlStartTag(
"material");
103 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
104 if (strcmp($matches[1],
"") != 0) {
105 $intlink = $solution[
"internal_link"];
108 "label" =>
"suggested_solution" 110 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
111 $a_xml_writer->xmlEndTag(
"material");
115 $attrs = array(
'shuffle' => $this->object->getShuffle() ?
'Yes' :
'No');
116 if ($this->object->getSelectionLimit()) {
117 $attrs[
'minnumber'] =
'0';
118 $attrs[
'maxnumber'] = (string) $this->object->getSelectionLimit();
120 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
121 $answers = &$this->
object->getAnswers();
122 $akeys = array_keys($answers);
123 if ($this->object->getShuffle() && $a_shuffle) {
124 $akeys = $this->
object->pcArrayShuffle($akeys);
127 foreach ($akeys as
$index) {
128 $answer = $answers[
$index];
132 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
134 if (strlen($answer->getImage())) {
135 $this->
object->addQTIMaterial($a_xml_writer, $answer->getAnswertext(),
false,
false);
136 $imagetype =
"image/jpeg";
137 if (preg_match(
"/.*\.(png|gif)$/", $answer->getImage(), $matches)) {
138 $imagetype =
"image/" . $matches[1];
140 if ($force_image_references) {
142 "imagtype" => $imagetype,
143 "label" => $answer->getImage(),
144 "uri" => $this->
object->getImagePathWeb() . $answer->getImage()
146 $a_xml_writer->xmlElement(
"matimage", $attrs);
148 $imagepath = $this->
object->getImagePath() . $answer->getImage();
149 $fh = @
fopen($imagepath,
"rb");
151 $imagefile = fread($fh, filesize($imagepath));
153 $base64 = base64_encode($imagefile);
155 "imagtype" => $imagetype,
156 "label" => $answer->getImage(),
157 "embedded" =>
"base64" 159 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
162 $a_xml_writer->xmlEndTag(
"material");
164 $this->
object->addQTIMaterial($a_xml_writer, $answer->getAnswertext());
166 $a_xml_writer->xmlEndTag(
"response_label");
168 $a_xml_writer->xmlEndTag(
"render_choice");
169 $a_xml_writer->xmlEndTag(
"response_lid");
170 $a_xml_writer->xmlEndTag(
"flow");
171 $a_xml_writer->xmlEndTag(
"presentation");
174 $a_xml_writer->xmlStartTag(
"resprocessing");
175 $a_xml_writer->xmlStartTag(
"outcomes");
176 $a_xml_writer->xmlStartTag(
"decvar");
177 $a_xml_writer->xmlEndTag(
"decvar");
178 $a_xml_writer->xmlEndTag(
"outcomes");
180 foreach ($answers as $index => $answer) {
184 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
186 $a_xml_writer->xmlStartTag(
"conditionvar");
189 "respident" =>
"MCMR" 191 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
192 $a_xml_writer->xmlEndTag(
"conditionvar");
197 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
199 $linkrefid =
"response_$index";
201 "feedbacktype" =>
"Response",
202 "linkrefid" => $linkrefid
204 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
205 $a_xml_writer->xmlEndTag(
"respcondition");
209 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
212 $a_xml_writer->xmlStartTag(
"conditionvar");
215 "respident" =>
"MCMR" 217 $a_xml_writer->xmlStartTag(
"not");
218 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
219 $a_xml_writer->xmlEndTag(
"not");
220 $a_xml_writer->xmlEndTag(
"conditionvar");
225 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPointsUnchecked());
226 $a_xml_writer->xmlEndTag(
"respcondition");
228 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
229 $this->object->getId(),
232 if (strlen($feedback_allcorrect)) {
236 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
238 $a_xml_writer->xmlStartTag(
"conditionvar");
239 foreach ($answers as $index => $answer) {
240 if ($answer->getPointsChecked() < $answer->getPointsUnchecked()) {
241 $a_xml_writer->xmlStartTag(
"not");
244 "respident" =>
"MCMR" 246 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
247 if ($answer->getPointsChecked() < $answer->getPointsUnchecked()) {
248 $a_xml_writer->xmlEndTag(
"not");
251 $a_xml_writer->xmlEndTag(
"conditionvar");
254 "feedbacktype" =>
"Response",
255 "linkrefid" =>
"response_allcorrect" 257 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
258 $a_xml_writer->xmlEndTag(
"respcondition");
260 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
261 $this->object->getId(),
264 if (strlen($feedback_onenotcorrect)) {
268 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
270 $a_xml_writer->xmlStartTag(
"conditionvar");
271 foreach ($answers as $index => $answer) {
273 $a_xml_writer->xmlStartTag(
"or");
275 if ($answer->getPointsChecked() >= $answer->getPointsUnchecked()) {
276 $a_xml_writer->xmlStartTag(
"not");
279 "respident" =>
"MCMR" 281 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
282 if ($answer->getPointsChecked() >= $answer->getPointsUnchecked()) {
283 $a_xml_writer->xmlEndTag(
"not");
286 $a_xml_writer->xmlEndTag(
"or");
289 $a_xml_writer->xmlEndTag(
"conditionvar");
292 "feedbacktype" =>
"Response",
293 "linkrefid" =>
"response_onenotcorrect" 295 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
296 $a_xml_writer->xmlEndTag(
"respcondition");
298 $a_xml_writer->xmlEndTag(
"resprocessing");
301 foreach ($answers as $index => $answer) {
302 $linkrefid =
"response_$index";
304 "ident" => $linkrefid,
307 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
309 $a_xml_writer->xmlStartTag(
"flow_mat");
310 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
311 $this->object->getId(),
315 $this->
object->addQTIMaterial($a_xml_writer, $fb);
316 $a_xml_writer->xmlEndTag(
"flow_mat");
317 $a_xml_writer->xmlEndTag(
"itemfeedback");
319 if (strlen($feedback_allcorrect)) {
321 "ident" =>
"response_allcorrect",
324 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
326 $a_xml_writer->xmlStartTag(
"flow_mat");
327 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
328 $a_xml_writer->xmlEndTag(
"flow_mat");
329 $a_xml_writer->xmlEndTag(
"itemfeedback");
331 if (strlen($feedback_onenotcorrect)) {
333 "ident" =>
"response_onenotcorrect",
336 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
338 $a_xml_writer->xmlStartTag(
"flow_mat");
339 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
340 $a_xml_writer->xmlEndTag(
"flow_mat");
341 $a_xml_writer->xmlEndTag(
"itemfeedback");
344 $a_xml_writer->xmlEndTag(
"item");
345 $a_xml_writer->xmlEndTag(
"questestinterop");
347 $xml = $a_xml_writer->xmlDumpMem(
false);
348 if (!$a_include_header) {
349 $pos = strpos(
$xml,
"?>");
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER
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 ...
xmlHeader()
Writes xml header public.
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...