ILIAS  release_4-4 Revision
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
 assQuestionExport (&$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
 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 assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), NUMERIC_QUESTION_IDENTIFIER, 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  {
89  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches))
90  {
91  $a_xml_writer->xmlStartTag("material");
92  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
93  if (strcmp($matches[1], "") != 0)
94  {
95  $intlink = $solution["internal_link"];
96  }
97  $attrs = array(
98  "label" => "suggested_solution"
99  );
100  $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
101  $a_xml_writer->xmlEndTag("material");
102  }
103  }
104  // shuffle output
105  $attrs = array(
106  "fibtype" => "Decimal",
107  "maxchars" => $this->object->getMaxChars()
108  );
109  $a_xml_writer->xmlStartTag("render_fib", $attrs);
110  $a_xml_writer->xmlEndTag("render_fib");
111  $a_xml_writer->xmlEndTag("response_num");
112  $a_xml_writer->xmlEndTag("flow");
113  $a_xml_writer->xmlEndTag("presentation");
114 
115  // PART II: qti resprocessing
116  $a_xml_writer->xmlStartTag("resprocessing");
117  $a_xml_writer->xmlStartTag("outcomes");
118  $a_xml_writer->xmlStartTag("decvar");
119  $a_xml_writer->xmlEndTag("decvar");
120  $a_xml_writer->xmlEndTag("outcomes");
121  // add response conditions
122  $a_xml_writer->xmlStartTag("respcondition");
123  // qti conditionvar
124  $a_xml_writer->xmlStartTag("conditionvar");
125  $attrs = array(
126  "respident" => "NUM"
127  );
128  $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
129  $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
130  $a_xml_writer->xmlEndTag("conditionvar");
131  // qti setvar
132  $attrs = array(
133  "action" => "Add"
134  );
135  $a_xml_writer->xmlElement("setvar", $attrs, $this->object->getPoints());
136  // qti displayfeedback
137  $attrs = array(
138  "feedbacktype" => "Response",
139  "linkrefid" => "Correct"
140  );
141  $a_xml_writer->xmlElement("displayfeedback", $attrs);
142  $a_xml_writer->xmlEndTag("respcondition");
143 
144  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
145  $this->object->getId(), true
146  );
147  if (strlen($feedback_allcorrect))
148  {
149  $attrs = array(
150  "continue" => "Yes"
151  );
152  $a_xml_writer->xmlStartTag("respcondition", $attrs);
153  // qti conditionvar
154  $a_xml_writer->xmlStartTag("conditionvar");
155  $attrs = array(
156  "respident" => "NUM"
157  );
158  $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
159  $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
160  $a_xml_writer->xmlEndTag("conditionvar");
161  // qti displayfeedback
162  $attrs = array(
163  "feedbacktype" => "Response",
164  "linkrefid" => "response_allcorrect"
165  );
166  $a_xml_writer->xmlElement("displayfeedback", $attrs);
167  $a_xml_writer->xmlEndTag("respcondition");
168  }
169 
170  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
171  $this->object->getId(), false
172  );
173  if (strlen($feedback_onenotcorrect))
174  {
175  $attrs = array(
176  "continue" => "Yes"
177  );
178  $a_xml_writer->xmlStartTag("respcondition", $attrs);
179  // qti conditionvar
180  $a_xml_writer->xmlStartTag("conditionvar");
181  $a_xml_writer->xmlStartTag("not");
182  $attrs = array(
183  "respident" => "NUM"
184  );
185  $a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
186  $a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
187  $a_xml_writer->xmlEndTag("not");
188  $a_xml_writer->xmlEndTag("conditionvar");
189  // qti displayfeedback
190  $attrs = array(
191  "feedbacktype" => "Response",
192  "linkrefid" => "response_onenotcorrect"
193  );
194  $a_xml_writer->xmlElement("displayfeedback", $attrs);
195  $a_xml_writer->xmlEndTag("respcondition");
196  }
197 
198  $a_xml_writer->xmlEndTag("resprocessing");
199 
200  // PART III: qti itemfeedback
201  $attrs = array(
202  "ident" => "Correct",
203  "view" => "All"
204  );
205  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
206  // qti flow_mat
207  $a_xml_writer->xmlStartTag("flow_mat");
208  $a_xml_writer->xmlStartTag("material");
209  $a_xml_writer->xmlElement("mattext");
210  $a_xml_writer->xmlEndTag("material");
211  $a_xml_writer->xmlEndTag("flow_mat");
212  $a_xml_writer->xmlEndTag("itemfeedback");
213  if (strlen($feedback_allcorrect))
214  {
215  $attrs = array(
216  "ident" => "response_allcorrect",
217  "view" => "All"
218  );
219  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
220  // qti flow_mat
221  $a_xml_writer->xmlStartTag("flow_mat");
222  $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
223  $a_xml_writer->xmlEndTag("flow_mat");
224  $a_xml_writer->xmlEndTag("itemfeedback");
225  }
226  if (strlen($feedback_onenotcorrect))
227  {
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->xmlEndTag("item");
241  $a_xml_writer->xmlEndTag("questestinterop");
242 
243  $xml = $a_xml_writer->xmlDumpMem(FALSE);
244  if (!$a_include_header)
245  {
246  $pos = strpos($xml, "?>");
247  $xml = substr($xml, $pos + 2);
248  }
249  return $xml;
250  }
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: