ILIAS  release_8 Revision v8.24
assTextSubsetExport Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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...
 

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)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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.

Reimplemented from assQuestionExport.

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

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

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

+ Here is the call graph for this function:

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