ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assNumericExport Class Reference

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

Additional Inherited Members

- Data Fields inherited from assQuestionExport
 $object
 
- 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 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 15 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

Returns
string The QTI xml representation of the question public

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

References $DIC, $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), NUMERIC_QUESTION_IDENTIFIER, and ilXmlWriter\xmlHeader().

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

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