ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
assOrderingQuestionExport Class Reference

Class for ordering question exports. 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. 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. More...
 

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)
 

Detailed Description

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 15 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

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

Reimplemented from assQuestionExport.

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

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

References $duration, $fh, $ilDB, $ilUser, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, OQ_PICTURES, OQ_TERMS, ORDERING_QUESTION_IDENTIFIER, OUTPUT_JAVASCRIPT, sprintf, and ilXmlWriter\xmlHeader().

+ Here is the call graph for this function:

Field Documentation

◆ $object

assOrderingQuestionExport::$object

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


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