4 require_once
'Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php';
19 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
22 $ilias = $DIC[
'ilias'];
24 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
28 $xml->xmlStartTag(
"questestinterop");
30 "ident" =>
"il_" . IL_INST_ID .
"_qst_" . $this->object->getId(),
31 "title" => $this->
object->getTitle(),
32 "maxattempts" => $this->
object->getNrOfTries()
34 $xml->xmlStartTag(
"item", $attrs);
36 $xml->xmlElement(
"qticomment", null, $this->object->getComment());
38 $workingtime = $this->
object->getEstimatedWorkingTime();
39 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
40 $xml->xmlElement(
"duration", null, $duration);
42 $xml->xmlStartTag(
"itemmetadata");
43 $xml->xmlStartTag(
"qtimetadata");
44 $xml->xmlStartTag(
"qtimetadatafield");
45 $xml->xmlElement(
"fieldlabel", null,
"ILIAS_VERSION");
46 $xml->xmlElement(
"fieldentry", null, $ilias->getSetting(
"ilias_version"));
47 $xml->xmlEndTag(
"qtimetadatafield");
48 $xml->xmlStartTag(
"qtimetadatafield");
49 $xml->xmlElement(
"fieldlabel", null,
"QUESTIONTYPE");
51 $xml->xmlEndTag(
"qtimetadatafield");
52 $xml->xmlStartTag(
"qtimetadatafield");
53 $xml->xmlElement(
"fieldlabel", null,
"AUTHOR");
54 $xml->xmlElement(
"fieldentry", null, $this->object->getAuthor());
55 $xml->xmlEndTag(
"qtimetadatafield");
61 $xml->xmlStartTag(
"qtimetadatafield");
62 $xml->xmlElement(
"fieldlabel", null,
"answer_type");
63 $xml->xmlElement(
"fieldentry", null, $this->object->getAnswerType());
64 $xml->xmlEndTag(
"qtimetadatafield");
66 $xml->xmlStartTag(
"qtimetadatafield");
67 $xml->xmlElement(
"fieldlabel", null,
"thumb_size");
68 $xml->xmlElement(
"fieldentry", null, $this->object->getThumbSize());
69 $xml->xmlEndTag(
"qtimetadatafield");
71 $xml->xmlStartTag(
"qtimetadatafield");
72 $xml->xmlElement(
"fieldlabel", null,
"option_label_setting");
73 $xml->xmlElement(
"fieldentry", null, $this->object->getOptionLabel());
74 $xml->xmlEndTag(
"qtimetadatafield");
75 $xml->xmlStartTag(
"qtimetadatafield");
76 $xml->xmlElement(
"fieldlabel", null,
"custom_true_option_label");
77 $xml->xmlElement(
"fieldentry", null, $this->object->getCustomTrueOptionLabel());
78 $xml->xmlEndTag(
"qtimetadatafield");
79 $xml->xmlStartTag(
"qtimetadatafield");
80 $xml->xmlElement(
"fieldlabel", null,
"custom_false_option_label");
81 $xml->xmlElement(
"fieldentry", null, $this->object->getCustomFalseOptionLabel());
82 $xml->xmlEndTag(
"qtimetadatafield");
84 $xml->xmlStartTag(
"qtimetadatafield");
85 $xml->xmlElement(
"fieldlabel", null,
"feedback_setting");
86 $xml->xmlElement(
"fieldentry", null, $this->object->getSpecificFeedbackSetting());
87 $xml->xmlEndTag(
"qtimetadatafield");
89 $xml->xmlEndTag(
"qtimetadata");
90 $xml->xmlEndTag(
"itemmetadata");
94 "label" => $this->object->getTitle()
96 $xml->xmlStartTag(
"presentation", $attrs);
98 $xml->xmlStartTag(
"flow");
100 $this->
object->addQTIMaterial(
$xml, $this->object->getQuestion());
104 "rcardinality" =>
"Multiple" 106 $xml->xmlStartTag(
"response_lid", $attrs);
107 $solution = $this->
object->getSuggestedSolution(0);
108 if (count($solution)) {
109 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
110 $xml->xmlStartTag(
"material");
111 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
112 if (strcmp($matches[1],
"") != 0) {
113 $intlink = $solution[
"internal_link"];
116 "label" =>
"suggested_solution" 118 $xml->xmlElement(
"mattext", $attrs, $intlink);
119 $xml->xmlEndTag(
"material");
124 if ($this->object->isShuffleAnswersEnabled()) {
133 $xml->xmlStartTag(
"render_choice", $attrs);
136 $answers = &$this->
object->getAnswers();
137 $akeys = array_keys($answers);
138 foreach ($akeys as
$index) {
139 $answer = $this->
object->getAnswer($index);
141 $xml->xmlStartTag(
'response_label', array(
'ident' => $answer->getPosition()));
143 if (strlen($answer->getImageFile())) {
144 $this->
object->addQTIMaterial(
$xml, $answer->getAnswertext(),
false,
false);
145 $imagetype =
"image/jpeg";
146 if (preg_match(
"/.*\.(png|gif)$/", $answer->getImageFile(), $matches)) {
147 $imagetype =
"image/" . $matches[1];
149 if ($force_image_references) {
151 "imagtype" => $imagetype,
152 "label" => $answer->getImageFile(),
153 "uri" => $answer->getImageWebPath()
155 $xml->xmlElement(
"matimage", $attrs);
157 $imagepath = $answer->getImageFsPath();
158 $fh = @
fopen($imagepath,
"rb");
160 $imagefile = fread($fh, filesize($imagepath));
162 $base64 = base64_encode($imagefile);
164 "imagtype" => $imagetype,
165 "label" => $answer->getImageFile(),
166 "embedded" =>
"base64" 168 $xml->xmlElement(
"matimage", $attrs, $base64,
false,
false);
171 $xml->xmlEndTag(
"material");
173 $this->
object->addQTIMaterial(
$xml, $answer->getAnswertext());
175 $xml->xmlEndTag(
"response_label");
177 $xml->xmlEndTag(
"render_choice");
178 $xml->xmlEndTag(
"response_lid");
179 $xml->xmlEndTag(
"flow");
180 $xml->xmlEndTag(
"presentation");
184 $xml->xmlStartTag(
'resprocessing');
186 $xml->xmlStartTag(
'outcomes');
187 $xml->xmlElement(
'decvar', array(
188 'varname' =>
'SCORE',
'vartype' =>
'Decimal',
'defaultval' =>
'0',
191 $xml->xmlEndTag(
'outcomes');
194 foreach ($answers as $answer) {
195 $xml->xmlStartTag(
'respcondition', array(
'continue' =>
'Yes'));
197 $xml->xmlStartTag(
'conditionvar');
198 $xml->xmlElement(
'varequal', array(
'respident' => $answer->getPosition()), $answer->getCorrectness());
199 $xml->xmlEndTag(
'conditionvar');
201 $xml->xmlElement(
'displayfeedback', array(
202 'feedbacktype' =>
'Response',
'linkrefid' =>
"response_{$answer->getPosition()}" 205 $xml->xmlEndTag(
'respcondition');
208 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
209 $this->object->getId(),
213 $xml->xmlStartTag(
'respcondition', array(
'continue' =>
'Yes'));
215 $xml->xmlStartTag(
'conditionvar');
216 $xml->xmlStartTag(
'and');
217 foreach ($answers as $answer) {
218 $xml->xmlElement(
'varequal', array(
'respident' => $answer->getPosition()), $answer->getCorrectness());
220 $xml->xmlEndTag(
'and');
221 $xml->xmlEndTag(
'conditionvar');
223 $xml->xmlElement(
'setvar', array(
'action' =>
'Add'), $this->object->getPoints());
225 if (strlen($feedback_allcorrect)) {
226 $xml->xmlElement(
'displayfeedback', array(
'feedbacktype' =>
'Response',
'linkrefid' =>
'response_allcorrect'));
229 $xml->xmlEndTag(
'respcondition');
231 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
232 $this->object->getId(),
236 $xml->xmlStartTag(
'respcondition', array(
'continue' =>
'Yes'));
238 $xml->xmlStartTag(
'conditionvar');
239 $xml->xmlStartTag(
'or');
240 foreach ($answers as $answer) {
241 $xml->xmlStartTag(
'not');
242 $xml->xmlElement(
'varequal', array(
'respident' => $answer->getPosition()), $answer->getCorrectness());
243 $xml->xmlEndTag(
'not');
245 $xml->xmlEndTag(
'or');
246 $xml->xmlEndTag(
'conditionvar');
248 $xml->xmlElement(
'setvar', array(
'action' =>
'Add'), 0);
250 if (strlen($feedback_onenotcorrect)) {
251 $xml->xmlElement(
'displayfeedback', array(
'feedbacktype' =>
'Response',
'linkrefid' =>
'response_onenotcorrect'));
254 $xml->xmlEndTag(
'respcondition');
256 $xml->xmlEndTag(
'resprocessing');
258 foreach ($answers as $answer) {
259 $xml->xmlStartTag(
'itemfeedback', array(
'ident' =>
"response_{$answer->getPosition()}",
'view' =>
'All'));
260 $xml->xmlStartTag(
'flow_mat');
262 $this->
object->addQTIMaterial(
$xml, $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
263 $this->object->getId(),
265 $answer->getPosition()
268 $xml->xmlEndTag(
'flow_mat');
269 $xml->xmlEndTag(
'itemfeedback');
271 if (strlen($feedback_allcorrect)) {
272 $xml->xmlStartTag(
'itemfeedback', array(
'ident' =>
'response_allcorrect',
'view' =>
'All'));
273 $xml->xmlStartTag(
'flow_mat');
275 $this->
object->addQTIMaterial(
$xml, $feedback_allcorrect);
277 $xml->xmlEndTag(
'flow_mat');
278 $xml->xmlEndTag(
'itemfeedback');
280 if (strlen($feedback_onenotcorrect)) {
281 $xml->xmlStartTag(
'itemfeedback', array(
'ident' =>
'response_onenotcorrect',
'view' =>
'All'));
282 $xml->xmlStartTag(
'flow_mat');
284 $this->
object->addQTIMaterial(
$xml, $feedback_onenotcorrect);
286 $xml->xmlEndTag(
'flow_mat');
287 $xml->xmlEndTag(
'itemfeedback');
290 $xml->xmlEndTag(
"item");
291 $xml->xmlEndTag(
"questestinterop");
294 if (!$a_include_header) {
295 $pos = strpos(
$xml,
"?>");
303 if ($this->object->isScorePartialSolutionEnabled()) {
304 return ($this->object->getPoints() / 2);
312 return $this->
object->getPoints();
const KPRIM_CHOICE_QUESTION_IDENTIFIER
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
toXML($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)