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)) {
108 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
109 $xml->xmlStartTag(
"material");
110 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
111 if (strcmp($matches[1],
"") != 0) {
112 $intlink = $solution[
"internal_link"];
115 "label" =>
"suggested_solution" 117 $xml->xmlElement(
"mattext", $attrs, $intlink);
118 $xml->xmlEndTag(
"material");
123 if ($this->
object->isShuffleAnswersEnabled()) {
132 $xml->xmlStartTag(
"render_choice", $attrs);
135 $answers =&$this->
object->getAnswers();
136 $akeys = array_keys($answers);
137 foreach ($akeys as
$index) {
138 $answer = $this->
object->getAnswer($index);
140 $xml->xmlStartTag(
'response_label',
array(
'ident' => $answer->getPosition()));
142 if (strlen($answer->getImageFile())) {
143 $this->
object->addQTIMaterial(
$xml, $answer->getAnswertext(),
false,
false);
144 $imagetype =
"image/jpeg";
145 if (preg_match(
"/.*\.(png|gif)$/", $answer->getImageFile(), $matches)) {
146 $imagetype =
"image/" . $matches[1];
148 if ($force_image_references) {
150 "imagtype" => $imagetype,
151 "label" => $answer->getImageFile(),
152 "uri" => $answer->getImageWebPath()
154 $xml->xmlElement(
"matimage", $attrs);
156 $imagepath = $answer->getImageFsPath();
157 $fh = @fopen($imagepath,
"rb");
159 $imagefile = fread(
$fh, filesize($imagepath));
161 $base64 = base64_encode($imagefile);
163 "imagtype" => $imagetype,
164 "label" => $answer->getImageFile(),
165 "embedded" =>
"base64" 167 $xml->xmlElement(
"matimage", $attrs, $base64,
false,
false);
170 $xml->xmlEndTag(
"material");
172 $this->
object->addQTIMaterial(
$xml, $answer->getAnswertext());
174 $xml->xmlEndTag(
"response_label");
176 $xml->xmlEndTag(
"render_choice");
177 $xml->xmlEndTag(
"response_lid");
178 $xml->xmlEndTag(
"flow");
179 $xml->xmlEndTag(
"presentation");
183 $xml->xmlStartTag(
'resprocessing');
185 $xml->xmlStartTag(
'outcomes');
187 'varname' =>
'SCORE',
'vartype' =>
'Decimal',
'defaultval' =>
'0',
190 $xml->xmlEndTag(
'outcomes');
193 foreach ($answers as $answer) {
194 $xml->xmlStartTag(
'respcondition',
array(
'continue' =>
'Yes'));
196 $xml->xmlStartTag(
'conditionvar');
197 $xml->xmlElement(
'varequal',
array(
'respident' => $answer->getPosition()), $answer->getCorrectness());
198 $xml->xmlEndTag(
'conditionvar');
200 $xml->xmlElement(
'displayfeedback',
array(
201 'feedbacktype' =>
'Response',
'linkrefid' =>
"response_{$answer->getPosition()}" 204 $xml->xmlEndTag(
'respcondition');
207 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
212 $xml->xmlStartTag(
'respcondition',
array(
'continue' =>
'Yes'));
214 $xml->xmlStartTag(
'conditionvar');
215 $xml->xmlStartTag(
'and');
216 foreach ($answers as $answer) {
217 $xml->xmlElement(
'varequal',
array(
'respident' => $answer->getPosition()), $answer->getCorrectness());
219 $xml->xmlEndTag(
'and');
220 $xml->xmlEndTag(
'conditionvar');
222 $xml->xmlElement(
'setvar',
array(
'action' =>
'Add'), $this->
object->getPoints());
224 if (strlen($feedback_allcorrect)) {
225 $xml->xmlElement(
'displayfeedback',
array(
'feedbacktype' =>
'Response',
'linkrefid' =>
'response_allcorrect'));
228 $xml->xmlEndTag(
'respcondition');
230 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
235 $xml->xmlStartTag(
'respcondition',
array(
'continue' =>
'Yes'));
237 $xml->xmlStartTag(
'conditionvar');
238 $xml->xmlStartTag(
'or');
239 foreach ($answers as $answer) {
240 $xml->xmlStartTag(
'not');
241 $xml->xmlElement(
'varequal',
array(
'respident' => $answer->getPosition()), $answer->getCorrectness());
242 $xml->xmlEndTag(
'not');
244 $xml->xmlEndTag(
'or');
245 $xml->xmlEndTag(
'conditionvar');
247 $xml->xmlElement(
'setvar',
array(
'action' =>
'Add'), 0);
249 if (strlen($feedback_onenotcorrect)) {
250 $xml->xmlElement(
'displayfeedback',
array(
'feedbacktype' =>
'Response',
'linkrefid' =>
'response_onenotcorrect'));
253 $xml->xmlEndTag(
'respcondition');
255 $xml->xmlEndTag(
'resprocessing');
257 foreach ($answers as $answer) {
258 $xml->xmlStartTag(
'itemfeedback',
array(
'ident' =>
"response_{$answer->getPosition()}",
'view' =>
'All'));
259 $xml->xmlStartTag(
'flow_mat');
261 $this->
object->addQTIMaterial(
$xml, $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
262 $this->object->getId(),
263 $answer->getPosition()
266 $xml->xmlEndTag(
'flow_mat');
267 $xml->xmlEndTag(
'itemfeedback');
269 if (strlen($feedback_allcorrect)) {
270 $xml->xmlStartTag(
'itemfeedback',
array(
'ident' =>
'response_allcorrect',
'view' =>
'All'));
271 $xml->xmlStartTag(
'flow_mat');
273 $this->
object->addQTIMaterial(
$xml, $feedback_allcorrect);
275 $xml->xmlEndTag(
'flow_mat');
276 $xml->xmlEndTag(
'itemfeedback');
278 if (strlen($feedback_onenotcorrect)) {
279 $xml->xmlStartTag(
'itemfeedback',
array(
'ident' =>
'response_onenotcorrect',
'view' =>
'All'));
280 $xml->xmlStartTag(
'flow_mat');
282 $this->
object->addQTIMaterial(
$xml, $feedback_onenotcorrect);
284 $xml->xmlEndTag(
'flow_mat');
285 $xml->xmlEndTag(
'itemfeedback');
288 $xml->xmlEndTag(
"item");
289 $xml->xmlEndTag(
"questestinterop");
292 if (!$a_include_header) {
293 $pos = strpos(
$xml,
"?>");
301 if ($this->
object->isScorePartialSolutionEnabled()) {
302 return ($this->
object->getPoints() / 2);
310 return $this->
object->getPoints();
const KPRIM_CHOICE_QUESTION_IDENTIFIER
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
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