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)
23 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
27 $xml->xmlStartTag(
"questestinterop");
29 "ident" =>
"il_".IL_INST_ID.
"_qst_".$this->object->getId(),
30 "title" => $this->
object->getTitle(),
31 "maxattempts" => $this->
object->getNrOfTries()
33 $xml->xmlStartTag(
"item", $attrs);
35 $xml->xmlElement(
"qticomment", NULL, $this->
object->getComment());
37 $workingtime = $this->
object->getEstimatedWorkingTime();
38 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
39 $xml->xmlElement(
"duration", NULL,
$duration);
41 $xml->xmlStartTag(
"itemmetadata");
42 $xml->xmlStartTag(
"qtimetadata");
43 $xml->xmlStartTag(
"qtimetadatafield");
44 $xml->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
45 $xml->xmlElement(
"fieldentry", NULL, $ilias->getSetting(
"ilias_version"));
46 $xml->xmlEndTag(
"qtimetadatafield");
47 $xml->xmlStartTag(
"qtimetadatafield");
48 $xml->xmlElement(
"fieldlabel", NULL,
"QUESTIONTYPE");
50 $xml->xmlEndTag(
"qtimetadatafield");
51 $xml->xmlStartTag(
"qtimetadatafield");
52 $xml->xmlElement(
"fieldlabel", NULL,
"AUTHOR");
53 $xml->xmlElement(
"fieldentry", NULL, $this->
object->getAuthor());
54 $xml->xmlEndTag(
"qtimetadatafield");
60 $xml->xmlStartTag(
"qtimetadatafield");
61 $xml->xmlElement(
"fieldlabel", NULL,
"answer_type");
62 $xml->xmlElement(
"fieldentry", NULL, $this->
object->getAnswerType());
63 $xml->xmlEndTag(
"qtimetadatafield");
65 $xml->xmlStartTag(
"qtimetadatafield");
66 $xml->xmlElement(
"fieldlabel", NULL,
"thumb_size");
67 $xml->xmlElement(
"fieldentry", NULL, $this->
object->getThumbSize());
68 $xml->xmlEndTag(
"qtimetadatafield");
70 $xml->xmlStartTag(
"qtimetadatafield");
71 $xml->xmlElement(
"fieldlabel", NULL,
"option_label_setting");
72 $xml->xmlElement(
"fieldentry", NULL, $this->
object->getOptionLabel());
73 $xml->xmlEndTag(
"qtimetadatafield");
74 $xml->xmlStartTag(
"qtimetadatafield");
75 $xml->xmlElement(
"fieldlabel", NULL,
"custom_true_option_label");
76 $xml->xmlElement(
"fieldentry", NULL, $this->
object->getCustomTrueOptionLabel());
77 $xml->xmlEndTag(
"qtimetadatafield");
78 $xml->xmlStartTag(
"qtimetadatafield");
79 $xml->xmlElement(
"fieldlabel", NULL,
"custom_false_option_label");
80 $xml->xmlElement(
"fieldentry", NULL, $this->
object->getCustomFalseOptionLabel());
81 $xml->xmlEndTag(
"qtimetadatafield");
83 $xml->xmlStartTag(
"qtimetadatafield");
84 $xml->xmlElement(
"fieldlabel", NULL,
"feedback_setting");
85 $xml->xmlElement(
"fieldentry", NULL, $this->
object->getSpecificFeedbackSetting());
86 $xml->xmlEndTag(
"qtimetadatafield");
88 $xml->xmlEndTag(
"qtimetadata");
89 $xml->xmlEndTag(
"itemmetadata");
93 "label" => $this->
object->getTitle()
95 $xml->xmlStartTag(
"presentation", $attrs);
97 $xml->xmlStartTag(
"flow");
99 $this->
object->addQTIMaterial($xml, $this->
object->getQuestion());
103 "rcardinality" =>
"Multiple" 105 $xml->xmlStartTag(
"response_lid", $attrs);
106 $solution = $this->
object->getSuggestedSolution(0);
107 if (count($solution))
109 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
111 $xml->xmlStartTag(
"material");
112 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
113 if (strcmp($matches[1],
"") != 0)
115 $intlink = $solution[
"internal_link"];
118 "label" =>
"suggested_solution" 120 $xml->xmlElement(
"mattext", $attrs, $intlink);
121 $xml->xmlEndTag(
"material");
126 if ($this->
object->isShuffleAnswersEnabled())
138 $xml->xmlStartTag(
"render_choice", $attrs);
141 $answers =& $this->
object->getAnswers();
142 $akeys = array_keys($answers);
143 foreach ($akeys as $index)
145 $answer = $this->
object->getAnswer($index);
147 $xml->xmlStartTag(
'response_label',
array(
'ident' => $answer->getPosition()));
149 if (strlen($answer->getImageFile()))
151 $this->
object->addQTIMaterial($xml, $answer->getAnswertext(), FALSE, FALSE);
152 $imagetype =
"image/jpeg";
153 if (preg_match(
"/.*\.(png|gif)$/", $answer->getImageFile(), $matches))
155 $imagetype =
"image/" . $matches[1];
157 if ($force_image_references)
160 "imagtype" => $imagetype,
161 "label" => $answer->getImageFile(),
162 "uri" => $answer->getImageWebPath()
164 $xml->xmlElement(
"matimage", $attrs);
168 $imagepath = $answer->getImageFsPath();
169 $fh = @fopen($imagepath,
"rb");
172 $imagefile = fread(
$fh, filesize($imagepath));
174 $base64 = base64_encode($imagefile);
176 "imagtype" => $imagetype,
177 "label" => $answer->getImageFile(),
178 "embedded" =>
"base64" 180 $xml->xmlElement(
"matimage", $attrs, $base64, FALSE, FALSE);
183 $xml->xmlEndTag(
"material");
187 $this->
object->addQTIMaterial($xml, $answer->getAnswertext());
189 $xml->xmlEndTag(
"response_label");
191 $xml->xmlEndTag(
"render_choice");
192 $xml->xmlEndTag(
"response_lid");
193 $xml->xmlEndTag(
"flow");
194 $xml->xmlEndTag(
"presentation");
198 $xml->xmlStartTag(
'resprocessing');
200 $xml->xmlStartTag(
'outcomes');
201 $xml->xmlElement(
'decvar',
array(
202 'varname' =>
'SCORE',
'vartype' =>
'Decimal',
'defaultval' =>
'0',
205 $xml->xmlEndTag(
'outcomes');
208 foreach ($answers as $answer)
210 $xml->xmlStartTag(
'respcondition',
array(
'continue' =>
'Yes'));
212 $xml->xmlStartTag(
'conditionvar');
213 $xml->xmlElement(
'varequal',
array(
'respident' => $answer->getPosition()), $answer->getCorrectness());
214 $xml->xmlEndTag(
'conditionvar');
216 $xml->xmlElement(
'displayfeedback',
array(
217 'feedbacktype' =>
'Response',
'linkrefid' =>
"response_{$answer->getPosition()}" 220 $xml->xmlEndTag(
'respcondition');
223 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
224 $this->
object->getId(), true
227 $xml->xmlStartTag(
'respcondition',
array(
'continue' =>
'Yes'));
229 $xml->xmlStartTag(
'conditionvar');
230 $xml->xmlStartTag(
'and');
231 foreach ($answers as $answer)
233 $xml->xmlElement(
'varequal',
array(
'respident' => $answer->getPosition()), $answer->getCorrectness());
235 $xml->xmlEndTag(
'and');
236 $xml->xmlEndTag(
'conditionvar');
238 $xml->xmlElement(
'setvar',
array(
'action' =>
'Add'), $this->
object->getPoints());
240 if( strlen($feedback_allcorrect) )
242 $xml->xmlElement(
'displayfeedback',
array(
'feedbacktype' =>
'Response',
'linkrefid' =>
'response_allcorrect'));
245 $xml->xmlEndTag(
'respcondition');
247 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
248 $this->
object->getId(), false
251 $xml->xmlStartTag(
'respcondition',
array(
'continue' =>
'Yes'));
253 $xml->xmlStartTag(
'conditionvar');
254 $xml->xmlStartTag(
'or');
255 foreach ($answers as $answer)
257 $xml->xmlStartTag(
'not');
258 $xml->xmlElement(
'varequal',
array(
'respident' => $answer->getPosition()), $answer->getCorrectness());
259 $xml->xmlEndTag(
'not');
261 $xml->xmlEndTag(
'or');
262 $xml->xmlEndTag(
'conditionvar');
264 $xml->xmlElement(
'setvar',
array(
'action' =>
'Add'), 0);
266 if (strlen($feedback_onenotcorrect))
268 $xml->xmlElement(
'displayfeedback',
array(
'feedbacktype' =>
'Response',
'linkrefid' =>
'response_onenotcorrect'));
271 $xml->xmlEndTag(
'respcondition');
273 $xml->xmlEndTag(
'resprocessing');
275 foreach ($answers as $answer)
277 $xml->xmlStartTag(
'itemfeedback',
array(
'ident' =>
"response_{$answer->getPosition()}",
'view' =>
'All'));
278 $xml->xmlStartTag(
'flow_mat');
280 $this->
object->addQTIMaterial($xml, $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
281 $this->object->getId(), $answer->getPosition()
284 $xml->xmlEndTag(
'flow_mat');
285 $xml->xmlEndTag(
'itemfeedback');
287 if (strlen($feedback_allcorrect))
289 $xml->xmlStartTag(
'itemfeedback',
array(
'ident' =>
'response_allcorrect',
'view' =>
'All'));
290 $xml->xmlStartTag(
'flow_mat');
292 $this->
object->addQTIMaterial($xml, $feedback_allcorrect);
294 $xml->xmlEndTag(
'flow_mat');
295 $xml->xmlEndTag(
'itemfeedback');
297 if (strlen($feedback_onenotcorrect))
299 $xml->xmlStartTag(
'itemfeedback',
array(
'ident' =>
'response_onenotcorrect',
'view' =>
'All'));
300 $xml->xmlStartTag(
'flow_mat');
302 $this->
object->addQTIMaterial($xml, $feedback_onenotcorrect);
304 $xml->xmlEndTag(
'flow_mat');
305 $xml->xmlEndTag(
'itemfeedback');
308 $xml->xmlEndTag(
"item");
309 $xml->xmlEndTag(
"questestinterop");
311 $xml = $xml->xmlDumpMem(FALSE);
312 if (!$a_include_header)
314 $pos = strpos($xml,
"?>");
315 $xml = substr($xml, $pos + 2);
322 if( $this->
object->isScorePartialSolutionEnabled() )
324 return ( $this->
object->getPoints() / 2 );
332 return $this->
object->getPoints();
const KPRIM_CHOICE_QUESTION_IDENTIFIER
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
xmlHeader()
Writes xml header public.
Create styles array
The data for the language used.
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)
Create new PHPExcel object
obj_idprivate