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,
"QUESTIONTYPE");
77 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
78 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
79 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"AUTHOR");
80 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getAuthor());
81 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
82 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
83 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"textrating");
84 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getTextRating());
85 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
94 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
95 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"matchcondition");
96 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->matchcondition);
97 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
99 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
100 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"termscoring");
101 $scores = serialize($this->object->getAnswers());
102 $a_xml_writer->xmlElement(
"fieldentry", NULL, $scores);
103 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
105 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
106 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"termrelation");
107 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getKeywordRelation());
108 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
110 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
111 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"specificfeedback");
112 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getKeywordRelation());
113 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
115 $a_xml_writer->xmlEndTag(
"qtimetadata");
116 $a_xml_writer->xmlEndTag(
"itemmetadata");
120 "label" => $this->object->getTitle()
122 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
124 $a_xml_writer->xmlStartTag(
"flow");
126 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
130 "rcardinality" =>
"Ordered"
132 $a_xml_writer->xmlStartTag(
"response_str", $attrs);
134 "fibtype" =>
"String",
137 if ($this->object->getMaxNumOfChars() > 0)
139 $attrs[
"maxchars"] = $this->
object->getMaxNumOfChars();
141 $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
145 $a_xml_writer->xmlStartTag(
"response_label", $attrs);
146 $a_xml_writer->xmlEndTag(
"response_label");
147 $a_xml_writer->xmlEndTag(
"render_fib");
149 $solution = $this->
object->getSuggestedSolution(0);
150 if (count($solution))
152 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
154 $a_xml_writer->xmlStartTag(
"material");
155 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
156 if (strcmp($matches[1],
"") != 0)
158 $intlink = $solution[
"internal_link"];
161 "label" =>
"suggested_solution"
163 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
164 $a_xml_writer->xmlEndTag(
"material");
167 $a_xml_writer->xmlEndTag(
"response_str");
168 $a_xml_writer->xmlEndTag(
"flow");
169 $a_xml_writer->xmlEndTag(
"presentation");
173 "scoremodel" =>
"HumanRater"
175 $a_xml_writer->xmlStartTag(
"resprocessing", $attrs);
176 $a_xml_writer->xmlStartTag(
"outcomes");
178 "varname" =>
"WritingScore",
179 "vartype" =>
"Integer",
181 "maxvalue" => $this->object->getPoints()
183 $a_xml_writer->xmlStartTag(
"decvar", $attrs);
184 $a_xml_writer->xmlEndTag(
"decvar");
185 $a_xml_writer->xmlEndTag(
"outcomes");
187 $feedback_allcorrect = $this->
object->getFeedbackGeneric(1);
188 $feedback_onenotcorrect = $this->
object->getFeedbackGeneric(0);
189 if (strlen($feedback_allcorrect . $feedback_onenotcorrect))
191 if (strlen($feedback_allcorrect))
196 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
198 $a_xml_writer->xmlStartTag(
"conditionvar");
200 "respident" =>
"points"
202 $a_xml_writer->xmlElement(
"varequal", $attrs, $this->object->getPoints());
203 $a_xml_writer->xmlEndTag(
"conditionvar");
206 "feedbacktype" =>
"Response",
207 "linkrefid" =>
"response_allcorrect"
209 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
210 $a_xml_writer->xmlEndTag(
"respcondition");
213 if (strlen($feedback_onenotcorrect))
218 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
220 $a_xml_writer->xmlStartTag(
"conditionvar");
221 $a_xml_writer->xmlStartTag(
"not");
223 "respident" =>
"points"
225 $a_xml_writer->xmlElement(
"varequal", $attrs, $this->object->getPoints());
226 $a_xml_writer->xmlEndTag(
"not");
227 $a_xml_writer->xmlEndTag(
"conditionvar");
230 "feedbacktype" =>
"Response",
231 "linkrefid" =>
"response_onenotcorrect"
233 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
234 $a_xml_writer->xmlEndTag(
"respcondition");
238 $a_xml_writer->xmlStartTag(
"respcondition");
239 $a_xml_writer->xmlStartTag(
"conditionvar");
240 $a_xml_writer->xmlElement(
"other", NULL,
"tutor_rated");
241 $a_xml_writer->xmlEndTag(
"conditionvar");
242 $a_xml_writer->xmlEndTag(
"respcondition");
243 $a_xml_writer->xmlEndTag(
"resprocessing");
245 if (strlen($feedback_allcorrect))
248 "ident" =>
"response_allcorrect",
251 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
253 $a_xml_writer->xmlStartTag(
"flow_mat");
254 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
255 $a_xml_writer->xmlEndTag(
"flow_mat");
256 $a_xml_writer->xmlEndTag(
"itemfeedback");
258 if (strlen($feedback_onenotcorrect))
261 "ident" =>
"response_onenotcorrect",
264 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
266 $a_xml_writer->xmlStartTag(
"flow_mat");
267 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
268 $a_xml_writer->xmlEndTag(
"flow_mat");
269 $a_xml_writer->xmlEndTag(
"itemfeedback");
272 $a_xml_writer->xmlEndTag(
"item");
273 $a_xml_writer->xmlEndTag(
"questestinterop");
275 $xml = $a_xml_writer->xmlDumpMem(FALSE);
276 if (!$a_include_header)
278 $pos = strpos($xml,
"?>");
279 $xml = substr($xml, $pos + 2);