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)
50 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
54 $a_xml_writer->xmlStartTag(
"questestinterop");
56 "ident" =>
"il_".IL_INST_ID.
"_qst_".$this->object->getId(),
57 "title" => $this->
object->getTitle(),
58 "maxattempts" => $this->
object->getNrOfTries()
60 $a_xml_writer->xmlStartTag(
"item", $attrs);
62 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->object->getComment());
64 $workingtime = $this->
object->getEstimatedWorkingTime();
65 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
66 $a_xml_writer->xmlElement(
"duration", NULL, $duration);
68 $a_xml_writer->xmlStartTag(
"itemmetadata");
69 $a_xml_writer->xmlStartTag(
"qtimetadata");
70 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
71 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
72 $a_xml_writer->xmlElement(
"fieldentry", NULL, $ilias->getSetting(
"ilias_version"));
73 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
74 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
75 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"externalID");
76 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getExternalID());
77 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
78 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
79 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"QUESTIONTYPE");
81 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
82 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
83 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"AUTHOR");
84 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getAuthor());
85 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
86 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
87 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"textrating");
88 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getTextRating());
89 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
90 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
91 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"correctanswers");
92 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getCorrectAnswers());
93 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
94 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
95 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"points");
96 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getPoints());
97 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
98 $a_xml_writer->xmlEndTag(
"qtimetadata");
99 $a_xml_writer->xmlEndTag(
"itemmetadata");
103 "label" => $this->object->getTitle()
105 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
107 $a_xml_writer->xmlStartTag(
"flow");
109 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
111 for ($counter = 1; $counter <= $this->
object->getCorrectAnswers(); $counter++)
114 "ident" =>
"TEXTSUBSET_" . sprintf(
"%02d", $counter),
115 "rcardinality" =>
"Single"
117 $a_xml_writer->xmlStartTag(
"response_str", $attrs);
118 $solution = $this->
object->getSuggestedSolution(0);
119 if (count($solution))
121 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
123 $a_xml_writer->xmlStartTag(
"material");
124 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
125 if (strcmp($matches[1],
"") != 0)
127 $intlink = $solution[
"internal_link"];
130 "label" =>
"suggested_solution"
132 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
133 $a_xml_writer->xmlEndTag(
"material");
138 "fibtype" =>
"String",
139 "columns" => $this->object->getMaxTextboxWidth()
141 $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
142 $a_xml_writer->xmlEndTag(
"render_fib");
143 $a_xml_writer->xmlEndTag(
"response_str");
146 $a_xml_writer->xmlEndTag(
"flow");
147 $a_xml_writer->xmlEndTag(
"presentation");
150 $a_xml_writer->xmlStartTag(
"resprocessing");
151 $a_xml_writer->xmlStartTag(
"outcomes");
152 $a_xml_writer->xmlStartTag(
"decvar");
153 $a_xml_writer->xmlEndTag(
"decvar");
155 "varname" =>
"matches",
158 $a_xml_writer->xmlElement(
"decvar", $attribs, NULL);
159 $a_xml_writer->xmlEndTag(
"outcomes");
161 for ($counter = 1; $counter <= $this->
object->getCorrectAnswers(); $counter++)
163 $scoregroups =& $this->
object->joinAnswers();
164 foreach ($scoregroups as
$points => $scoreanswers)
169 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
171 $a_xml_writer->xmlStartTag(
"conditionvar");
173 "respident" =>
"TEXTSUBSET_" . sprintf(
"%02d", $counter)
175 $a_xml_writer->xmlElement(
"varsubset", $attrs, join(
",", $scoreanswers));
176 $a_xml_writer->xmlEndTag(
"conditionvar");
179 "varname" =>
"matches",
182 $a_xml_writer->xmlElement(
"setvar", $attrs,
$points);
185 "feedbacktype" =>
"Response",
186 "linkrefid" =>
"Matches_" . sprintf(
"%02d", $counter)
188 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
189 $a_xml_writer->xmlEndTag(
"respcondition");
193 $feedback_allcorrect = $this->
object->getFeedbackGeneric(1);
194 $feedback_onenotcorrect = $this->
object->getFeedbackGeneric(0);
195 if (strlen($feedback_allcorrect . $feedback_onenotcorrect))
197 if (strlen($feedback_allcorrect))
202 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
204 $a_xml_writer->xmlStartTag(
"conditionvar");
206 "respident" =>
"points"
208 $a_xml_writer->xmlElement(
"varsubset", $attrs, $this->object->getMaximumPoints());
209 $a_xml_writer->xmlEndTag(
"conditionvar");
212 "feedbacktype" =>
"Response",
213 "linkrefid" =>
"response_allcorrect"
215 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
216 $a_xml_writer->xmlEndTag(
"respcondition");
219 if (strlen($feedback_onenotcorrect))
224 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
226 $a_xml_writer->xmlStartTag(
"conditionvar");
227 $a_xml_writer->xmlStartTag(
"not");
230 "respident" =>
"points"
232 $a_xml_writer->xmlElement(
"varsubset", $attrs, $this->object->getMaximumPoints());
234 $a_xml_writer->xmlEndTag(
"not");
235 $a_xml_writer->xmlEndTag(
"conditionvar");
238 "feedbacktype" =>
"Response",
239 "linkrefid" =>
"response_onenotcorrect"
241 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
242 $a_xml_writer->xmlEndTag(
"respcondition");
246 $a_xml_writer->xmlEndTag(
"resprocessing");
249 for ($counter = 1; $counter <= $this->
object->getCorrectAnswers(); $counter++)
252 "ident" =>
"Matches_" . sprintf(
"%02d", $counter),
255 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
257 $a_xml_writer->xmlStartTag(
"flow_mat");
258 $a_xml_writer->xmlStartTag(
"material");
259 $a_xml_writer->xmlElement(
"mattext");
260 $a_xml_writer->xmlEndTag(
"material");
261 $a_xml_writer->xmlEndTag(
"flow_mat");
262 $a_xml_writer->xmlEndTag(
"itemfeedback");
265 if (strlen($feedback_allcorrect))
268 "ident" =>
"response_allcorrect",
271 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
273 $a_xml_writer->xmlStartTag(
"flow_mat");
274 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
275 $a_xml_writer->xmlEndTag(
"flow_mat");
276 $a_xml_writer->xmlEndTag(
"itemfeedback");
278 if (strlen($feedback_onenotcorrect))
281 "ident" =>
"response_onenotcorrect",
284 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
286 $a_xml_writer->xmlStartTag(
"flow_mat");
287 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
288 $a_xml_writer->xmlEndTag(
"flow_mat");
289 $a_xml_writer->xmlEndTag(
"itemfeedback");
292 $a_xml_writer->xmlEndTag(
"item");
293 $a_xml_writer->xmlEndTag(
"questestinterop");
295 $xml = $a_xml_writer->xmlDumpMem(FALSE);
296 if (!$a_include_header)
298 $pos = strpos($xml,
"?>");
299 $xml = substr($xml,
$pos + 2);