ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assTextSubsetExport Class Reference

Class for text subset question exports. More...

+ Inheritance diagram for assTextSubsetExport:
+ Collaboration diagram for assTextSubsetExport:

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 text subset question exports.

assTextSubsetExport is a class for text subset 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.assTextSubsetExport.php.

Member Function Documentation

◆ toXML()

assTextSubsetExport::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.assTextSubsetExport.php.

References $counter, $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), array, object, TEXTSUBSET_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, TEXTSUBSET_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->xmlStartTag("qtimetadatafield");
68  $a_xml_writer->xmlElement("fieldlabel", null, "textrating");
69  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getTextRating());
70  $a_xml_writer->xmlEndTag("qtimetadatafield");
71  $a_xml_writer->xmlStartTag("qtimetadatafield");
72  $a_xml_writer->xmlElement("fieldlabel", null, "correctanswers");
73  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getCorrectAnswers());
74  $a_xml_writer->xmlEndTag("qtimetadatafield");
75  $a_xml_writer->xmlStartTag("qtimetadatafield");
76  $a_xml_writer->xmlElement("fieldlabel", null, "points");
77  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getPoints());
78  $a_xml_writer->xmlEndTag("qtimetadatafield");
79  $a_xml_writer->xmlEndTag("qtimetadata");
80  $a_xml_writer->xmlEndTag("itemmetadata");
81 
82  // PART I: qti presentation
83  $attrs = array(
84  "label" => $this->object->getTitle()
85  );
86  $a_xml_writer->xmlStartTag("presentation", $attrs);
87  // add flow to presentation
88  $a_xml_writer->xmlStartTag("flow");
89  // add material with question text to presentation
90  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
91  // add answers to presentation
92  for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
93  $attrs = array(
94  "ident" => "TEXTSUBSET_" . sprintf("%02d", $counter),
95  "rcardinality" => "Single"
96  );
97  $a_xml_writer->xmlStartTag("response_str", $attrs);
98  $solution = $this->object->getSuggestedSolution(0);
99  if (count($solution)) {
100  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) {
101  $a_xml_writer->xmlStartTag("material");
102  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
103  if (strcmp($matches[1], "") != 0) {
104  $intlink = $solution["internal_link"];
105  }
106  $attrs = array(
107  "label" => "suggested_solution"
108  );
109  $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
110  $a_xml_writer->xmlEndTag("material");
111  }
112  }
113  // shuffle output
114  $attrs = array(
115  "fibtype" => "String",
116  "columns" => $this->object->getMaxTextboxWidth()
117  );
118  $a_xml_writer->xmlStartTag("render_fib", $attrs);
119  $a_xml_writer->xmlEndTag("render_fib");
120  $a_xml_writer->xmlEndTag("response_str");
121  }
122 
123  $a_xml_writer->xmlEndTag("flow");
124  $a_xml_writer->xmlEndTag("presentation");
125 
126  // PART II: qti resprocessing
127  $a_xml_writer->xmlStartTag("resprocessing");
128  $a_xml_writer->xmlStartTag("outcomes");
129  $a_xml_writer->xmlStartTag("decvar");
130  $a_xml_writer->xmlEndTag("decvar");
131  $attribs = array(
132  "varname" => "matches",
133  "defaultval" => "0"
134  );
135  $a_xml_writer->xmlElement("decvar", $attribs, null);
136  $a_xml_writer->xmlEndTag("outcomes");
137  // add response conditions
138  for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
139  $scoregroups =&$this->object->joinAnswers();
140  foreach ($scoregroups as $points => $scoreanswers) {
141  $attrs = array(
142  "continue" => "Yes"
143  );
144  $a_xml_writer->xmlStartTag("respcondition", $attrs);
145  // qti conditionvar
146  $a_xml_writer->xmlStartTag("conditionvar");
147  $attrs = array(
148  "respident" => "TEXTSUBSET_" . sprintf("%02d", $counter)
149  );
150  $a_xml_writer->xmlElement("varsubset", $attrs, join(",", $scoreanswers));
151  $a_xml_writer->xmlEndTag("conditionvar");
152  // qti setvar
153  $attrs = array(
154  "varname" => "matches",
155  "action" => "Add"
156  );
157  $a_xml_writer->xmlElement("setvar", $attrs, $points);
158  // qti displayfeedback
159  $attrs = array(
160  "feedbacktype" => "Response",
161  "linkrefid" => "Matches_" . sprintf("%02d", $counter)
162  );
163  $a_xml_writer->xmlElement("displayfeedback", $attrs);
164  $a_xml_writer->xmlEndTag("respcondition");
165  }
166  }
167 
168  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
169  $this->object->getId(),
170  true
171  );
172  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
173  $this->object->getId(),
174  false
175  );
176  if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
177  if (strlen($feedback_allcorrect)) {
178  $attrs = array(
179  "continue" => "Yes"
180  );
181  $a_xml_writer->xmlStartTag("respcondition", $attrs);
182  // qti conditionvar
183  $a_xml_writer->xmlStartTag("conditionvar");
184  $attrs = array(
185  "respident" => "points"
186  );
187  $a_xml_writer->xmlElement("varsubset", $attrs, $this->object->getMaximumPoints());
188  $a_xml_writer->xmlEndTag("conditionvar");
189  // qti displayfeedback
190  $attrs = array(
191  "feedbacktype" => "Response",
192  "linkrefid" => "response_allcorrect"
193  );
194  $a_xml_writer->xmlElement("displayfeedback", $attrs);
195  $a_xml_writer->xmlEndTag("respcondition");
196  }
197 
198  if (strlen($feedback_onenotcorrect)) {
199  $attrs = array(
200  "continue" => "Yes"
201  );
202  $a_xml_writer->xmlStartTag("respcondition", $attrs);
203  // qti conditionvar
204  $a_xml_writer->xmlStartTag("conditionvar");
205  $a_xml_writer->xmlStartTag("not");
206 
207  $attrs = array(
208  "respident" => "points"
209  );
210  $a_xml_writer->xmlElement("varsubset", $attrs, $this->object->getMaximumPoints());
211 
212  $a_xml_writer->xmlEndTag("not");
213  $a_xml_writer->xmlEndTag("conditionvar");
214  // qti displayfeedback
215  $attrs = array(
216  "feedbacktype" => "Response",
217  "linkrefid" => "response_onenotcorrect"
218  );
219  $a_xml_writer->xmlElement("displayfeedback", $attrs);
220  $a_xml_writer->xmlEndTag("respcondition");
221  }
222  }
223 
224  $a_xml_writer->xmlEndTag("resprocessing");
225 
226  // PART III: qti itemfeedback
227  for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
228  $attrs = array(
229  "ident" => "Matches_" . sprintf("%02d", $counter),
230  "view" => "All"
231  );
232  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
233  // qti flow_mat
234  $a_xml_writer->xmlStartTag("flow_mat");
235  $a_xml_writer->xmlStartTag("material");
236  $a_xml_writer->xmlElement("mattext");
237  $a_xml_writer->xmlEndTag("material");
238  $a_xml_writer->xmlEndTag("flow_mat");
239  $a_xml_writer->xmlEndTag("itemfeedback");
240  }
241 
242  if (strlen($feedback_allcorrect)) {
243  $attrs = array(
244  "ident" => "response_allcorrect",
245  "view" => "All"
246  );
247  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
248  // qti flow_mat
249  $a_xml_writer->xmlStartTag("flow_mat");
250  $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
251  $a_xml_writer->xmlEndTag("flow_mat");
252  $a_xml_writer->xmlEndTag("itemfeedback");
253  }
254  if (strlen($feedback_onenotcorrect)) {
255  $attrs = array(
256  "ident" => "response_onenotcorrect",
257  "view" => "All"
258  );
259  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
260  // qti flow_mat
261  $a_xml_writer->xmlStartTag("flow_mat");
262  $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
263  $a_xml_writer->xmlEndTag("flow_mat");
264  $a_xml_writer->xmlEndTag("itemfeedback");
265  }
266 
267  $a_xml_writer->xmlEndTag("item");
268  $a_xml_writer->xmlEndTag("questestinterop");
269 
270  $xml = $a_xml_writer->xmlDumpMem(false);
271  if (!$a_include_header) {
272  $pos = strpos($xml, "?>");
273  $xml = substr($xml, $pos + 2);
274  }
275  return $xml;
276  }
const TEXTSUBSET_QUESTION_IDENTIFIER
XML writer class.
addGeneralMetadata(ilXmlWriter $xmlwriter)
$counter
$xml
Definition: metadata.php:240
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: