4 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
26 function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
30 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
34 $a_xml_writer->xmlStartTag(
"questestinterop");
36 "ident" =>
"il_".IL_INST_ID.
"_qst_".$this->object->getId(),
37 "title" => $this->
object->getTitle(),
38 "maxattempts" => $this->
object->getNrOfTries()
40 $a_xml_writer->xmlStartTag(
"item", $attrs);
42 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->
object->getComment());
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);
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");
67 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
68 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"thumb_size");
69 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getThumbSize());
70 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
72 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
73 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"feedback_setting");
74 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
object->getSpecificFeedbackSetting());
75 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
79 $a_xml_writer->xmlEndTag(
"qtimetadata");
80 $a_xml_writer->xmlEndTag(
"itemmetadata");
84 "label" => $this->
object->getTitle()
86 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
88 $a_xml_writer->xmlStartTag(
"flow");
90 $this->
object->addQTIMaterial($a_xml_writer, $this->
object->getQuestion());
95 "rcardinality" =>
"Single" 97 $a_xml_writer->xmlStartTag(
"response_lid", $attrs);
98 $solution = $this->
object->getSuggestedSolution(0);
101 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
103 $a_xml_writer->xmlStartTag(
"material");
104 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
105 if (strcmp($matches[1],
"") != 0)
107 $intlink = $solution[
"internal_link"];
110 "label" =>
"suggested_solution" 112 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
113 $a_xml_writer->xmlEndTag(
"material");
118 if ($this->
object->getShuffle())
130 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
131 $answers =& $this->
object->getAnswers();
132 $akeys = array_keys($answers);
133 if ($this->
object->getShuffle() && $a_shuffle)
135 $akeys = $this->
object->pcArrayShuffle($akeys);
138 foreach ($akeys as $index)
140 $answer = $answers[$index];
144 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
146 if (strlen($answer->getImage()))
148 $this->
object->addQTIMaterial($a_xml_writer, $answer->getAnswertext(), FALSE, FALSE);
149 $imagetype =
"image/jpeg";
150 if (preg_match(
"/.*\.(png|gif)$/", $answer->getImage(), $matches))
152 $imagetype =
"image/" . $matches[1];
154 if ($force_image_references)
157 "imagtype" => $imagetype,
158 "label" => $answer->getImage(),
159 "uri" => $this->
object->getImagePathWeb() . $answer->getImage()
161 $a_xml_writer->xmlElement(
"matimage", $attrs);
165 $imagepath = $this->
object->getImagePath() . $answer->getImage();
166 $fh = @fopen($imagepath,
"rb");
169 $imagefile = fread(
$fh, filesize($imagepath));
171 $base64 = base64_encode($imagefile);
173 "imagtype" => $imagetype,
174 "label" => $answer->getImage(),
175 "embedded" =>
"base64" 177 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, FALSE, FALSE);
180 $a_xml_writer->xmlEndTag(
"material");
184 $this->
object->addQTIMaterial($a_xml_writer, $answer->getAnswertext());
186 $a_xml_writer->xmlEndTag(
"response_label");
188 $a_xml_writer->xmlEndTag(
"render_choice");
189 $a_xml_writer->xmlEndTag(
"response_lid");
190 $a_xml_writer->xmlEndTag(
"flow");
191 $a_xml_writer->xmlEndTag(
"presentation");
194 $a_xml_writer->xmlStartTag(
"resprocessing");
195 $a_xml_writer->xmlStartTag(
"outcomes");
196 $a_xml_writer->xmlStartTag(
"decvar");
197 $a_xml_writer->xmlEndTag(
"decvar");
198 $a_xml_writer->xmlEndTag(
"outcomes");
200 foreach ($answers as $index => $answer)
205 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
207 $a_xml_writer->xmlStartTag(
"conditionvar");
210 "respident" =>
"MCSR" 212 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
213 $a_xml_writer->xmlEndTag(
"conditionvar");
218 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
220 $linkrefid =
"response_$index";
222 "feedbacktype" =>
"Response",
223 "linkrefid" => $linkrefid
225 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
226 $a_xml_writer->xmlEndTag(
"respcondition");
229 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
230 $this->
object->getId(), true
232 if (strlen($feedback_allcorrect))
237 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
239 $a_xml_writer->xmlStartTag(
"conditionvar");
242 foreach ($answers as $index => $answer)
244 if ($answer->getPoints() > $maxpoints)
246 $maxpoints = $answer->getPoints();
251 "respident" =>
"MCSR" 253 $a_xml_writer->xmlElement(
"varequal", $attrs, $bestindex);
254 $a_xml_writer->xmlEndTag(
"conditionvar");
257 "feedbacktype" =>
"Response",
258 "linkrefid" =>
"response_allcorrect" 260 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
261 $a_xml_writer->xmlEndTag(
"respcondition");
264 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
265 $this->
object->getId(), false
267 if (strlen($feedback_onenotcorrect))
272 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
274 $a_xml_writer->xmlStartTag(
"conditionvar");
277 foreach ($answers as $index => $answer)
279 if ($answer->getPoints() > $maxpoints)
281 $maxpoints = $answer->getPoints();
286 "respident" =>
"MCSR" 288 $a_xml_writer->xmlStartTag(
"not");
289 $a_xml_writer->xmlElement(
"varequal", $attrs, $bestindex);
290 $a_xml_writer->xmlEndTag(
"not");
291 $a_xml_writer->xmlEndTag(
"conditionvar");
294 "feedbacktype" =>
"Response",
295 "linkrefid" =>
"response_onenotcorrect" 297 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
298 $a_xml_writer->xmlEndTag(
"respcondition");
301 $a_xml_writer->xmlEndTag(
"resprocessing");
304 foreach ($answers as $index => $answer)
306 $linkrefid =
"response_$index";
308 "ident" => $linkrefid,
311 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
313 $a_xml_writer->xmlStartTag(
"flow_mat");
314 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
315 $this->
object->getId(), $index
317 $this->
object->addQTIMaterial($a_xml_writer, $fb);
318 $a_xml_writer->xmlEndTag(
"flow_mat");
319 $a_xml_writer->xmlEndTag(
"itemfeedback");
321 if (strlen($feedback_allcorrect))
324 "ident" =>
"response_allcorrect",
327 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
329 $a_xml_writer->xmlStartTag(
"flow_mat");
330 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
331 $a_xml_writer->xmlEndTag(
"flow_mat");
332 $a_xml_writer->xmlEndTag(
"itemfeedback");
334 if (strlen($feedback_onenotcorrect))
337 "ident" =>
"response_onenotcorrect",
340 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
342 $a_xml_writer->xmlStartTag(
"flow_mat");
343 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
344 $a_xml_writer->xmlEndTag(
"flow_mat");
345 $a_xml_writer->xmlEndTag(
"itemfeedback");
348 $a_xml_writer->xmlEndTag(
"item");
349 $a_xml_writer->xmlEndTag(
"questestinterop");
351 $xml = $a_xml_writer->xmlDumpMem(FALSE);
352 if (!$a_include_header)
354 $pos = strpos($xml,
"?>");
355 $xml = substr($xml, $pos + 2);
Class for question exports.
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.
Class for single choice question exports.
toXML($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
Returns a QTI xml representation of the question.
Create styles array
The data for the language used.
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
Create new PHPExcel object
obj_idprivate
const SINGLE_CHOICE_QUESTION_IDENTIFIER