24 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
46 function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
49 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
53 $a_xml_writer->xmlStartTag(
"questestinterop");
55 "ident" =>
"il_".IL_INST_ID.
"_qst_".$this->object->getId(),
56 "title" => $this->
object->getTitle(),
57 "maxattempts" => $this->
object->getNrOfTries()
59 $a_xml_writer->xmlStartTag(
"item", $attrs);
61 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->object->getComment());
63 $workingtime = $this->
object->getEstimatedWorkingTime();
64 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
65 $a_xml_writer->xmlElement(
"duration", NULL, $duration);
67 $a_xml_writer->xmlStartTag(
"itemmetadata");
68 $a_xml_writer->xmlStartTag(
"qtimetadata");
69 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
70 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
71 $a_xml_writer->xmlElement(
"fieldentry", NULL, $ilias->getSetting(
"ilias_version"));
72 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
73 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
74 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"QUESTIONTYPE");
76 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
77 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
78 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"AUTHOR");
79 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getAuthor());
80 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
81 $a_xml_writer->xmlEndTag(
"qtimetadata");
82 $a_xml_writer->xmlEndTag(
"itemmetadata");
86 "label" => $this->object->getTitle()
88 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
90 $a_xml_writer->xmlStartTag(
"flow");
92 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
93 $solution = $this->
object->getSuggestedSolution(0);
96 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
98 $a_xml_writer->xmlStartTag(
"material");
99 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
100 if (strcmp($matches[1],
"") != 0)
102 $intlink = $solution[
"internal_link"];
105 "label" =>
"suggested_solution"
107 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
108 $a_xml_writer->xmlEndTag(
"material");
112 $a_xml_writer->xmlStartTag(
"material");
114 "label" =>
"applet data",
115 "uri" => $this->object->getJavaAppletFilename(),
116 "height" => $this->
object->getJavaHeight(),
117 "width" => $this->
object->getJavaWidth(),
118 "embedded" =>
"base64"
120 $javapath = $this->
object->getJavaPath() . $this->
object->getJavaAppletFilename();
121 $fh = @fopen($javapath,
"rb");
126 $javafile = fread($fh, filesize($javapath));
128 $base64 = base64_encode($javafile);
129 $a_xml_writer->xmlElement(
"matapplet", $attrs, $base64);
131 if ($this->object->buildParamsOnly())
133 if ($this->object->getJavaCode())
136 "label" =>
"java_code"
138 $a_xml_writer->xmlElement(
"mattext", $attrs, $this->object->getJavaCode());
140 if ($this->object->getJavaCodebase())
143 "label" =>
"java_codebase"
145 $a_xml_writer->xmlElement(
"mattext", $attrs, $this->object->getJavaCodebase());
147 if ($this->object->getJavaArchive())
150 "label" =>
"java_archive"
152 $a_xml_writer->xmlElement(
"mattext", $attrs, $this->object->getJavaArchive());
154 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
156 $param = $this->
object->getParameter($i);
158 "label" => $param[
"name"]
160 $a_xml_writer->xmlElement(
"mattext", $attrs, $param[
"value"]);
163 $a_xml_writer->xmlEndTag(
"material");
164 $a_xml_writer->xmlStartTag(
"material");
168 $a_xml_writer->xmlElement(
"mattext", $attrs, $this->object->getPoints());
169 $a_xml_writer->xmlEndTag(
"material");
171 $a_xml_writer->xmlEndTag(
"flow");
172 $a_xml_writer->xmlEndTag(
"presentation");
175 $feedback_allcorrect = $this->
object->getFeedbackGeneric(1);
176 $feedback_onenotcorrect = $this->
object->getFeedbackGeneric(0);
177 if (strlen($feedback_allcorrect . $feedback_onenotcorrect))
179 $a_xml_writer->xmlStartTag(
"resprocessing");
180 $a_xml_writer->xmlStartTag(
"outcomes");
181 $a_xml_writer->xmlStartTag(
"decvar");
182 $a_xml_writer->xmlEndTag(
"decvar");
183 $a_xml_writer->xmlEndTag(
"outcomes");
185 if (strlen($feedback_allcorrect))
190 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
192 $a_xml_writer->xmlStartTag(
"conditionvar");
194 "respident" =>
"points"
196 $a_xml_writer->xmlElement(
"varequal", $attrs, $this->object->getPoints());
197 $a_xml_writer->xmlEndTag(
"conditionvar");
200 "feedbacktype" =>
"Response",
201 "linkrefid" =>
"response_allcorrect"
203 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
204 $a_xml_writer->xmlEndTag(
"respcondition");
207 if (strlen($feedback_onenotcorrect))
212 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
214 $a_xml_writer->xmlStartTag(
"conditionvar");
215 $a_xml_writer->xmlStartTag(
"not");
217 "respident" =>
"points"
219 $a_xml_writer->xmlElement(
"varequal", $attrs, $this->object->getPoints());
220 $a_xml_writer->xmlEndTag(
"not");
221 $a_xml_writer->xmlEndTag(
"conditionvar");
224 "feedbacktype" =>
"Response",
225 "linkrefid" =>
"response_onenotcorrect"
227 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
228 $a_xml_writer->xmlEndTag(
"respcondition");
230 $a_xml_writer->xmlEndTag(
"resprocessing");
233 if (strlen($feedback_allcorrect))
236 "ident" =>
"response_allcorrect",
239 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
241 $a_xml_writer->xmlStartTag(
"flow_mat");
242 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
243 $a_xml_writer->xmlEndTag(
"flow_mat");
244 $a_xml_writer->xmlEndTag(
"itemfeedback");
246 if (strlen($feedback_onenotcorrect))
249 "ident" =>
"response_onenotcorrect",
252 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
254 $a_xml_writer->xmlStartTag(
"flow_mat");
255 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
256 $a_xml_writer->xmlEndTag(
"flow_mat");
257 $a_xml_writer->xmlEndTag(
"itemfeedback");
260 $a_xml_writer->xmlEndTag(
"item");
261 $a_xml_writer->xmlEndTag(
"questestinterop");
262 $xml = $a_xml_writer->xmlDumpMem(FALSE);
263 if (!$a_include_header)
265 $pos = strpos($xml,
"?>");
266 $xml = substr($xml, $pos + 2);