ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 public

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

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

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
71  $this->addAdditionalContentEditingModeInformation($a_xml_writer);
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  } elseif ($this->object->getOrderingType() == OQ_NESTED_PICTURES) {
104  $ordering_type ='OQNP';
105  } elseif ($this->object->getOrderingType() == OQ_NESTED_TERMS) {
106  $ordering_type ='OQNT';
107  } elseif ($this->object->getOrderingType() == OQ_TERMS) {
108  $ordering_type ='OQT';
109  }
110 
111  $attrs = array(
112  "ident" => $ordering_type,
113  "rcardinality" => "Ordered"
114  );
115 
116  if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT) {
117  $attrs["output"] = "javascript";
118  }
119  $a_xml_writer->xmlStartTag("response_lid", $attrs);
120  $solution = $this->object->getSuggestedSolution(0);
121  if (count($solution)) {
122  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) {
123  $a_xml_writer->xmlStartTag("material");
124  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
125  if (strcmp($matches[1], "") != 0) {
126  $intlink = $solution["internal_link"];
127  }
128  $attrs = array(
129  "label" => "suggested_solution"
130  );
131  $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
132  $a_xml_writer->xmlEndTag("material");
133  }
134  }
135  // shuffle output
136  $attrs = array();
137  if ($this->object->getShuffle()) {
138  $attrs = array(
139  "shuffle" => "Yes"
140  );
141  } else {
142  $attrs = array(
143  "shuffle" => "No"
144  );
145  }
146  $a_xml_writer->xmlStartTag("render_choice", $attrs);
147 
148  // add answers
149  foreach ($this->object->getOrderingElementList() as $element) {
150  $attrs = array(
151  'ident' => $element->getExportIdent()
152  );
153  $a_xml_writer->xmlStartTag("response_label", $attrs);
154  if ($this->object->getOrderingType() == OQ_PICTURES
155  || $this->object->getOrderingType() == OQ_NESTED_PICTURES) {
156  $imagetype = "image/jpeg";
157 
158  $a_xml_writer->xmlStartTag("material");
159  if ($force_image_references) {
160  $attrs = array(
161  "imagtype" => $imagetype,
162  "label" => $element->getContent(),
163  "uri" => $this->object->getImagePathWeb() . $element->getContent()
164  );
165  $a_xml_writer->xmlElement("matimage", $attrs);
166  } else {
167  $imagepath = $this->object->getImagePath() . $element->getContent();
168  $fh = @fopen($imagepath, "rb");
169  if ($fh != false) {
170  $imagefile = fread($fh, filesize($imagepath));
171  fclose($fh);
172  $base64 = base64_encode($imagefile);
173 
174  if (preg_match("/.*\.(png|gif)$/", $element->getContent(), $matches)) {
175  $imagetype = "image/" . $matches[1];
176  }
177  $attrs = array(
178  "imagtype" => $imagetype,
179  "label" => $element->getContent(),
180  "embedded" => "base64"
181  );
182  $a_xml_writer->xmlElement("matimage", $attrs, $base64, false, false);
183  }
184  }
185  $a_xml_writer->xmlEndTag("material");
186  } elseif ($this->object->getOrderingType() == OQ_TERMS
187  || $this->object->getOrderingType() == OQ_NESTED_TERMS) {
188  $a_xml_writer->xmlStartTag("material");
189  $this->object->addQTIMaterial($a_xml_writer, $element->getContent(), true, false);
190  $a_xml_writer->xmlEndTag("material");
191  $a_xml_writer->xmlStartTag("material");
192  $attrs = array("label" => "answerdepth");
193  $a_xml_writer->xmlElement("mattext", $attrs, $element->getIndentation());
194  $a_xml_writer->xmlEndTag("material");
195  }
196  $a_xml_writer->xmlEndTag("response_label");
197  }
198  $a_xml_writer->xmlEndTag("render_choice");
199  $a_xml_writer->xmlEndTag("response_lid");
200  $a_xml_writer->xmlEndTag("flow");
201  $a_xml_writer->xmlEndTag("presentation");
202 
203  // PART II: qti resprocessing
204  $a_xml_writer->xmlStartTag("resprocessing");
205  $a_xml_writer->xmlStartTag("outcomes");
206  $a_xml_writer->xmlStartTag("decvar");
207  $a_xml_writer->xmlEndTag("decvar");
208  $a_xml_writer->xmlEndTag("outcomes");
209  // add response conditions
210  foreach ($this->object->getOrderingElementList() as $element) {
211  $attrs = array(
212  "continue" => "Yes"
213  );
214  $a_xml_writer->xmlStartTag("respcondition", $attrs);
215  // qti conditionvar
216  $a_xml_writer->xmlStartTag("conditionvar");
217  $attrs = array();
218 
219  if ($this->object->getOrderingType() == OQ_PICTURES) {
220  $ordering_type ='OQP';
221  } elseif ($this->object->getOrderingType() == OQ_NESTED_PICTURES) {
222  $ordering_type ='OQNP';
223  } elseif ($this->object->getOrderingType() == OQ_NESTED_TERMS) {
224  $ordering_type ='OQNT';
225  } elseif ($this->object->getOrderingType() == OQ_TERMS) {
226  $ordering_type ='OQT';
227  }
228 
229  $attrs = array("respident" => $ordering_type);
230 
231  $attrs["index"] = $element->getPosition();
232  $a_xml_writer->xmlElement("varequal", $attrs, $element->getPosition());
233  $a_xml_writer->xmlEndTag("conditionvar");
234  // qti setvar
235  $attrs = array(
236  "action" => "Add"
237  );
238  $points = $this->object->getPoints() / $this->object->getOrderingElementList()->countElements();
239  $a_xml_writer->xmlElement("setvar", $attrs, $points);
240  // qti displayfeedback
241  $attrs = array(
242  "feedbacktype" => "Response",
243  "linkrefid" => "link_" . $element->getPosition()
244  );
245  $a_xml_writer->xmlElement("displayfeedback", $attrs);
246  $a_xml_writer->xmlEndTag("respcondition");
247  }
248 
249  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
250  $this->object->getId(),
251  true
252  );
253  if (strlen($feedback_allcorrect)) {
254  $attrs = array(
255  "continue" => "Yes"
256  );
257  $a_xml_writer->xmlStartTag("respcondition", $attrs);
258  // qti conditionvar
259  $a_xml_writer->xmlStartTag("conditionvar");
260 
261  foreach ($this->object->getOrderingElementList() as $element) {
262  $attrs = array();
263 
264  if ($this->object->getOrderingType() == OQ_PICTURES) {
265  $ordering_type ='OQP';
266  } elseif ($this->object->getOrderingType() == OQ_NESTED_PICTURES) {
267  $ordering_type ='OQNP';
268  } elseif ($this->object->getOrderingType() == OQ_NESTED_TERMS) {
269  $ordering_type ='OQNT';
270  } elseif ($this->object->getOrderingType() == OQ_TERMS) {
271  $ordering_type ='OQT';
272  }
273 
274  $attrs = array("respident" => $ordering_type);
275 
276  $attrs["index"] = $element->getPosition();
277  $a_xml_writer->xmlElement("varequal", $attrs, $element->getPosition());
278  }
279 
280  $a_xml_writer->xmlEndTag("conditionvar");
281  // qti displayfeedback
282  $attrs = array(
283  "feedbacktype" => "Response",
284  "linkrefid" => "response_allcorrect"
285  );
286  $a_xml_writer->xmlElement("displayfeedback", $attrs);
287  $a_xml_writer->xmlEndTag("respcondition");
288  }
289 
290  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
291  $this->object->getId(),
292  false
293  );
294  if (strlen($feedback_onenotcorrect)) {
295  $attrs = array(
296  "continue" => "Yes"
297  );
298  $a_xml_writer->xmlStartTag("respcondition", $attrs);
299  // qti conditionvar
300  $a_xml_writer->xmlStartTag("conditionvar");
301  $a_xml_writer->xmlStartTag("not");
302 
303  foreach ($this->object->getOrderingElementList() as $element) {
304  $attrs = array();
305  if ($this->object->getOrderingType() == OQ_PICTURES) {
306  $ordering_type ='OQP';
307  } elseif ($this->object->getOrderingType() == OQ_NESTED_PICTURES) {
308  $ordering_type ='OQNP';
309  } elseif ($this->object->getOrderingType() == OQ_NESTED_TERMS) {
310  $ordering_type ='OQNT';
311  } elseif ($this->object->getOrderingType() == OQ_TERMS) {
312  $ordering_type ='OQT';
313  }
314 
315  $attrs = array("respident" => $ordering_type);
316 
317  $attrs["index"] = $element->getPosition();
318  $a_xml_writer->xmlElement("varequal", $attrs, $element->getPosition());
319  }
320 
321  $a_xml_writer->xmlEndTag("not");
322  $a_xml_writer->xmlEndTag("conditionvar");
323  // qti displayfeedback
324  $attrs = array(
325  "feedbacktype" => "Response",
326  "linkrefid" => "response_onenotcorrect"
327  );
328  $a_xml_writer->xmlElement("displayfeedback", $attrs);
329  $a_xml_writer->xmlEndTag("respcondition");
330  }
331 
332  $a_xml_writer->xmlEndTag("resprocessing");
333 
334  // PART III: qti itemfeedback
335  foreach ($this->object->getOrderingElementList() as $element) {
336  $attrs = array(
337  "ident" => "link_" . $element->getPosition(),
338  "view" => "All"
339  );
340  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
341  // qti flow_mat
342  $a_xml_writer->xmlStartTag("flow_mat");
343  $a_xml_writer->xmlStartTag("material");
344  $a_xml_writer->xmlElement("mattext", null, $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
345  $this->object->getId(),
346  $element->getPosition()
347  ));
348  $a_xml_writer->xmlEndTag("material");
349  $a_xml_writer->xmlEndTag("flow_mat");
350  $a_xml_writer->xmlEndTag("itemfeedback");
351  }
352 
353  if (strlen($feedback_allcorrect)) {
354  $attrs = array(
355  "ident" => "response_allcorrect",
356  "view" => "All"
357  );
358  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
359  // qti flow_mat
360  $a_xml_writer->xmlStartTag("flow_mat");
361  $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
362  $a_xml_writer->xmlEndTag("flow_mat");
363  $a_xml_writer->xmlEndTag("itemfeedback");
364  }
365  if (strlen($feedback_onenotcorrect)) {
366  $attrs = array(
367  "ident" => "response_onenotcorrect",
368  "view" => "All"
369  );
370  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
371  // qti flow_mat
372  $a_xml_writer->xmlStartTag("flow_mat");
373  $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
374  $a_xml_writer->xmlEndTag("flow_mat");
375  $a_xml_writer->xmlEndTag("itemfeedback");
376  }
377 
378  $a_xml_writer->xmlEndTag("item");
379  $a_xml_writer->xmlEndTag("questestinterop");
380 
381  $xml = $a_xml_writer->xmlDumpMem(false);
382  if (!$a_include_header) {
383  $pos = strpos($xml, "?>");
384  $xml = substr($xml, $pos + 2);
385  }
386  return $xml;
387  }
const OQ_NESTED_TERMS
XML writer class.
const OUTPUT_JAVASCRIPT
addGeneralMetadata(ilXmlWriter $xmlwriter)
$xml
Definition: metadata.php:240
const OQ_PICTURES
Ordering question constants.
const ORDERING_QUESTION_IDENTIFIER
$ilUser
Definition: imgupload.php:18
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...
const OQ_TERMS
Create new PHPExcel object
obj_idprivate
const OQ_NESTED_PICTURES
global $ilDB
+ 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: