ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), array, NUMERIC_QUESTION_IDENTIFIER, object, and ilXmlWriter\xmlHeader().

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

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