ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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
 
const ITEM_SOLUTIONHINT = 'solutionhint'
 

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)
 
 addSolutionHints (ilXmlWriter $writer)
 
 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 27 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.

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

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

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

Field Documentation

◆ $object

assOrderingQuestionExport::$object

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


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