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,
"externalID");
84 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->object->getExternalID());
85 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
86 $a_xml_writer->xmlEndTag(
"qtimetadata");
87 $a_xml_writer->xmlEndTag(
"itemmetadata");
91 "label" => $this->object->getTitle()
93 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
95 $a_xml_writer->xmlStartTag(
"flow");
97 $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
101 "rcardinality" =>
"Single",
102 "numtype" =>
"Decimal"
104 $a_xml_writer->xmlStartTag(
"response_num", $attrs);
105 $solution = $this->
object->getSuggestedSolution(0);
106 if (count($solution))
108 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
110 $a_xml_writer->xmlStartTag(
"material");
111 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
112 if (strcmp($matches[1],
"") != 0)
114 $intlink = $solution[
"internal_link"];
117 "label" =>
"suggested_solution"
119 $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
120 $a_xml_writer->xmlEndTag(
"material");
125 "fibtype" =>
"Decimal",
126 "maxchars" => $this->object->getMaxChars()
128 $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
129 $a_xml_writer->xmlEndTag(
"render_fib");
130 $a_xml_writer->xmlEndTag(
"response_num");
131 $a_xml_writer->xmlEndTag(
"flow");
132 $a_xml_writer->xmlEndTag(
"presentation");
135 $a_xml_writer->xmlStartTag(
"resprocessing");
136 $a_xml_writer->xmlStartTag(
"outcomes");
137 $a_xml_writer->xmlStartTag(
"decvar");
138 $a_xml_writer->xmlEndTag(
"decvar");
139 $a_xml_writer->xmlEndTag(
"outcomes");
141 $a_xml_writer->xmlStartTag(
"respcondition");
143 $a_xml_writer->xmlStartTag(
"conditionvar");
147 $a_xml_writer->xmlElement(
"vargte", $attrs, $this->object->getLowerLimit());
148 $a_xml_writer->xmlElement(
"varlte", $attrs, $this->object->getUpperLimit());
149 $a_xml_writer->xmlEndTag(
"conditionvar");
154 $a_xml_writer->xmlElement(
"setvar", $attrs, $this->object->getPoints());
157 "feedbacktype" =>
"Response",
158 "linkrefid" =>
"Correct"
160 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
161 $a_xml_writer->xmlEndTag(
"respcondition");
163 $feedback_allcorrect = $this->
object->getFeedbackGeneric(1);
164 if (strlen($feedback_allcorrect))
169 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
171 $a_xml_writer->xmlStartTag(
"conditionvar");
175 $a_xml_writer->xmlElement(
"vargte", $attrs, $this->object->getLowerLimit());
176 $a_xml_writer->xmlElement(
"varlte", $attrs, $this->object->getUpperLimit());
177 $a_xml_writer->xmlEndTag(
"conditionvar");
180 "feedbacktype" =>
"Response",
181 "linkrefid" =>
"response_allcorrect"
183 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
184 $a_xml_writer->xmlEndTag(
"respcondition");
187 $feedback_onenotcorrect = $this->
object->getFeedbackGeneric(0);
188 if (strlen($feedback_onenotcorrect))
193 $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
195 $a_xml_writer->xmlStartTag(
"conditionvar");
196 $a_xml_writer->xmlStartTag(
"not");
200 $a_xml_writer->xmlElement(
"vargte", $attrs, $this->object->getLowerLimit());
201 $a_xml_writer->xmlElement(
"varlte", $attrs, $this->object->getUpperLimit());
202 $a_xml_writer->xmlEndTag(
"not");
203 $a_xml_writer->xmlEndTag(
"conditionvar");
206 "feedbacktype" =>
"Response",
207 "linkrefid" =>
"response_onenotcorrect"
209 $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
210 $a_xml_writer->xmlEndTag(
"respcondition");
213 $a_xml_writer->xmlEndTag(
"resprocessing");
217 "ident" =>
"Correct",
220 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
222 $a_xml_writer->xmlStartTag(
"flow_mat");
223 $a_xml_writer->xmlStartTag(
"material");
224 $a_xml_writer->xmlElement(
"mattext");
225 $a_xml_writer->xmlEndTag(
"material");
226 $a_xml_writer->xmlEndTag(
"flow_mat");
227 $a_xml_writer->xmlEndTag(
"itemfeedback");
228 if (strlen($feedback_allcorrect))
231 "ident" =>
"response_allcorrect",
234 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
236 $a_xml_writer->xmlStartTag(
"flow_mat");
237 $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
238 $a_xml_writer->xmlEndTag(
"flow_mat");
239 $a_xml_writer->xmlEndTag(
"itemfeedback");
241 if (strlen($feedback_onenotcorrect))
244 "ident" =>
"response_onenotcorrect",
247 $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
249 $a_xml_writer->xmlStartTag(
"flow_mat");
250 $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
251 $a_xml_writer->xmlEndTag(
"flow_mat");
252 $a_xml_writer->xmlEndTag(
"itemfeedback");
255 $a_xml_writer->xmlEndTag(
"item");
256 $a_xml_writer->xmlEndTag(
"questestinterop");
258 $xml = $a_xml_writer->xmlDumpMem(FALSE);
259 if (!$a_include_header)
261 $pos = strpos($xml,
"?>");
262 $xml = substr($xml,
$pos + 2);