ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.assNumericExport.php
Go to the documentation of this file.
1 <?php
28 {
35  public function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false): string
36  {
37  global $DIC;
38  $ilias = $DIC['ilias'];
39 
40  $a_xml_writer = new ilXmlWriter();
41  // set xml header
42  $a_xml_writer->xmlHeader();
43  $a_xml_writer->xmlStartTag("questestinterop");
44  $attrs = [
45  "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
46  "title" => $this->object->getTitle(),
47  "maxattempts" => $this->object->getNrOfTries()
48  ];
49  $a_xml_writer->xmlStartTag("item", $attrs);
50  // add question description
51  $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
52  $a_xml_writer->xmlStartTag("itemmetadata");
53  $a_xml_writer->xmlStartTag("qtimetadata");
54  $a_xml_writer->xmlStartTag("qtimetadatafield");
55  $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
56  $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
57  $a_xml_writer->xmlEndTag("qtimetadatafield");
58  $a_xml_writer->xmlStartTag("qtimetadatafield");
59  $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
60  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getQuestionType());
61  $a_xml_writer->xmlEndTag("qtimetadatafield");
62  $a_xml_writer->xmlStartTag("qtimetadatafield");
63  $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
64  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getAuthor());
65  $a_xml_writer->xmlEndTag("qtimetadatafield");
66 
67  // additional content editing information
68  $this->addAdditionalContentEditingModeInformation($a_xml_writer);
69  $this->addGeneralMetadata($a_xml_writer);
70 
71  $a_xml_writer->xmlEndTag("qtimetadata");
72  $a_xml_writer->xmlEndTag("itemmetadata");
73 
74  // PART I: qti presentation
75  $attrs = [
76  "label" => $this->object->getTitle()
77  ];
78  $a_xml_writer->xmlStartTag("presentation", $attrs);
79  // add flow to presentation
80  $a_xml_writer->xmlStartTag("flow");
81  // add material with question text to presentation
82  $this->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
83  // add answers to presentation
84  $attrs = [
85  "ident" => "NUM",
86  "rcardinality" => "Single",
87  "numtype" => "Decimal"
88  ];
89  $a_xml_writer->xmlStartTag("response_num", $attrs);
90  $a_xml_writer = $this->addSuggestedSolution($a_xml_writer);
91  // shuffle output
92  $attrs = [
93  "fibtype" => "Decimal",
94  "maxchars" => $this->object->getMaxChars()
95  ];
96  $a_xml_writer->xmlStartTag("render_fib", $attrs);
97  $a_xml_writer->xmlEndTag("render_fib");
98  $a_xml_writer->xmlEndTag("response_num");
99  $a_xml_writer->xmlEndTag("flow");
100  $a_xml_writer->xmlEndTag("presentation");
101 
102  // PART II: qti resprocessing
103  $a_xml_writer->xmlStartTag("resprocessing");
104  $a_xml_writer->xmlStartTag("outcomes");
105  $a_xml_writer->xmlStartTag("decvar");
106  $a_xml_writer->xmlEndTag("decvar");
107  $a_xml_writer->xmlEndTag("outcomes");
108  // add response conditions
109  $a_xml_writer->xmlStartTag("respcondition");
110  // qti conditionvar
111  $a_xml_writer->xmlStartTag("conditionvar");
112  $attrs = [
113  "respident" => "NUM"
114  ];
115  $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
116  $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
117  $a_xml_writer->xmlEndTag("conditionvar");
118  // qti setvar
119  $attrs = [
120  "action" => "Add"
121  ];
122  $a_xml_writer->xmlElement("setvar", $attrs, $this->object->getPoints());
123  // qti displayfeedback
124  $attrs = [
125  "feedbacktype" => "Response",
126  "linkrefid" => "Correct"
127  ];
128  $a_xml_writer->xmlElement("displayfeedback", $attrs);
129  $a_xml_writer->xmlEndTag("respcondition");
130 
131  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
132  $this->object->getId(),
133  true
134  );
135  if (strlen($feedback_allcorrect)) {
136  $attrs = [
137  "continue" => "Yes"
138  ];
139  $a_xml_writer->xmlStartTag("respcondition", $attrs);
140  // qti conditionvar
141  $a_xml_writer->xmlStartTag("conditionvar");
142  $attrs = [
143  "respident" => "NUM"
144  ];
145  $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
146  $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
147  $a_xml_writer->xmlEndTag("conditionvar");
148  // qti displayfeedback
149  $attrs = [
150  "feedbacktype" => "Response",
151  "linkrefid" => "response_allcorrect"
152  ];
153  $a_xml_writer->xmlElement("displayfeedback", $attrs);
154  $a_xml_writer->xmlEndTag("respcondition");
155  }
156 
157  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
158  $this->object->getId(),
159  false
160  );
161  if (strlen($feedback_onenotcorrect)) {
162  $attrs = [
163  "continue" => "Yes"
164  ];
165  $a_xml_writer->xmlStartTag("respcondition", $attrs);
166  // qti conditionvar
167  $a_xml_writer->xmlStartTag("conditionvar");
168  $a_xml_writer->xmlStartTag("not");
169  $attrs = [
170  "respident" => "NUM"
171  ];
172  $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
173  $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
174  $a_xml_writer->xmlEndTag("not");
175  $a_xml_writer->xmlEndTag("conditionvar");
176  // qti displayfeedback
177  $attrs = [
178  "feedbacktype" => "Response",
179  "linkrefid" => "response_onenotcorrect"
180  ];
181  $a_xml_writer->xmlElement("displayfeedback", $attrs);
182  $a_xml_writer->xmlEndTag("respcondition");
183  }
184 
185  $a_xml_writer->xmlEndTag("resprocessing");
186 
187  // PART III: qti itemfeedback
188  $attrs = [
189  "ident" => "Correct",
190  "view" => "All"
191  ];
192  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
193  // qti flow_mat
194  $a_xml_writer->xmlStartTag("flow_mat");
195  $a_xml_writer->xmlStartTag("material");
196  $a_xml_writer->xmlElement("mattext");
197  $a_xml_writer->xmlEndTag("material");
198  $a_xml_writer->xmlEndTag("flow_mat");
199  $a_xml_writer->xmlEndTag("itemfeedback");
200  if (strlen($feedback_allcorrect)) {
201  $attrs = [
202  "ident" => "response_allcorrect",
203  "view" => "All"
204  ];
205  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
206  // qti flow_mat
207  $a_xml_writer->xmlStartTag("flow_mat");
208  $this->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
209  $a_xml_writer->xmlEndTag("flow_mat");
210  $a_xml_writer->xmlEndTag("itemfeedback");
211  }
212  if (strlen($feedback_onenotcorrect)) {
213  $attrs = [
214  "ident" => "response_onenotcorrect",
215  "view" => "All"
216  ];
217  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
218  // qti flow_mat
219  $a_xml_writer->xmlStartTag("flow_mat");
220  $this->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
221  $a_xml_writer->xmlEndTag("flow_mat");
222  $a_xml_writer->xmlEndTag("itemfeedback");
223  }
224 
225  $a_xml_writer = $this->addSolutionHints($a_xml_writer);
226 
227  $a_xml_writer->xmlEndTag("item");
228  $a_xml_writer->xmlEndTag("questestinterop");
229 
230  $xml = $a_xml_writer->xmlDumpMem(false);
231  if (!$a_include_header) {
232  $pos = strpos($xml, "?>");
233  $xml = substr($xml, $pos + 2);
234  }
235  return $xml;
236  }
237 }
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)
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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...
global $DIC
Definition: shib_login.php:22
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)