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->xmlStartTag(
"qtimetadatafield");
82 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"externalID");
83 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getExternalID());
84 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
85 $a_xml_writer->xmlEndTag(
"qtimetadata");
86 $a_xml_writer->xmlEndTag(
"itemmetadata");
90 "label" => $this->object->getTitle()
92 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
94 $a_xml_writer->xmlStartTag(
"flow");
96 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
97 $solution = $this->
object->getSuggestedSolution(0);
100 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)
106 $intlink = $solution[
"internal_link"];
109 "label" =>
"suggested_solution"
111 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
112 $a_xml_writer->xmlEndTag(
"material");
116 $a_xml_writer->xmlStartTag(
"material");
118 "label" =>
"applet data",
119 "uri" => $this->object->getJavaAppletFilename(),
120 "height" => $this->
object->getJavaHeight(),
121 "width" => $this->
object->getJavaWidth(),
122 "embedded" =>
"base64"
124 $javapath = $this->
object->getJavaPath() . $this->
object->getJavaAppletFilename();
125 $fh = @fopen($javapath,
"rb");
130 $javafile = fread($fh, filesize($javapath));
132 $base64 = base64_encode($javafile);
133 $a_xml_writer->xmlElement(
"matapplet", $attrs, $base64);
135 if ($this->object->buildParamsOnly())
137 if ($this->object->getJavaCode())
140 "label" =>
"java_code"
142 $a_xml_writer->xmlElement(
"mattext", $attrs, $this->object->getJavaCode());
144 if ($this->object->getJavaCodebase())
147 "label" =>
"java_codebase"
149 $a_xml_writer->xmlElement(
"mattext", $attrs, $this->object->getJavaCodebase());
151 if ($this->object->getJavaArchive())
154 "label" =>
"java_archive"
156 $a_xml_writer->xmlElement(
"mattext", $attrs, $this->object->getJavaArchive());
158 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
160 $param = $this->
object->getParameter($i);
162 "label" => $param[
"name"]
164 $a_xml_writer->xmlElement(
"mattext", $attrs, $param[
"value"]);
167 $a_xml_writer->xmlEndTag(
"material");
168 $a_xml_writer->xmlStartTag(
"material");
172 $a_xml_writer->xmlElement(
"mattext", $attrs, $this->object->getPoints());
173 $a_xml_writer->xmlEndTag(
"material");
175 $a_xml_writer->xmlEndTag(
"flow");
176 $a_xml_writer->xmlEndTag(
"presentation");
179 $feedback_allcorrect = $this->
object->getFeedbackGeneric(1);
180 $feedback_onenotcorrect = $this->
object->getFeedbackGeneric(0);
181 if (strlen($feedback_allcorrect . $feedback_onenotcorrect))
183 $a_xml_writer->xmlStartTag(
"resprocessing");
184 $a_xml_writer->xmlStartTag(
"outcomes");
185 $a_xml_writer->xmlStartTag(
"decvar");
186 $a_xml_writer->xmlEndTag(
"decvar");
187 $a_xml_writer->xmlEndTag(
"outcomes");
189 if (strlen($feedback_allcorrect))
194 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
196 $a_xml_writer->xmlStartTag(
"conditionvar");
198 "respident" =>
"points"
200 $a_xml_writer->xmlElement(
"varequal", $attrs, $this->object->getPoints());
201 $a_xml_writer->xmlEndTag(
"conditionvar");
204 "feedbacktype" =>
"Response",
205 "linkrefid" =>
"response_allcorrect"
207 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
208 $a_xml_writer->xmlEndTag(
"respcondition");
211 if (strlen($feedback_onenotcorrect))
216 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
218 $a_xml_writer->xmlStartTag(
"conditionvar");
219 $a_xml_writer->xmlStartTag(
"not");
221 "respident" =>
"points"
223 $a_xml_writer->xmlElement(
"varequal", $attrs, $this->object->getPoints());
224 $a_xml_writer->xmlEndTag(
"not");
225 $a_xml_writer->xmlEndTag(
"conditionvar");
228 "feedbacktype" =>
"Response",
229 "linkrefid" =>
"response_onenotcorrect"
231 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
232 $a_xml_writer->xmlEndTag(
"respcondition");
234 $a_xml_writer->xmlEndTag(
"resprocessing");
237 if (strlen($feedback_allcorrect))
240 "ident" =>
"response_allcorrect",
243 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
245 $a_xml_writer->xmlStartTag(
"flow_mat");
246 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
247 $a_xml_writer->xmlEndTag(
"flow_mat");
248 $a_xml_writer->xmlEndTag(
"itemfeedback");
250 if (strlen($feedback_onenotcorrect))
253 "ident" =>
"response_onenotcorrect",
256 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
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");
264 $a_xml_writer->xmlEndTag(
"item");
265 $a_xml_writer->xmlEndTag(
"questestinterop");
266 $xml = $a_xml_writer->xmlDumpMem(FALSE);
267 if (!$a_include_header)
269 $pos = strpos($xml,
"?>");
270 $xml = substr($xml,
$pos + 2);