ILIAS  trunk Revision v5.2.0beta1-34132-g2d4d73d4a0
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 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...
 
 addQTIMaterial (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
 

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)
 
 addSuggestedSolutionLink (ilXmlWriter $writer, assQuestionSuggestedSolution $suggested_solution)
 

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 29 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 37 of file class.assNumericExport.php.

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

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