ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
assNumericExport 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 assNumericExport:
+ Collaboration diagram for assNumericExport:

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 public. 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...
 

Additional Inherited Members

- Data Fields inherited from assQuestionExport
 $object
 
const ITEM_SOLUTIONHINT = 'solutionhint'
 
- 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)
 

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

assNumericExport is a class for numeric 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.assNumericExport.php.

Member Function Documentation

◆ toXML()

assNumericExport::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 public.

Definition at line 35 of file class.assNumericExport.php.

References $DIC, $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), assQuestionExport\addSolutionHints(), IL_INST_ID, NUMERIC_QUESTION_IDENTIFIER, and ILIAS\Repository\object().

35  : string
36  {
37  global $DIC;
38  $ilias = $DIC['ilias'];
39 
40  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
41  $a_xml_writer = new ilXmlWriter();
42  // set xml header
43  $a_xml_writer->xmlHeader();
44  $a_xml_writer->xmlStartTag("questestinterop");
45  $attrs = array(
46  "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
47  "title" => $this->object->getTitle(),
48  "maxattempts" => $this->object->getNrOfTries()
49  );
50  $a_xml_writer->xmlStartTag("item", $attrs);
51  // add question description
52  $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
53  $a_xml_writer->xmlStartTag("itemmetadata");
54  $a_xml_writer->xmlStartTag("qtimetadata");
55  $a_xml_writer->xmlStartTag("qtimetadatafield");
56  $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
57  $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
58  $a_xml_writer->xmlEndTag("qtimetadatafield");
59  $a_xml_writer->xmlStartTag("qtimetadatafield");
60  $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
61  $a_xml_writer->xmlElement("fieldentry", null, NUMERIC_QUESTION_IDENTIFIER);
62  $a_xml_writer->xmlEndTag("qtimetadatafield");
63  $a_xml_writer->xmlStartTag("qtimetadatafield");
64  $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
65  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getAuthor());
66  $a_xml_writer->xmlEndTag("qtimetadatafield");
67 
68  // additional content editing information
69  $this->addAdditionalContentEditingModeInformation($a_xml_writer);
70  $this->addGeneralMetadata($a_xml_writer);
71 
72  $a_xml_writer->xmlEndTag("qtimetadata");
73  $a_xml_writer->xmlEndTag("itemmetadata");
74 
75  // PART I: qti presentation
76  $attrs = array(
77  "label" => $this->object->getTitle()
78  );
79  $a_xml_writer->xmlStartTag("presentation", $attrs);
80  // add flow to presentation
81  $a_xml_writer->xmlStartTag("flow");
82  // add material with question text to presentation
83  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
84  // add answers to presentation
85  $attrs = array(
86  "ident" => "NUM",
87  "rcardinality" => "Single",
88  "numtype" => "Decimal"
89  );
90  $a_xml_writer->xmlStartTag("response_num", $attrs);
91  $solution = $this->object->getSuggestedSolution(0);
92  if ($solution !== null && count($solution)) {
93  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) {
94  $a_xml_writer->xmlStartTag("material");
95  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
96  if (strcmp($matches[1], "") != 0) {
97  $intlink = $solution["internal_link"];
98  }
99  $attrs = array(
100  "label" => "suggested_solution"
101  );
102  $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
103  $a_xml_writer->xmlEndTag("material");
104  }
105  }
106  // shuffle output
107  $attrs = array(
108  "fibtype" => "Decimal",
109  "maxchars" => $this->object->getMaxChars()
110  );
111  $a_xml_writer->xmlStartTag("render_fib", $attrs);
112  $a_xml_writer->xmlEndTag("render_fib");
113  $a_xml_writer->xmlEndTag("response_num");
114  $a_xml_writer->xmlEndTag("flow");
115  $a_xml_writer->xmlEndTag("presentation");
116 
117  // PART II: qti resprocessing
118  $a_xml_writer->xmlStartTag("resprocessing");
119  $a_xml_writer->xmlStartTag("outcomes");
120  $a_xml_writer->xmlStartTag("decvar");
121  $a_xml_writer->xmlEndTag("decvar");
122  $a_xml_writer->xmlEndTag("outcomes");
123  // add response conditions
124  $a_xml_writer->xmlStartTag("respcondition");
125  // qti conditionvar
126  $a_xml_writer->xmlStartTag("conditionvar");
127  $attrs = array(
128  "respident" => "NUM"
129  );
130  $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
131  $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
132  $a_xml_writer->xmlEndTag("conditionvar");
133  // qti setvar
134  $attrs = array(
135  "action" => "Add"
136  );
137  $a_xml_writer->xmlElement("setvar", $attrs, $this->object->getPoints());
138  // qti displayfeedback
139  $attrs = array(
140  "feedbacktype" => "Response",
141  "linkrefid" => "Correct"
142  );
143  $a_xml_writer->xmlElement("displayfeedback", $attrs);
144  $a_xml_writer->xmlEndTag("respcondition");
145 
146  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
147  $this->object->getId(),
148  true
149  );
150  if (strlen($feedback_allcorrect)) {
151  $attrs = array(
152  "continue" => "Yes"
153  );
154  $a_xml_writer->xmlStartTag("respcondition", $attrs);
155  // qti conditionvar
156  $a_xml_writer->xmlStartTag("conditionvar");
157  $attrs = array(
158  "respident" => "NUM"
159  );
160  $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
161  $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
162  $a_xml_writer->xmlEndTag("conditionvar");
163  // qti displayfeedback
164  $attrs = array(
165  "feedbacktype" => "Response",
166  "linkrefid" => "response_allcorrect"
167  );
168  $a_xml_writer->xmlElement("displayfeedback", $attrs);
169  $a_xml_writer->xmlEndTag("respcondition");
170  }
171 
172  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
173  $this->object->getId(),
174  false
175  );
176  if (strlen($feedback_onenotcorrect)) {
177  $attrs = array(
178  "continue" => "Yes"
179  );
180  $a_xml_writer->xmlStartTag("respcondition", $attrs);
181  // qti conditionvar
182  $a_xml_writer->xmlStartTag("conditionvar");
183  $a_xml_writer->xmlStartTag("not");
184  $attrs = array(
185  "respident" => "NUM"
186  );
187  $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
188  $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
189  $a_xml_writer->xmlEndTag("not");
190  $a_xml_writer->xmlEndTag("conditionvar");
191  // qti displayfeedback
192  $attrs = array(
193  "feedbacktype" => "Response",
194  "linkrefid" => "response_onenotcorrect"
195  );
196  $a_xml_writer->xmlElement("displayfeedback", $attrs);
197  $a_xml_writer->xmlEndTag("respcondition");
198  }
199 
200  $a_xml_writer->xmlEndTag("resprocessing");
201 
202  // PART III: qti itemfeedback
203  $attrs = array(
204  "ident" => "Correct",
205  "view" => "All"
206  );
207  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
208  // qti flow_mat
209  $a_xml_writer->xmlStartTag("flow_mat");
210  $a_xml_writer->xmlStartTag("material");
211  $a_xml_writer->xmlElement("mattext");
212  $a_xml_writer->xmlEndTag("material");
213  $a_xml_writer->xmlEndTag("flow_mat");
214  $a_xml_writer->xmlEndTag("itemfeedback");
215  if (strlen($feedback_allcorrect)) {
216  $attrs = array(
217  "ident" => "response_allcorrect",
218  "view" => "All"
219  );
220  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
221  // qti flow_mat
222  $a_xml_writer->xmlStartTag("flow_mat");
223  $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
224  $a_xml_writer->xmlEndTag("flow_mat");
225  $a_xml_writer->xmlEndTag("itemfeedback");
226  }
227  if (strlen($feedback_onenotcorrect)) {
228  $attrs = array(
229  "ident" => "response_onenotcorrect",
230  "view" => "All"
231  );
232  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
233  // qti flow_mat
234  $a_xml_writer->xmlStartTag("flow_mat");
235  $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
236  $a_xml_writer->xmlEndTag("flow_mat");
237  $a_xml_writer->xmlEndTag("itemfeedback");
238  }
239 
240  $a_xml_writer = $this->addSolutionHints($a_xml_writer);
241 
242  $a_xml_writer->xmlEndTag("item");
243  $a_xml_writer->xmlEndTag("questestinterop");
244 
245  $xml = $a_xml_writer->xmlDumpMem(false);
246  if (!$a_include_header) {
247  $pos = strpos($xml, "?>");
248  $xml = substr($xml, $pos + 2);
249  }
250  return $xml;
251  }
const IL_INST_ID
Definition: constants.php:40
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addGeneralMetadata(ilXmlWriter $xmlwriter)
global $DIC
Definition: feed.php:28
const NUMERIC_QUESTION_IDENTIFIER
$xml
Definition: metadata.php:351
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
addSolutionHints(ilXmlWriter $writer)
+ Here is the call graph for this function:

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