ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
assOrderingQuestionExport 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 assOrderingQuestionExport:
+ Collaboration diagram for assOrderingQuestionExport:

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)
 

Data Fields

 $object
 
- Data Fields inherited from assQuestionExport
 $object
 

Additional Inherited Members

- 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 ordering question exports

assOrderingQuestionExport is a class for ordering 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$ \

Definition at line 28 of file class.assOrderingQuestionExport.php.

Member Function Documentation

◆ toXML()

assOrderingQuestionExport::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.

Reimplemented from assQuestionExport.

Definition at line 40 of file class.assOrderingQuestionExport.php.

40 : string
41 {
42 global $DIC;
43 $ilias = $DIC['ilias'];
44
45 $a_xml_writer = new ilXmlWriter();
46 // set xml header
47 $a_xml_writer->xmlHeader();
48 $a_xml_writer->xmlStartTag("questestinterop");
49 $attrs = [
50 "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
51 "title" => $this->object->getTitle(),
52 "maxattempts" => $this->object->getNrOfTries()
53 ];
54 $a_xml_writer->xmlStartTag("item", $attrs);
55 // add question description
56 $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
57 $a_xml_writer->xmlStartTag("itemmetadata");
58 $a_xml_writer->xmlStartTag("qtimetadata");
59 $a_xml_writer->xmlStartTag("qtimetadatafield");
60 $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
61 $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
62 $a_xml_writer->xmlEndTag("qtimetadatafield");
63 $a_xml_writer->xmlStartTag("qtimetadatafield");
64 $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
65 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getQuestionType());
66 $a_xml_writer->xmlEndTag("qtimetadatafield");
67 $a_xml_writer->xmlStartTag("qtimetadatafield");
68 $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
69 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getAuthor());
70 $a_xml_writer->xmlEndTag("qtimetadatafield");
71
72 // additional content editing information
74 $this->addGeneralMetadata($a_xml_writer);
75
76 $a_xml_writer->xmlStartTag("qtimetadatafield");
77 $a_xml_writer->xmlElement("fieldlabel", null, "thumb_geometry");
78 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getThumbSize());
79 $a_xml_writer->xmlEndTag("qtimetadatafield");
80 $a_xml_writer->xmlStartTag("qtimetadatafield");
81 $a_xml_writer->xmlElement("fieldlabel", null, "element_height");
82 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getElementHeight());
83 $a_xml_writer->xmlEndTag("qtimetadatafield");
84 $a_xml_writer->xmlStartTag("qtimetadatafield");
85 $a_xml_writer->xmlElement("fieldlabel", null, "points");
86 $a_xml_writer->xmlElement("fieldentry", null, $this->object->getPoints());
87 $a_xml_writer->xmlEndTag("qtimetadatafield");
88 $a_xml_writer->xmlEndTag("qtimetadata");
89 $a_xml_writer->xmlEndTag("itemmetadata");
90
91 // PART I: qti presentation
92 $attrs = [
93 "label" => $this->object->getTitle()
94 ];
95 $a_xml_writer->xmlStartTag("presentation", $attrs);
96 // add flow to presentation
97 $a_xml_writer->xmlStartTag("flow");
98 // add material with question text to presentation
99 $this->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
100 // add answers to presentation
101 $attrs = [];
102
103 if ($this->object->getOrderingType() == assOrderingQuestion::OQ_PICTURES) {
104 $ordering_type = 'OQP';
105 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_NESTED_PICTURES) {
106 $ordering_type = 'OQNP';
107 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_NESTED_TERMS) {
108 $ordering_type = 'OQNT';
109 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_TERMS) {
110 $ordering_type = 'OQT';
111 }
112
113 $attrs = [
114 "ident" => $ordering_type,
115 "rcardinality" => "Ordered"
116 ];
117
118 $attrs["output"] = "javascript";
119 $a_xml_writer->xmlStartTag("response_lid", $attrs);
120 $a_xml_writer = $this->addSuggestedSolution($a_xml_writer);
121 // shuffle output
122 $attrs = [];
123 if ($this->object->getShuffle()) {
124 $attrs = [
125 "shuffle" => "Yes"
126 ];
127 } else {
128 $attrs = [
129 "shuffle" => "No"
130 ];
131 }
132 $a_xml_writer->xmlStartTag("render_choice", $attrs);
133
134 // add answers
135 foreach ($this->object->getOrderingElementList() as $element) {
136 $attrs = [
137 'ident' => $element->getExportIdent()
138 ];
139 $a_xml_writer->xmlStartTag("response_label", $attrs);
140 if ($this->object->getOrderingType() == assOrderingQuestion::OQ_PICTURES
141 || $this->object->getOrderingType() == assOrderingQuestion::OQ_NESTED_PICTURES) {
142 $imagetype = "image/jpeg";
143
144 $a_xml_writer->xmlStartTag("material");
145 if ($force_image_references) {
146 $attrs = [
147 "imagtype" => $imagetype,
148 "label" => $element->getContent(),
149 "uri" => $this->object->getImagePathWeb() . $element->getContent()
150 ];
151 $a_xml_writer->xmlElement("matimage", $attrs);
152 } else {
153 $imagepath = $this->object->getImagePath() . $element->getContent();
154 if (file_exists($imagepath) && is_file($imagepath)) {
155 $fh = @fopen($imagepath, "rb");
156 if ($fh != false) {
157 $imagefile = fread($fh, filesize($imagepath));
158 fclose($fh);
159 $base64 = base64_encode($imagefile);
160
161 if (preg_match("/.*\.(png|gif)$/", $element->getContent(), $matches)) {
162 $imagetype = "image/" . $matches[1];
163 }
164 $attrs = [
165 "imagtype" => $imagetype,
166 "label" => $element->getContent(),
167 "embedded" => "base64"
168 ];
169 $a_xml_writer->xmlElement("matimage", $attrs, $base64, false, false);
170 }
171 }
172 }
173 $a_xml_writer->xmlEndTag("material");
174 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_TERMS
175 || $this->object->getOrderingType() == assOrderingQuestion::OQ_NESTED_TERMS) {
176 $a_xml_writer->xmlStartTag("material");
177 $this->addQTIMaterial($a_xml_writer, $element->getContent(), true, false);
178 $a_xml_writer->xmlEndTag("material");
179 $a_xml_writer->xmlStartTag("material");
180 $attrs = ["label" => "answerdepth"];
181 $a_xml_writer->xmlElement("mattext", $attrs, $element->getIndentation());
182 $a_xml_writer->xmlEndTag("material");
183 }
184 $a_xml_writer->xmlEndTag("response_label");
185 }
186 $a_xml_writer->xmlEndTag("render_choice");
187 $a_xml_writer->xmlEndTag("response_lid");
188 $a_xml_writer->xmlEndTag("flow");
189 $a_xml_writer->xmlEndTag("presentation");
190
191 // PART II: qti resprocessing
192 $a_xml_writer->xmlStartTag("resprocessing");
193 $a_xml_writer->xmlStartTag("outcomes");
194 $a_xml_writer->xmlStartTag("decvar");
195 $a_xml_writer->xmlEndTag("decvar");
196 $a_xml_writer->xmlEndTag("outcomes");
197 // add response conditions
198 foreach ($this->object->getOrderingElementList() as $element) {
199 $attrs = [
200 "continue" => "Yes"
201 ];
202 $a_xml_writer->xmlStartTag("respcondition", $attrs);
203 // qti conditionvar
204 $a_xml_writer->xmlStartTag("conditionvar");
205 $attrs = [];
206
207 if ($this->object->getOrderingType() == assOrderingQuestion::OQ_PICTURES) {
208 $ordering_type = 'OQP';
209 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_NESTED_PICTURES) {
210 $ordering_type = 'OQNP';
211 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_NESTED_TERMS) {
212 $ordering_type = 'OQNT';
213 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_TERMS) {
214 $ordering_type = 'OQT';
215 }
216
217 $attrs = ["respident" => $ordering_type];
218
219 $attrs["index"] = $element->getPosition();
220 $a_xml_writer->xmlElement("varequal", $attrs, $element->getPosition());
221 $a_xml_writer->xmlEndTag("conditionvar");
222 // qti setvar
223 $attrs = [
224 "action" => "Add"
225 ];
226 $points = $this->object->getPoints() / $this->object->getOrderingElementList()->countElements();
227 $a_xml_writer->xmlElement("setvar", $attrs, $points);
228 // qti displayfeedback
229 $attrs = [
230 "feedbacktype" => "Response",
231 "linkrefid" => "link_" . $element->getPosition()
232 ];
233 $a_xml_writer->xmlElement("displayfeedback", $attrs);
234 $a_xml_writer->xmlEndTag("respcondition");
235 }
236
237 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
238 $this->object->getId(),
239 true
240 );
241 if (strlen($feedback_allcorrect)) {
242 $attrs = [
243 "continue" => "Yes"
244 ];
245 $a_xml_writer->xmlStartTag("respcondition", $attrs);
246 // qti conditionvar
247 $a_xml_writer->xmlStartTag("conditionvar");
248
249 foreach ($this->object->getOrderingElementList() as $element) {
250 $attrs = [];
251
252 if ($this->object->getOrderingType() == assOrderingQuestion::OQ_PICTURES) {
253 $ordering_type = 'OQP';
254 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_NESTED_PICTURES) {
255 $ordering_type = 'OQNP';
256 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_NESTED_TERMS) {
257 $ordering_type = 'OQNT';
258 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_TERMS) {
259 $ordering_type = 'OQT';
260 }
261
262 $attrs = ["respident" => $ordering_type];
263
264 $attrs["index"] = $element->getPosition();
265 $a_xml_writer->xmlElement("varequal", $attrs, $element->getPosition());
266 }
267
268 $a_xml_writer->xmlEndTag("conditionvar");
269 // qti displayfeedback
270 $attrs = [
271 "feedbacktype" => "Response",
272 "linkrefid" => "response_allcorrect"
273 ];
274 $a_xml_writer->xmlElement("displayfeedback", $attrs);
275 $a_xml_writer->xmlEndTag("respcondition");
276 }
277
278 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
279 $this->object->getId(),
280 false
281 );
282 if (strlen($feedback_onenotcorrect)) {
283 $attrs = [
284 "continue" => "Yes"
285 ];
286 $a_xml_writer->xmlStartTag("respcondition", $attrs);
287 // qti conditionvar
288 $a_xml_writer->xmlStartTag("conditionvar");
289 $a_xml_writer->xmlStartTag("not");
290
291 foreach ($this->object->getOrderingElementList() as $element) {
292 $attrs = [];
293 if ($this->object->getOrderingType() == assOrderingQuestion::OQ_PICTURES) {
294 $ordering_type = 'OQP';
295 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_NESTED_PICTURES) {
296 $ordering_type = 'OQNP';
297 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_NESTED_TERMS) {
298 $ordering_type = 'OQNT';
299 } elseif ($this->object->getOrderingType() == assOrderingQuestion::OQ_TERMS) {
300 $ordering_type = 'OQT';
301 }
302
303 $attrs = ["respident" => $ordering_type];
304
305 $attrs["index"] = $element->getPosition();
306 $a_xml_writer->xmlElement("varequal", $attrs, $element->getPosition());
307 }
308
309 $a_xml_writer->xmlEndTag("not");
310 $a_xml_writer->xmlEndTag("conditionvar");
311 // qti displayfeedback
312 $attrs = [
313 "feedbacktype" => "Response",
314 "linkrefid" => "response_onenotcorrect"
315 ];
316 $a_xml_writer->xmlElement("displayfeedback", $attrs);
317 $a_xml_writer->xmlEndTag("respcondition");
318 }
319
320 $a_xml_writer->xmlEndTag("resprocessing");
321
322 // PART III: qti itemfeedback
323 foreach ($this->object->getOrderingElementList() as $element) {
324 $attrs = [
325 "ident" => "link_" . $element->getPosition(),
326 "view" => "All"
327 ];
328 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
329 // qti flow_mat
330 $a_xml_writer->xmlStartTag("flow_mat");
331 $a_xml_writer->xmlStartTag("material");
332 $a_xml_writer->xmlElement("mattext", null, $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
333 $this->object->getId(),
334 0,
335 $element->getPosition()
336 ));
337 $a_xml_writer->xmlEndTag("material");
338 $a_xml_writer->xmlEndTag("flow_mat");
339 $a_xml_writer->xmlEndTag("itemfeedback");
340 }
341
342 if (strlen($feedback_allcorrect)) {
343 $attrs = [
344 "ident" => "response_allcorrect",
345 "view" => "All"
346 ];
347 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
348 // qti flow_mat
349 $a_xml_writer->xmlStartTag("flow_mat");
350 $this->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
351 $a_xml_writer->xmlEndTag("flow_mat");
352 $a_xml_writer->xmlEndTag("itemfeedback");
353 }
354 if (strlen($feedback_onenotcorrect)) {
355 $attrs = [
356 "ident" => "response_onenotcorrect",
357 "view" => "All"
358 ];
359 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
360 // qti flow_mat
361 $a_xml_writer->xmlStartTag("flow_mat");
362 $this->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
363 $a_xml_writer->xmlEndTag("flow_mat");
364 $a_xml_writer->xmlEndTag("itemfeedback");
365 }
366
367 $a_xml_writer->xmlEndTag("item");
368 $a_xml_writer->xmlEndTag("questestinterop");
369
370 $xml = $a_xml_writer->xmlDumpMem(false);
371 if (!$a_include_header) {
372 $pos = strpos($xml, "?>");
373 $xml = substr($xml, $pos + 2);
374 }
375 return $xml;
376 }
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

References $DIC, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), assQuestionExport\addQTIMaterial(), assQuestionExport\addSuggestedSolution(), IL_INST_ID, ILIAS\Repository\object(), assOrderingQuestion\OQ_NESTED_PICTURES, assOrderingQuestion\OQ_NESTED_TERMS, assOrderingQuestion\OQ_PICTURES, and assOrderingQuestion\OQ_TERMS.

+ Here is the call graph for this function:

Field Documentation

◆ $object

assOrderingQuestionExport::$object

Definition at line 33 of file class.assOrderingQuestionExport.php.


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