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
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);
99 if (count($solution)) {
100 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
101 $a_xml_writer->xmlStartTag(
"material");
102 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
103 if (strcmp($matches[1],
"") != 0) {
104 $intlink = $solution[
"internal_link"];
107 "label" =>
"suggested_solution" 109 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
110 $a_xml_writer->xmlEndTag(
"material");
115 if ($this->
object->getShuffle()) {
124 $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
125 $answers =&$this->
object->getAnswers();
126 $akeys = array_keys($answers);
127 if ($this->
object->getShuffle() && $a_shuffle) {
128 $akeys = $this->
object->pcArrayShuffle($akeys);
131 foreach ($akeys as
$index) {
132 $answer = $answers[
$index];
136 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
138 if (strlen($answer->getImage())) {
139 $this->
object->addQTIMaterial($a_xml_writer, $answer->getAnswertext(),
false,
false);
140 $imagetype =
"image/jpeg";
141 if (preg_match(
"/.*\.(png|gif)$/", $answer->getImage(), $matches)) {
142 $imagetype =
"image/" . $matches[1];
144 if ($force_image_references) {
146 "imagtype" => $imagetype,
147 "label" => $answer->getImage(),
148 "uri" => $this->
object->getImagePathWeb() . $answer->getImage()
150 $a_xml_writer->xmlElement(
"matimage", $attrs);
152 $imagepath = $this->
object->getImagePath() . $answer->getImage();
153 $fh = @fopen($imagepath,
"rb");
155 $imagefile = fread(
$fh, filesize($imagepath));
157 $base64 = base64_encode($imagefile);
159 "imagtype" => $imagetype,
160 "label" => $answer->getImage(),
161 "embedded" =>
"base64" 163 $a_xml_writer->xmlElement(
"matimage", $attrs, $base64,
false,
false);
166 $a_xml_writer->xmlEndTag(
"material");
168 $this->
object->addQTIMaterial($a_xml_writer, $answer->getAnswertext());
170 $a_xml_writer->xmlEndTag(
"response_label");
172 $a_xml_writer->xmlEndTag(
"render_choice");
173 $a_xml_writer->xmlEndTag(
"response_lid");
174 $a_xml_writer->xmlEndTag(
"flow");
175 $a_xml_writer->xmlEndTag(
"presentation");
178 $a_xml_writer->xmlStartTag(
"resprocessing");
179 $a_xml_writer->xmlStartTag(
"outcomes");
180 $a_xml_writer->xmlStartTag(
"decvar");
181 $a_xml_writer->xmlEndTag(
"decvar");
182 $a_xml_writer->xmlEndTag(
"outcomes");
184 foreach ($answers as $index => $answer) {
188 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
190 $a_xml_writer->xmlStartTag(
"conditionvar");
193 "respident" =>
"MCSR" 195 $a_xml_writer->xmlElement(
"varequal", $attrs, $index);
196 $a_xml_writer->xmlEndTag(
"conditionvar");
201 $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
203 $linkrefid =
"response_$index";
205 "feedbacktype" =>
"Response",
206 "linkrefid" => $linkrefid
208 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
209 $a_xml_writer->xmlEndTag(
"respcondition");
212 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
216 if (strlen($feedback_allcorrect)) {
220 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
222 $a_xml_writer->xmlStartTag(
"conditionvar");
225 foreach ($answers as $index => $answer) {
226 if ($answer->getPoints() > $maxpoints) {
227 $maxpoints = $answer->getPoints();
232 "respident" =>
"MCSR" 234 $a_xml_writer->xmlElement(
"varequal", $attrs, $bestindex);
235 $a_xml_writer->xmlEndTag(
"conditionvar");
238 "feedbacktype" =>
"Response",
239 "linkrefid" =>
"response_allcorrect" 241 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
242 $a_xml_writer->xmlEndTag(
"respcondition");
245 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
249 if (strlen($feedback_onenotcorrect)) {
253 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
255 $a_xml_writer->xmlStartTag(
"conditionvar");
258 foreach ($answers as $index => $answer) {
259 if ($answer->getPoints() > $maxpoints) {
260 $maxpoints = $answer->getPoints();
265 "respident" =>
"MCSR" 267 $a_xml_writer->xmlStartTag(
"not");
268 $a_xml_writer->xmlElement(
"varequal", $attrs, $bestindex);
269 $a_xml_writer->xmlEndTag(
"not");
270 $a_xml_writer->xmlEndTag(
"conditionvar");
273 "feedbacktype" =>
"Response",
274 "linkrefid" =>
"response_onenotcorrect" 276 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
277 $a_xml_writer->xmlEndTag(
"respcondition");
280 $a_xml_writer->xmlEndTag(
"resprocessing");
283 foreach ($answers as $index => $answer) {
284 $linkrefid =
"response_$index";
286 "ident" => $linkrefid,
289 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
291 $a_xml_writer->xmlStartTag(
"flow_mat");
292 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
296 $this->
object->addQTIMaterial($a_xml_writer, $fb);
297 $a_xml_writer->xmlEndTag(
"flow_mat");
298 $a_xml_writer->xmlEndTag(
"itemfeedback");
300 if (strlen($feedback_allcorrect)) {
302 "ident" =>
"response_allcorrect",
305 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
307 $a_xml_writer->xmlStartTag(
"flow_mat");
308 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
309 $a_xml_writer->xmlEndTag(
"flow_mat");
310 $a_xml_writer->xmlEndTag(
"itemfeedback");
312 if (strlen($feedback_onenotcorrect)) {
314 "ident" =>
"response_onenotcorrect",
317 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
319 $a_xml_writer->xmlStartTag(
"flow_mat");
320 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
321 $a_xml_writer->xmlEndTag(
"flow_mat");
322 $a_xml_writer->xmlEndTag(
"itemfeedback");
325 $a_xml_writer->xmlEndTag(
"item");
326 $a_xml_writer->xmlEndTag(
"questestinterop");
328 $xml = $a_xml_writer->xmlDumpMem(
false);
329 if (!$a_include_header) {
330 $pos = strpos(
$xml,
"?>");
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.
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