ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $xml, 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  $attrs["maxchars"] = $this->object->getMaxNumOfChars();
124  }
125  $a_xml_writer->xmlStartTag("render_fib", $attrs);
126  $attrs = array(
127  "ident" => "A"
128  );
129  $a_xml_writer->xmlStartTag("response_label", $attrs);
130  $a_xml_writer->xmlEndTag("response_label");
131  $a_xml_writer->xmlEndTag("render_fib");
132 
133  $solution = $this->object->getSuggestedSolution(0);
134  if (count($solution)) {
135  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) {
136  $a_xml_writer->xmlStartTag("material");
137  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
138  if (strcmp($matches[1], "") != 0) {
139  $intlink = $solution["internal_link"];
140  }
141  $attrs = array(
142  "label" => "suggested_solution"
143  );
144  $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
145  $a_xml_writer->xmlEndTag("material");
146  }
147  }
148  $a_xml_writer->xmlEndTag("response_str");
149  $a_xml_writer->xmlEndTag("flow");
150  $a_xml_writer->xmlEndTag("presentation");
151 
152  // PART II: qti resprocessing
153  $attrs = array(
154  "scoremodel" => "HumanRater"
155  );
156  $a_xml_writer->xmlStartTag("resprocessing", $attrs);
157  $a_xml_writer->xmlStartTag("outcomes");
158  $attrs = array(
159  "varname" => "WritingScore",
160  "vartype" => "Integer",
161  "minvalue" => "0",
162  "maxvalue" => $this->object->getPoints()
163  );
164  $a_xml_writer->xmlStartTag("decvar", $attrs);
165  $a_xml_writer->xmlEndTag("decvar");
166  $a_xml_writer->xmlEndTag("outcomes");
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("varequal", $attrs, $this->object->getPoints());
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  $attrs = array(
207  "respident" => "points"
208  );
209  $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
210  $a_xml_writer->xmlEndTag("not");
211  $a_xml_writer->xmlEndTag("conditionvar");
212  // qti displayfeedback
213  $attrs = array(
214  "feedbacktype" => "Response",
215  "linkrefid" => "response_onenotcorrect"
216  );
217  $a_xml_writer->xmlElement("displayfeedback", $attrs);
218  $a_xml_writer->xmlEndTag("respcondition");
219  }
220  }
221 
222  $a_xml_writer->xmlStartTag("respcondition");
223  $a_xml_writer->xmlStartTag("conditionvar");
224  $a_xml_writer->xmlElement("other", null, "tutor_rated");
225  $a_xml_writer->xmlEndTag("conditionvar");
226  $a_xml_writer->xmlEndTag("respcondition");
227  $a_xml_writer->xmlEndTag("resprocessing");
228 
229  $this->addAnswerSpecificFeedback($a_xml_writer, $this->object->feedbackOBJ->getAnswerOptionsByAnswerIndex());
230 
231  if (strlen($feedback_allcorrect)) {
232  $attrs = array(
233  "ident" => "response_allcorrect",
234  "view" => "All"
235  );
236  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
237  // qti flow_mat
238  $a_xml_writer->xmlStartTag("flow_mat");
239  $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
240  $a_xml_writer->xmlEndTag("flow_mat");
241  $a_xml_writer->xmlEndTag("itemfeedback");
242  }
243  if (strlen($feedback_onenotcorrect)) {
244  $attrs = array(
245  "ident" => "response_onenotcorrect",
246  "view" => "All"
247  );
248  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
249  // qti flow_mat
250  $a_xml_writer->xmlStartTag("flow_mat");
251  $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
252  $a_xml_writer->xmlEndTag("flow_mat");
253  $a_xml_writer->xmlEndTag("itemfeedback");
254  }
255 
256  $a_xml_writer->xmlEndTag("item");
257  $a_xml_writer->xmlEndTag("questestinterop");
258 
259  $xml = $a_xml_writer->xmlDumpMem(false);
260  if (!$a_include_header) {
261  $pos = strpos($xml, "?>");
262  $xml = substr($xml, $pos + 2);
263  }
264  return $xml;
265  }
XML writer class.
addAnswerSpecificFeedback(ilXmlWriter $a_xml_writer, $answers)
addGeneralMetadata(ilXmlWriter $xmlwriter)
$xml
Definition: metadata.php:240
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: