ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
assImagemapQuestionExport Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assImagemapQuestionExport:
+ Collaboration diagram for assImagemapQuestionExport:

Public Member Functions

 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation. More...
 
- Public Member Functions inherited from assQuestionExport
 __construct ($a_object)
 assQuestionExport constructor More...
 
 exportFeedbackOnly ($a_xml_writer)
 
 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation. More...
 
 addQTIMaterial (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
 

Additional Inherited Members

- Data Fields inherited from assQuestionExport
 $object
 
- Protected Member Functions inherited from assQuestionExport
 addAnswerSpecificFeedback (ilXmlWriter $a_xml_writer, $answers)
 
 addGenericFeedback (ilXmlWriter $a_xml_writer)
 
 addQtiMetaDataField (ilXmlWriter $a_xml_writer, $fieldLabel, $fieldValue)
 adds a qti meta data field with given name and value to the passed xml writer (xml writer must be in context of opened "qtimetadata" tag) More...
 
 addAdditionalContentEditingModeInformation (ilXmlWriter $a_xml_writer)
 adds a qti meta data field for ilias specific information of "additional content editing mode" (xml writer must be in context of opened "qtimetadata" tag) More...
 
 addGeneralMetadata (ilXmlWriter $xmlwriter)
 
 addSuggestedSolution (ilXmlWriter $writer)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class for imagemap question exports

assImagemapQuestionExport is a class for imagemap question exports

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$ \
Deprecated:
Use normalized question export instead

Definition at line 30 of file class.assImagemapQuestionExport.php.

Member Function Documentation

◆ toXML()

assImagemapQuestionExport::toXML (   $a_include_header = true,
  $a_include_binary = true,
  $a_shuffle = false,
  $test_output = false,
  $force_image_references = false 
)

Returns a QTI xml representation of the question Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation.

Returns
string The QTI xml representation of the question @access public

Reimplemented from assQuestionExport.

Definition at line 39 of file class.assImagemapQuestionExport.php.

39 : string
40 {
41 global $DIC;
42 $ilias = $DIC['ilias'];
43
44 $a_xml_writer = new ilXmlWriter();
45 // set xml header
46 $a_xml_writer->xmlHeader();
47 $a_xml_writer->xmlStartTag("questestinterop");
48 $attrs = [
49 "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
50 "title" => $this->object->getTitle(),
51 "maxattempts" => $this->object->getNrOfTries()
52 ];
53 $a_xml_writer->xmlStartTag("item", $attrs);
54 // add question description
55 $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
56 $a_xml_writer->xmlStartTag("itemmetadata");
57 $a_xml_writer->xmlStartTag("qtimetadata");
58 $a_xml_writer->xmlStartTag("qtimetadatafield");
59 $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
60 $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
61 $a_xml_writer->xmlEndTag("qtimetadatafield");
62 $a_xml_writer->xmlStartTag("qtimetadatafield");
63 $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
64 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getQuestionType());
65 $a_xml_writer->xmlEndTag("qtimetadatafield");
66 $a_xml_writer->xmlStartTag("qtimetadatafield");
67 $a_xml_writer->xmlElement("fieldlabel", null, "IS_MULTIPLE_CHOICE");
68 $a_xml_writer->xmlElement("fieldentry", null, ($this->object->getIsMultipleChoice()) ? "1" : "0");
69 $a_xml_writer->xmlEndTag("qtimetadatafield");
70 $a_xml_writer->xmlStartTag("qtimetadatafield");
71 $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
72 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getAuthor());
73 $a_xml_writer->xmlEndTag("qtimetadatafield");
74
75 // additional content editing information
77 $this->addGeneralMetadata($a_xml_writer);
78
79 $a_xml_writer->xmlEndTag("qtimetadata");
80 $a_xml_writer->xmlEndTag("itemmetadata");
81
82 // PART I: qti presentation
83 $attrs = [
84 "label" => $this->object->getTitle()
85 ];
86 $a_xml_writer->xmlStartTag("presentation", $attrs);
87 // add flow to presentation
88 $a_xml_writer->xmlStartTag("flow");
89 // add material with question text to presentation
90 $this->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
91 // add answers to presentation
92 $attrs = [
93 "ident" => "IM",
94 "rcardinality" => "Single"
95 ];
96 $a_xml_writer->xmlStartTag("response_xy", $attrs);
97 $a_xml_writer = $this->addSuggestedSolution($a_xml_writer);
98 $a_xml_writer->xmlStartTag("render_hotspot");
99 $a_xml_writer->xmlStartTag("material");
100 $imagetype = "image/jpeg";
101 if (preg_match("/.*\.(png|gif)$/i", $this->object->getImageFilename(), $matches)) {
102 $imagetype = "image/" . strtolower($matches[1]);
103 }
104 $attrs = [
105 "imagtype" => $imagetype,
106 "label" => $this->object->getImageFilename()
107 ];
108 if ($a_include_binary) {
109 if ($force_image_references) {
110 $attrs["uri"] = $this->object->getImagePathWeb() . $this->object->getImageFilename();
111 $a_xml_writer->xmlElement("matimage", $attrs);
112 } else {
113 $attrs["embedded"] = "base64";
114 $imagepath = $this->object->getImagePath() . $this->object->getImageFilename();
115 $fh = fopen($imagepath, "rb");
116 if ($fh == false) {
117 global $DIC;
118 $ilErr = $DIC['ilErr'];
119 $ilErr->raiseError($GLOBALS['DIC']['lng']->txt("error_open_image_file"), $ilErr->MESSAGE);
120 }
121 $imagefile = fread($fh, filesize($imagepath));
122 fclose($fh);
123 $base64 = base64_encode($imagefile);
124 $a_xml_writer->xmlElement("matimage", $attrs, $base64, false, false);
125 }
126 } else {
127 $a_xml_writer->xmlElement("matimage", $attrs);
128 }
129 $a_xml_writer->xmlEndTag("material");
130
131 // add answers
132 foreach ($this->object->getAnswers() as $index => $answer) {
133 $rared = "";
134 switch ($answer->getArea()) {
135 case "rect":
136 $rarea = "Rectangle";
137 break;
138 case "circle":
139 $rarea = "Ellipse";
140 break;
141 case "poly":
142 $rarea = "Bounded";
143 break;
144 }
145 $attrs = [
146 "ident" => $index,
147 "rarea" => $rarea
148 ];
149 $a_xml_writer->xmlStartTag("response_label", $attrs);
150 $a_xml_writer->xmlData($answer->getCoords());
151 $a_xml_writer->xmlStartTag("material");
152 $a_xml_writer->xmlElement("mattext", null, $answer->getAnswertext());
153 $a_xml_writer->xmlEndTag("material");
154 $a_xml_writer->xmlEndTag("response_label");
155 }
156 $a_xml_writer->xmlEndTag("render_hotspot");
157 $a_xml_writer->xmlEndTag("response_xy");
158 $a_xml_writer->xmlEndTag("flow");
159 $a_xml_writer->xmlEndTag("presentation");
160
161 // PART II: qti resprocessing
162 $a_xml_writer->xmlStartTag("resprocessing");
163 $a_xml_writer->xmlStartTag("outcomes");
164 $a_xml_writer->xmlStartTag("decvar");
165 $a_xml_writer->xmlEndTag("decvar");
166 $a_xml_writer->xmlEndTag("outcomes");
167 // add response conditions
168 foreach ($this->object->getAnswers() as $index => $answer) {
169 $attrs = [
170 "continue" => "Yes"
171 ];
172 $a_xml_writer->xmlStartTag("respcondition", $attrs);
173 // qti conditionvar
174 $a_xml_writer->xmlStartTag("conditionvar");
175 if (!$answer->isStateSet()) {
176 $a_xml_writer->xmlStartTag("not");
177 }
178 $areatype = "";
179 switch ($answer->getArea()) {
180 case "rect":
181 $areatype = "Rectangle";
182 break;
183 case "circle":
184 $areatype = "Ellipse";
185 break;
186 case "poly":
187 $areatype = "Bounded";
188 break;
189 }
190 $attrs = [
191 "respident" => "IM",
192 "areatype" => $areatype
193 ];
194 $a_xml_writer->xmlElement("varequal", $attrs, $answer->getCoords());
195 if (!$answer->isStateSet()) {
196 $a_xml_writer->xmlEndTag("not");
197 }
198 $a_xml_writer->xmlEndTag("conditionvar");
199 // qti setvar
200 $attrs = [
201 "action" => "Add"
202 ];
203 $a_xml_writer->xmlElement("setvar", $attrs, $answer->getPoints());
204 $linkrefid = "response_$index";
205 $attrs = [
206 "feedbacktype" => "Response",
207 "linkrefid" => $linkrefid
208 ];
209 $a_xml_writer->xmlElement("displayfeedback", $attrs);
210 $a_xml_writer->xmlEndTag("respcondition");
211 $attrs = [
212 "continue" => "Yes"
213 ];
214 $a_xml_writer->xmlStartTag("respcondition", $attrs);
215 // qti conditionvar
216 $a_xml_writer->xmlStartTag("conditionvar");
217 $attrs = [
218 "respident" => "IM"
219 ];
220 $a_xml_writer->xmlStartTag("not");
221 $a_xml_writer->xmlElement("varequal", $attrs, $answer->getCoords());
222 $a_xml_writer->xmlEndTag("not");
223 $a_xml_writer->xmlEndTag("conditionvar");
224 // qti setvar
225 $attrs = [
226 "action" => "Add"
227 ];
228 $a_xml_writer->xmlElement("setvar", $attrs, $answer->getPointsUnchecked());
229 $a_xml_writer->xmlEndTag("respcondition");
230 }
231
232 $answers = $this->object->getAnswers();
233 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
234 $this->object->getId(),
235 true
236 );
237 if (strlen($feedback_allcorrect) && count($answers) > 0) {
238 $attrs = [
239 "continue" => "Yes"
240 ];
241 $a_xml_writer->xmlStartTag("respcondition", $attrs);
242 // qti conditionvar
243 $a_xml_writer->xmlStartTag("conditionvar");
244 if (!$this->object->getIsMultipleChoice()) {
245 $bestindex = 0;
246 $maxpoints = 0;
247 foreach ($answers as $index => $answer) {
248 if ($answer->getPoints() > $maxpoints) {
249 $maxpoints = $answer->getPoints();
250 $bestindex = $index;
251 }
252 }
253
254 $areatype = "";
255 $answer = $answers[$bestindex];
256 switch ($answer->getArea()) {
257 case "rect":
258 $areatype = "Rectangle";
259 break;
260 case "circle":
261 $areatype = "Ellipse";
262 break;
263 case "poly":
264 $areatype = "Bounded";
265 break;
266 }
267 $attrs = [
268 "respident" => "IM",
269 "areatype" => $areatype
270 ];
271 $a_xml_writer->xmlElement("varinside", $attrs, $answer->getCoords());
272 } else {
273 foreach ($answers as $index => $answer) {
274 if ($answer->getPoints() < $answer->getPointsUnchecked()) {
275 $a_xml_writer->xmlStartTag("not");
276 }
277 switch ($answer->getArea()) {
278 case "rect":
279 $areatype = "Rectangle";
280 break;
281 case "circle":
282 $areatype = "Ellipse";
283 break;
284 case "poly":
285 $areatype = "Bounded";
286 break;
287 }
288 $attrs = [
289 "respident" => "IM",
290 "areatype" => $areatype
291 ];
292 $a_xml_writer->xmlElement("varequal", $attrs, $index);
293 if ($answer->getPoints() < $answer->getPointsUnchecked()) {
294 $a_xml_writer->xmlEndTag("not");
295 }
296 }
297 }
298
299 $a_xml_writer->xmlEndTag("conditionvar");
300 // qti displayfeedback
301 $attrs = [
302 "feedbacktype" => "Response",
303 "linkrefid" => "response_allcorrect"
304 ];
305 $a_xml_writer->xmlElement("displayfeedback", $attrs);
306 $a_xml_writer->xmlEndTag("respcondition");
307 }
308
309 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
310 $this->object->getId(),
311 false
312 );
313 if (strlen($feedback_onenotcorrect) && count($answers) > 0) {
314 $attrs = [
315 "continue" => "Yes"
316 ];
317 $a_xml_writer->xmlStartTag("respcondition", $attrs);
318 // qti conditionvar
319 $a_xml_writer->xmlStartTag("conditionvar");
320 if (!$this->object->getIsMultipleChoice()) {
321 $bestindex = 0;
322 $maxpoints = 0;
323 foreach ($answers as $index => $answer) {
324 if ($answer->getPoints() > $maxpoints) {
325 $maxpoints = $answer->getPoints();
326 $bestindex = $index;
327 }
328 }
329 $attrs = [
330 "respident" => "IM"
331 ];
332 $a_xml_writer->xmlStartTag("not");
333
334 $areatype = "";
335 $answer = $answers[$bestindex];
336 switch ($answer->getArea()) {
337 case "rect":
338 $areatype = "Rectangle";
339 break;
340 case "circle":
341 $areatype = "Ellipse";
342 break;
343 case "poly":
344 $areatype = "Bounded";
345 break;
346 }
347 $attrs = [
348 "respident" => "IM",
349 "areatype" => $areatype
350 ];
351 $a_xml_writer->xmlElement("varinside", $attrs, $answer->getCoords());
352
353 $a_xml_writer->xmlEndTag("not");
354 } else {
355 foreach ($answers as $index => $answer) {
356 if ($index > 0) {
357 $a_xml_writer->xmlStartTag("or");
358 }
359 if ($answer->getPoints() >= $answer->getPointsUnchecked()) {
360 $a_xml_writer->xmlStartTag("not");
361 }
362 switch ($answer->getArea()) {
363 case "rect":
364 $areatype = "Rectangle";
365 break;
366 case "circle":
367 $areatype = "Ellipse";
368 break;
369 case "poly":
370 $areatype = "Bounded";
371 break;
372 }
373 $attrs = [
374 "respident" => "IM",
375 "areatype" => $areatype
376 ];
377 $a_xml_writer->xmlElement("varequal", $attrs, $index);
378 if ($answer->getPoints() >= $answer->getPointsUnchecked()) {
379 $a_xml_writer->xmlEndTag("not");
380 }
381 if ($index > 0) {
382 $a_xml_writer->xmlEndTag("or");
383 }
384 }
385 }
386 $a_xml_writer->xmlEndTag("conditionvar");
387 // qti displayfeedback
388 $attrs = [
389 "feedbacktype" => "Response",
390 "linkrefid" => "response_onenotcorrect"
391 ];
392 $a_xml_writer->xmlElement("displayfeedback", $attrs);
393 $a_xml_writer->xmlEndTag("respcondition");
394 }
395
396 $a_xml_writer->xmlEndTag("resprocessing");
397
398 // PART III: qti itemfeedback
399 foreach ($this->object->getAnswers() as $index => $answer) {
400 $linkrefid = "response_$index";
401 $attrs = [
402 "ident" => $linkrefid,
403 "view" => "All"
404 ];
405 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
406 // qti flow_mat
407 $a_xml_writer->xmlStartTag("flow_mat");
408 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
409 $this->object->getId(),
410 0,
411 $index
412 );
413 $this->addQTIMaterial($a_xml_writer, $fb);
414 $a_xml_writer->xmlEndTag("flow_mat");
415 $a_xml_writer->xmlEndTag("itemfeedback");
416 }
417 if (strlen($feedback_allcorrect)) {
418 $attrs = [
419 "ident" => "response_allcorrect",
420 "view" => "All"
421 ];
422 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
423 // qti flow_mat
424 $a_xml_writer->xmlStartTag("flow_mat");
425 $this->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
426 $a_xml_writer->xmlEndTag("flow_mat");
427 $a_xml_writer->xmlEndTag("itemfeedback");
428 }
429 if (strlen($feedback_onenotcorrect)) {
430 $attrs = [
431 "ident" => "response_onenotcorrect",
432 "view" => "All"
433 ];
434 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
435 // qti flow_mat
436 $a_xml_writer->xmlStartTag("flow_mat");
437 $this->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
438 $a_xml_writer->xmlEndTag("flow_mat");
439 $a_xml_writer->xmlEndTag("itemfeedback");
440 }
441
442 $a_xml_writer->xmlEndTag("item");
443 $a_xml_writer->xmlEndTag("questestinterop");
444
445 $xml = $a_xml_writer->xmlDumpMem(false);
446 if (!$a_include_header) {
447 $pos = strpos($xml, "?>");
448 $xml = substr($xml, $pos + 2);
449 }
450 return $xml;
451 }
addGeneralMetadata(ilXmlWriter $xmlwriter)
addQTIMaterial(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
addSuggestedSolution(ilXmlWriter $writer)
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:66

References $DIC, $GLOBALS, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), assQuestionExport\addQTIMaterial(), assQuestionExport\addSuggestedSolution(), IL_INST_ID, and ILIAS\Repository\object().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: