ILIAS  trunk Revision v5.2.0beta1-34132-g2d4d73d4a0
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 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...
 
- 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 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 29 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.

Definition at line 36 of file class.assTextSubsetExport.php.

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

36  : string
37  {
38  global $DIC;
39  $ilias = $DIC['ilias'];
40 
41  $a_xml_writer = new ilXmlWriter();
42  // set xml header
43  $a_xml_writer->xmlHeader();
44  $a_xml_writer->xmlStartTag("questestinterop");
45  $attrs = [
46  "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
47  "title" => $this->object->getTitle(),
48  "maxattempts" => $this->object->getNrOfTries()
49  ];
50  $a_xml_writer->xmlStartTag("item", $attrs);
51  // add question description
52  $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
53  $a_xml_writer->xmlStartTag("itemmetadata");
54  $a_xml_writer->xmlStartTag("qtimetadata");
55  $a_xml_writer->xmlStartTag("qtimetadatafield");
56  $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
57  $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
58  $a_xml_writer->xmlEndTag("qtimetadatafield");
59  $a_xml_writer->xmlStartTag("qtimetadatafield");
60  $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
61  $a_xml_writer->xmlElement("fieldentry", null, QuestionIdentifiers::TEXTSUBSET_QUESTION_IDENTIFIER);
62  $a_xml_writer->xmlEndTag("qtimetadatafield");
63  $a_xml_writer->xmlStartTag("qtimetadatafield");
64  $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
65  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getAuthor());
66  $a_xml_writer->xmlEndTag("qtimetadatafield");
67 
68  // additional content editing information
69  $this->addAdditionalContentEditingModeInformation($a_xml_writer);
70  $this->addGeneralMetadata($a_xml_writer);
71 
72  $a_xml_writer->xmlStartTag("qtimetadatafield");
73  $a_xml_writer->xmlElement("fieldlabel", null, "textrating");
74  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getTextRating());
75  $a_xml_writer->xmlEndTag("qtimetadatafield");
76  $a_xml_writer->xmlStartTag("qtimetadatafield");
77  $a_xml_writer->xmlElement("fieldlabel", null, "correctanswers");
78  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getCorrectAnswers());
79  $a_xml_writer->xmlEndTag("qtimetadatafield");
80  $a_xml_writer->xmlStartTag("qtimetadatafield");
81  $a_xml_writer->xmlElement("fieldlabel", null, "points");
82  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getPoints());
83  $a_xml_writer->xmlEndTag("qtimetadatafield");
84  $a_xml_writer->xmlEndTag("qtimetadata");
85  $a_xml_writer->xmlEndTag("itemmetadata");
86 
87  // PART I: qti presentation
88  $attrs = [
89  "label" => $this->object->getTitle()
90  ];
91  $a_xml_writer->xmlStartTag("presentation", $attrs);
92  // add flow to presentation
93  $a_xml_writer->xmlStartTag("flow");
94  // add material with question text to presentation
95  $this->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
96  // add answers to presentation
97  for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
98  $attrs = [
99  "ident" => "TEXTSUBSET_$counter",
100  "rcardinality" => "Single"
101  ];
102  $a_xml_writer->xmlStartTag("response_str", $attrs);
103  $solution = $this->object->getSuggestedSolution(0);
104  if ($solution !== null) {
105  $a_xml_writer = $this->addSuggestedSolutionLink($a_xml_writer, $solution);
106  }
107  // shuffle output
108  $attrs = [
109  "fibtype" => "String",
110  "columns" => $this->object->getMaxTextboxWidth()
111  ];
112  $a_xml_writer->xmlStartTag("render_fib", $attrs);
113  $a_xml_writer->xmlEndTag("render_fib");
114  $a_xml_writer->xmlEndTag("response_str");
115  }
116 
117  $a_xml_writer->xmlEndTag("flow");
118  $a_xml_writer->xmlEndTag("presentation");
119 
120  // PART II: qti resprocessing
121  $a_xml_writer->xmlStartTag("resprocessing");
122  $a_xml_writer->xmlStartTag("outcomes");
123  $a_xml_writer->xmlStartTag("decvar");
124  $a_xml_writer->xmlEndTag("decvar");
125  $attribs = [
126  "varname" => "matches",
127  "defaultval" => "0"
128  ];
129  $a_xml_writer->xmlElement("decvar", $attribs, null);
130  $a_xml_writer->xmlEndTag("outcomes");
131  // add response conditions
132  for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
133  $scoregroups = &$this->object->joinAnswers();
134  foreach ($scoregroups as $points => $scoreanswers) {
135  $attrs = [
136  "continue" => "Yes"
137  ];
138  $a_xml_writer->xmlStartTag("respcondition", $attrs);
139  // qti conditionvar
140  $a_xml_writer->xmlStartTag("conditionvar");
141  $attrs = [
142  "respident" => "TEXTSUBSET_$counter"
143  ];
144  $a_xml_writer->xmlElement("varsubset", $attrs, join(",", $scoreanswers));
145  $a_xml_writer->xmlEndTag("conditionvar");
146  // qti setvar
147  $attrs = [
148  "varname" => "matches",
149  "action" => "Add"
150  ];
151  $a_xml_writer->xmlElement("setvar", $attrs, $points);
152  // qti displayfeedback
153  $attrs = [
154  "feedbacktype" => "Response",
155  "linkrefid" => "Matches_$counter"
156  ];
157  $a_xml_writer->xmlElement("displayfeedback", $attrs);
158  $a_xml_writer->xmlEndTag("respcondition");
159  }
160  }
161 
162  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
163  $this->object->getId(),
164  true
165  );
166  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
167  $this->object->getId(),
168  false
169  );
170  if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
171  if (strlen($feedback_allcorrect)) {
172  $attrs = [
173  "continue" => "Yes"
174  ];
175  $a_xml_writer->xmlStartTag("respcondition", $attrs);
176  // qti conditionvar
177  $a_xml_writer->xmlStartTag("conditionvar");
178  $attrs = [
179  "respident" => "points"
180  ];
181  $a_xml_writer->xmlElement("varsubset", $attrs, $this->object->getMaximumPoints());
182  $a_xml_writer->xmlEndTag("conditionvar");
183  // qti displayfeedback
184  $attrs = [
185  "feedbacktype" => "Response",
186  "linkrefid" => "response_allcorrect"
187  ];
188  $a_xml_writer->xmlElement("displayfeedback", $attrs);
189  $a_xml_writer->xmlEndTag("respcondition");
190  }
191 
192  if (strlen($feedback_onenotcorrect)) {
193  $attrs = [
194  "continue" => "Yes"
195  ];
196  $a_xml_writer->xmlStartTag("respcondition", $attrs);
197  // qti conditionvar
198  $a_xml_writer->xmlStartTag("conditionvar");
199  $a_xml_writer->xmlStartTag("not");
200 
201  $attrs = [
202  "respident" => "points"
203  ];
204  $a_xml_writer->xmlElement("varsubset", $attrs, $this->object->getMaximumPoints());
205 
206  $a_xml_writer->xmlEndTag("not");
207  $a_xml_writer->xmlEndTag("conditionvar");
208  // qti displayfeedback
209  $attrs = [
210  "feedbacktype" => "Response",
211  "linkrefid" => "response_onenotcorrect"
212  ];
213  $a_xml_writer->xmlElement("displayfeedback", $attrs);
214  $a_xml_writer->xmlEndTag("respcondition");
215  }
216  }
217 
218  $a_xml_writer->xmlEndTag("resprocessing");
219 
220  // PART III: qti itemfeedback
221  for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
222  $attrs = [
223  "ident" => "Matches_$counter",
224  "view" => "All"
225  ];
226  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
227  // qti flow_mat
228  $a_xml_writer->xmlStartTag("flow_mat");
229  $a_xml_writer->xmlStartTag("material");
230  $a_xml_writer->xmlElement("mattext");
231  $a_xml_writer->xmlEndTag("material");
232  $a_xml_writer->xmlEndTag("flow_mat");
233  $a_xml_writer->xmlEndTag("itemfeedback");
234  }
235 
236  if (strlen($feedback_allcorrect)) {
237  $attrs = [
238  "ident" => "response_allcorrect",
239  "view" => "All"
240  ];
241  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
242  // qti flow_mat
243  $a_xml_writer->xmlStartTag("flow_mat");
244  $this->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
245  $a_xml_writer->xmlEndTag("flow_mat");
246  $a_xml_writer->xmlEndTag("itemfeedback");
247  }
248  if (strlen($feedback_onenotcorrect)) {
249  $attrs = [
250  "ident" => "response_onenotcorrect",
251  "view" => "All"
252  ];
253  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
254  // qti flow_mat
255  $a_xml_writer->xmlStartTag("flow_mat");
256  $this->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
257  $a_xml_writer->xmlEndTag("flow_mat");
258  $a_xml_writer->xmlEndTag("itemfeedback");
259  }
260 
261  $a_xml_writer = $this->addSolutionHints($a_xml_writer);
262 
263  $a_xml_writer->xmlEndTag("item");
264  $a_xml_writer->xmlEndTag("questestinterop");
265 
266  $xml = $a_xml_writer->xmlDumpMem(false);
267  if (!$a_include_header) {
268  $pos = strpos($xml, "?>");
269  $xml = substr($xml, $pos + 2);
270  }
271  return $xml;
272  }
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: