ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
assTextQuestionExport Class Reference

Class for essay question exports. More...

+ Inheritance diagram for assTextQuestionExport:
+ Collaboration diagram for assTextQuestionExport:

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...
 

Data Fields

 $object
 
- Data Fields inherited from assQuestionExport
 $object
 

Additional Inherited Members

- 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 essay question exports.

assTextQuestionExport is a class for essay 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.assTextQuestionExport.php.

Member Function Documentation

◆ toXML()

assTextQuestionExport::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 31 of file class.assTextQuestionExport.php.

References $DIC, $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addAnswerSpecificFeedback(), assQuestionExport\addGeneralMetadata(), assQuestionExport\addQtiMetaDataField(), TEXT_QUESTION_IDENTIFIER, and ilXmlWriter\xmlHeader().

32  {
33  global $DIC;
34  $ilias = $DIC['ilias'];
35 
36  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
37  $a_xml_writer = new ilXmlWriter;
38  // set xml header
39  $a_xml_writer->xmlHeader();
40  $a_xml_writer->xmlStartTag("questestinterop");
41  $attrs = array(
42  "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
43  "title" => $this->object->getTitle(),
44  "maxattempts" => $this->object->getNrOfTries()
45  );
46  $a_xml_writer->xmlStartTag("item", $attrs);
47  // add question description
48  $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
49  // add estimated working time
50  $workingtime = $this->object->getEstimatedWorkingTime();
51  $duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
52  $a_xml_writer->xmlElement("duration", null, $duration);
53  // add ILIAS specific metadata
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, TEXT_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  $this->addQtiMetaDataField($a_xml_writer, 'wordcounter', (int) $this->object->isWordCounterEnabled());
74 
75  $a_xml_writer->xmlStartTag("qtimetadatafield");
76  $a_xml_writer->xmlElement("fieldlabel", null, "textrating");
77  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getTextRating());
78  $a_xml_writer->xmlEndTag("qtimetadatafield");
79 
80  /*
81  $a_xml_writer->xmlStartTag("qtimetadatafield");
82  $a_xml_writer->xmlElement("fieldlabel", NULL, "keywords");
83  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getKeywords());
84  $a_xml_writer->xmlEndTag("qtimetadatafield");
85  */
86 
87  $a_xml_writer->xmlStartTag("qtimetadatafield");
88  $a_xml_writer->xmlElement("fieldlabel", null, "matchcondition");
89  $a_xml_writer->xmlElement("fieldentry", null, $this->object->matchcondition);
90  $a_xml_writer->xmlEndTag("qtimetadatafield");
91 
92  $a_xml_writer->xmlStartTag("qtimetadatafield");
93  $a_xml_writer->xmlElement("fieldlabel", null, "termscoring");
94  $scores = base64_encode(serialize($this->object->getAnswers()));
95  $a_xml_writer->xmlElement("fieldentry", null, $scores);
96  $a_xml_writer->xmlEndTag("qtimetadatafield");
97 
98  $a_xml_writer->xmlStartTag("qtimetadatafield");
99  $a_xml_writer->xmlElement("fieldlabel", null, "termrelation");
100  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getKeywordRelation());
101  $a_xml_writer->xmlEndTag("qtimetadatafield");
102 
103  $a_xml_writer->xmlStartTag("qtimetadatafield");
104  $a_xml_writer->xmlElement("fieldlabel", null, "specificfeedback");
105  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getKeywordRelation());
106  $a_xml_writer->xmlEndTag("qtimetadatafield");
107 
108  $a_xml_writer->xmlEndTag("qtimetadata");
109  $a_xml_writer->xmlEndTag("itemmetadata");
110 
111  // PART I: qti presentation
112  $attrs = array(
113  "label" => $this->object->getTitle()
114  );
115  $a_xml_writer->xmlStartTag("presentation", $attrs);
116  // add flow to presentation
117  $a_xml_writer->xmlStartTag("flow");
118  // add material with question text to presentation
119  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
120  // add information on response rendering
121  $attrs = array(
122  "ident" => "TEXT",
123  "rcardinality" => "Ordered"
124  );
125  $a_xml_writer->xmlStartTag("response_str", $attrs);
126  $attrs = array(
127  "fibtype" => "String",
128  "prompt" => "Box"
129  );
130  if ($this->object->getMaxNumOfChars() > 0) {
131  $attrs["maxchars"] = $this->object->getMaxNumOfChars();
132  }
133  $a_xml_writer->xmlStartTag("render_fib", $attrs);
134  $attrs = array(
135  "ident" => "A"
136  );
137  $a_xml_writer->xmlStartTag("response_label", $attrs);
138  $a_xml_writer->xmlEndTag("response_label");
139  $a_xml_writer->xmlEndTag("render_fib");
140 
141  $solution = $this->object->getSuggestedSolution(0);
142  if (count($solution)) {
143  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) {
144  $a_xml_writer->xmlStartTag("material");
145  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
146  if (strcmp($matches[1], "") != 0) {
147  $intlink = $solution["internal_link"];
148  }
149  $attrs = array(
150  "label" => "suggested_solution"
151  );
152  $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
153  $a_xml_writer->xmlEndTag("material");
154  }
155  }
156  $a_xml_writer->xmlEndTag("response_str");
157  $a_xml_writer->xmlEndTag("flow");
158  $a_xml_writer->xmlEndTag("presentation");
159 
160  // PART II: qti resprocessing
161  $attrs = array(
162  "scoremodel" => "HumanRater"
163  );
164  $a_xml_writer->xmlStartTag("resprocessing", $attrs);
165  $a_xml_writer->xmlStartTag("outcomes");
166  $attrs = array(
167  "varname" => "WritingScore",
168  "vartype" => "Integer",
169  "minvalue" => "0",
170  "maxvalue" => $this->object->getPoints()
171  );
172  $a_xml_writer->xmlStartTag("decvar", $attrs);
173  $a_xml_writer->xmlEndTag("decvar");
174  $a_xml_writer->xmlEndTag("outcomes");
175 
176  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
177  $this->object->getId(),
178  true
179  );
180  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
181  $this->object->getId(),
182  false
183  );
184  if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
185  if (strlen($feedback_allcorrect)) {
186  $attrs = array(
187  "continue" => "Yes"
188  );
189  $a_xml_writer->xmlStartTag("respcondition", $attrs);
190  // qti conditionvar
191  $a_xml_writer->xmlStartTag("conditionvar");
192  $attrs = array(
193  "respident" => "points"
194  );
195  $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
196  $a_xml_writer->xmlEndTag("conditionvar");
197  // qti displayfeedback
198  $attrs = array(
199  "feedbacktype" => "Response",
200  "linkrefid" => "response_allcorrect"
201  );
202  $a_xml_writer->xmlElement("displayfeedback", $attrs);
203  $a_xml_writer->xmlEndTag("respcondition");
204  }
205 
206  if (strlen($feedback_onenotcorrect)) {
207  $attrs = array(
208  "continue" => "Yes"
209  );
210  $a_xml_writer->xmlStartTag("respcondition", $attrs);
211  // qti conditionvar
212  $a_xml_writer->xmlStartTag("conditionvar");
213  $a_xml_writer->xmlStartTag("not");
214  $attrs = array(
215  "respident" => "points"
216  );
217  $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
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->xmlStartTag("respcondition");
231  $a_xml_writer->xmlStartTag("conditionvar");
232  $a_xml_writer->xmlElement("other", null, "tutor_rated");
233  $a_xml_writer->xmlEndTag("conditionvar");
234  $a_xml_writer->xmlEndTag("respcondition");
235  $a_xml_writer->xmlEndTag("resprocessing");
236 
237  $this->addAnswerSpecificFeedback($a_xml_writer, $this->object->feedbackOBJ->getAnswerOptionsByAnswerIndex());
238 
239  if (strlen($feedback_allcorrect)) {
240  $attrs = array(
241  "ident" => "response_allcorrect",
242  "view" => "All"
243  );
244  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
245  // qti flow_mat
246  $a_xml_writer->xmlStartTag("flow_mat");
247  $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
248  $a_xml_writer->xmlEndTag("flow_mat");
249  $a_xml_writer->xmlEndTag("itemfeedback");
250  }
251  if (strlen($feedback_onenotcorrect)) {
252  $attrs = array(
253  "ident" => "response_onenotcorrect",
254  "view" => "All"
255  );
256  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
257  // qti flow_mat
258  $a_xml_writer->xmlStartTag("flow_mat");
259  $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
260  $a_xml_writer->xmlEndTag("flow_mat");
261  $a_xml_writer->xmlEndTag("itemfeedback");
262  }
263 
264  $a_xml_writer->xmlEndTag("item");
265  $a_xml_writer->xmlEndTag("questestinterop");
266 
267  $xml = $a_xml_writer->xmlDumpMem(false);
268  if (!$a_include_header) {
269  $pos = strpos($xml, "?>");
270  $xml = substr($xml, $pos + 2);
271  }
272  return $xml;
273  }
XML writer class.
addAnswerSpecificFeedback(ilXmlWriter $a_xml_writer, $answers)
addGeneralMetadata(ilXmlWriter $xmlwriter)
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 ...
xmlHeader()
Writes xml header public.
$xml
Definition: metadata.php:332
const TEXT_QUESTION_IDENTIFIER
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Field Documentation

◆ $object

assTextQuestionExport::$object

Definition at line 20 of file class.assTextQuestionExport.php.


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