ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 

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

References $duration, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addAnswerSpecificFeedback(), assQuestionExport\addGeneralMetadata(), array, object, TEXT_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, TEXT_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 
72  /*
73  $a_xml_writer->xmlStartTag("qtimetadatafield");
74  $a_xml_writer->xmlElement("fieldlabel", NULL, "keywords");
75  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getKeywords());
76  $a_xml_writer->xmlEndTag("qtimetadatafield");
77  */
78 
79  $a_xml_writer->xmlStartTag("qtimetadatafield");
80  $a_xml_writer->xmlElement("fieldlabel", NULL, "matchcondition");
81  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->matchcondition);
82  $a_xml_writer->xmlEndTag("qtimetadatafield");
83 
84  $a_xml_writer->xmlStartTag("qtimetadatafield");
85  $a_xml_writer->xmlElement("fieldlabel", NULL, "termscoring");
86  $scores = base64_encode(serialize($this->object->getAnswers()));
87  $a_xml_writer->xmlElement("fieldentry", NULL, $scores);
88  $a_xml_writer->xmlEndTag("qtimetadatafield");
89 
90  $a_xml_writer->xmlStartTag("qtimetadatafield");
91  $a_xml_writer->xmlElement("fieldlabel", NULL, "termrelation");
92  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getKeywordRelation());
93  $a_xml_writer->xmlEndTag("qtimetadatafield");
94 
95  $a_xml_writer->xmlStartTag("qtimetadatafield");
96  $a_xml_writer->xmlElement("fieldlabel", NULL, "specificfeedback");
97  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getKeywordRelation());
98  $a_xml_writer->xmlEndTag("qtimetadatafield");
99 
100  $a_xml_writer->xmlEndTag("qtimetadata");
101  $a_xml_writer->xmlEndTag("itemmetadata");
102 
103  // PART I: qti presentation
104  $attrs = array(
105  "label" => $this->object->getTitle()
106  );
107  $a_xml_writer->xmlStartTag("presentation", $attrs);
108  // add flow to presentation
109  $a_xml_writer->xmlStartTag("flow");
110  // add material with question text to presentation
111  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
112  // add information on response rendering
113  $attrs = array(
114  "ident" => "TEXT",
115  "rcardinality" => "Ordered"
116  );
117  $a_xml_writer->xmlStartTag("response_str", $attrs);
118  $attrs = array(
119  "fibtype" => "String",
120  "prompt" => "Box"
121  );
122  if ($this->object->getMaxNumOfChars() > 0)
123  {
124  $attrs["maxchars"] = $this->object->getMaxNumOfChars();
125  }
126  $a_xml_writer->xmlStartTag("render_fib", $attrs);
127  $attrs = array(
128  "ident" => "A"
129  );
130  $a_xml_writer->xmlStartTag("response_label", $attrs);
131  $a_xml_writer->xmlEndTag("response_label");
132  $a_xml_writer->xmlEndTag("render_fib");
133 
134  $solution = $this->object->getSuggestedSolution(0);
135  if (count($solution))
136  {
137  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches))
138  {
139  $a_xml_writer->xmlStartTag("material");
140  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
141  if (strcmp($matches[1], "") != 0)
142  {
143  $intlink = $solution["internal_link"];
144  }
145  $attrs = array(
146  "label" => "suggested_solution"
147  );
148  $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
149  $a_xml_writer->xmlEndTag("material");
150  }
151  }
152  $a_xml_writer->xmlEndTag("response_str");
153  $a_xml_writer->xmlEndTag("flow");
154  $a_xml_writer->xmlEndTag("presentation");
155 
156  // PART II: qti resprocessing
157  $attrs = array(
158  "scoremodel" => "HumanRater"
159  );
160  $a_xml_writer->xmlStartTag("resprocessing", $attrs);
161  $a_xml_writer->xmlStartTag("outcomes");
162  $attrs = array(
163  "varname" => "WritingScore",
164  "vartype" => "Integer",
165  "minvalue" => "0",
166  "maxvalue" => $this->object->getPoints()
167  );
168  $a_xml_writer->xmlStartTag("decvar", $attrs);
169  $a_xml_writer->xmlEndTag("decvar");
170  $a_xml_writer->xmlEndTag("outcomes");
171 
172  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
173  $this->object->getId(), true
174  );
175  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
176  $this->object->getId(), false
177  );
178  if (strlen($feedback_allcorrect . $feedback_onenotcorrect))
179  {
180  if (strlen($feedback_allcorrect))
181  {
182  $attrs = array(
183  "continue" => "Yes"
184  );
185  $a_xml_writer->xmlStartTag("respcondition", $attrs);
186  // qti conditionvar
187  $a_xml_writer->xmlStartTag("conditionvar");
188  $attrs = array(
189  "respident" => "points"
190  );
191  $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
192  $a_xml_writer->xmlEndTag("conditionvar");
193  // qti displayfeedback
194  $attrs = array(
195  "feedbacktype" => "Response",
196  "linkrefid" => "response_allcorrect"
197  );
198  $a_xml_writer->xmlElement("displayfeedback", $attrs);
199  $a_xml_writer->xmlEndTag("respcondition");
200  }
201 
202  if (strlen($feedback_onenotcorrect))
203  {
204  $attrs = array(
205  "continue" => "Yes"
206  );
207  $a_xml_writer->xmlStartTag("respcondition", $attrs);
208  // qti conditionvar
209  $a_xml_writer->xmlStartTag("conditionvar");
210  $a_xml_writer->xmlStartTag("not");
211  $attrs = array(
212  "respident" => "points"
213  );
214  $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
215  $a_xml_writer->xmlEndTag("not");
216  $a_xml_writer->xmlEndTag("conditionvar");
217  // qti displayfeedback
218  $attrs = array(
219  "feedbacktype" => "Response",
220  "linkrefid" => "response_onenotcorrect"
221  );
222  $a_xml_writer->xmlElement("displayfeedback", $attrs);
223  $a_xml_writer->xmlEndTag("respcondition");
224  }
225  }
226 
227  $a_xml_writer->xmlStartTag("respcondition");
228  $a_xml_writer->xmlStartTag("conditionvar");
229  $a_xml_writer->xmlElement("other", NULL, "tutor_rated");
230  $a_xml_writer->xmlEndTag("conditionvar");
231  $a_xml_writer->xmlEndTag("respcondition");
232  $a_xml_writer->xmlEndTag("resprocessing");
233 
234  $this->addAnswerSpecificFeedback($a_xml_writer, $this->object->feedbackOBJ->getAnswerOptionsByAnswerIndex());
235 
236  if (strlen($feedback_allcorrect))
237  {
238  $attrs = array(
239  "ident" => "response_allcorrect",
240  "view" => "All"
241  );
242  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
243  // qti flow_mat
244  $a_xml_writer->xmlStartTag("flow_mat");
245  $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
246  $a_xml_writer->xmlEndTag("flow_mat");
247  $a_xml_writer->xmlEndTag("itemfeedback");
248  }
249  if (strlen($feedback_onenotcorrect))
250  {
251  $attrs = array(
252  "ident" => "response_onenotcorrect",
253  "view" => "All"
254  );
255  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
256  // qti flow_mat
257  $a_xml_writer->xmlStartTag("flow_mat");
258  $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
259  $a_xml_writer->xmlEndTag("flow_mat");
260  $a_xml_writer->xmlEndTag("itemfeedback");
261  }
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  {
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)
xmlHeader()
Writes xml header public.
const TEXT_QUESTION_IDENTIFIER
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: