ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.assQuestionExport.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
5 
16 {
24  var $object;
25 
32  public function __construct($a_object)
33  {
34  $this->object = $a_object;
35  }
36 
40  protected function addAnswerSpecificFeedback(ilXmlWriter $a_xml_writer, $answers)
41  {
42  foreach ($answers as $index => $answer)
43  {
44  $linkrefid = "response_$index";
45  $attrs = array(
46  "ident" => $linkrefid,
47  "view" => "All"
48  );
49  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
50  // qti flow_mat
51  $a_xml_writer->xmlStartTag("flow_mat");
52  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
53  $this->object->getId(), $index
54  );
55  $this->object->addQTIMaterial($a_xml_writer, $fb);
56  $a_xml_writer->xmlEndTag("flow_mat");
57  $a_xml_writer->xmlEndTag("itemfeedback");
58  }
59  }
60 
64  protected function addGenericFeedback(ilXmlWriter $a_xml_writer)
65  {
66  $this->exportFeedbackOnly($a_xml_writer);
67  }
68 
69  function exportFeedbackOnly($a_xml_writer)
70  {
71  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
72  $this->object->getId(), true
73  );
74  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
75  $this->object->getId(), false
76  );
77  if (strlen($feedback_allcorrect . $feedback_onenotcorrect))
78  {
79  $a_xml_writer->xmlStartTag("resprocessing");
80  $a_xml_writer->xmlStartTag("outcomes");
81  $a_xml_writer->xmlStartTag("decvar");
82  $a_xml_writer->xmlEndTag("decvar");
83  $a_xml_writer->xmlEndTag("outcomes");
84 
85  if (strlen($feedback_allcorrect))
86  {
87  $attrs = array(
88  "continue" => "Yes"
89  );
90  $a_xml_writer->xmlStartTag("respcondition", $attrs);
91  // qti conditionvar
92  $a_xml_writer->xmlStartTag("conditionvar");
93  $attrs = array(
94  "respident" => "points"
95  );
96  $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
97  $a_xml_writer->xmlEndTag("conditionvar");
98  // qti displayfeedback
99  $attrs = array(
100  "feedbacktype" => "Response",
101  "linkrefid" => "response_allcorrect"
102  );
103  $a_xml_writer->xmlElement("displayfeedback", $attrs);
104  $a_xml_writer->xmlEndTag("respcondition");
105  }
106 
107  if (strlen($feedback_onenotcorrect))
108  {
109  $attrs = array(
110  "continue" => "Yes"
111  );
112  $a_xml_writer->xmlStartTag("respcondition", $attrs);
113  // qti conditionvar
114  $a_xml_writer->xmlStartTag("conditionvar");
115  $a_xml_writer->xmlStartTag("not");
116  $attrs = array(
117  "respident" => "points"
118  );
119  $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
120  $a_xml_writer->xmlEndTag("not");
121  $a_xml_writer->xmlEndTag("conditionvar");
122  // qti displayfeedback
123  $attrs = array(
124  "feedbacktype" => "Response",
125  "linkrefid" => "response_onenotcorrect"
126  );
127  $a_xml_writer->xmlElement("displayfeedback", $attrs);
128  $a_xml_writer->xmlEndTag("respcondition");
129  }
130  $a_xml_writer->xmlEndTag("resprocessing");
131  }
132 
133  if (strlen($feedback_allcorrect))
134  {
135  $attrs = array(
136  "ident" => "response_allcorrect",
137  "view" => "All"
138  );
139  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
140  // qti flow_mat
141  $a_xml_writer->xmlStartTag("flow_mat");
142  $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
143  $a_xml_writer->xmlEndTag("flow_mat");
144  $a_xml_writer->xmlEndTag("itemfeedback");
145  }
146  if (strlen($feedback_onenotcorrect))
147  {
148  $attrs = array(
149  "ident" => "response_onenotcorrect",
150  "view" => "All"
151  );
152  $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
153  // qti flow_mat
154  $a_xml_writer->xmlStartTag("flow_mat");
155  $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
156  $a_xml_writer->xmlEndTag("flow_mat");
157  $a_xml_writer->xmlEndTag("itemfeedback");
158  }
159  }
160 
170  function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
171  {
172  }
173 
184  final protected function addQtiMetaDataField(ilXmlWriter $a_xml_writer, $fieldLabel, $fieldValue)
185  {
186  $a_xml_writer->xmlStartTag("qtimetadatafield");
187  $a_xml_writer->xmlElement("fieldlabel", NULL, $fieldLabel);
188  $a_xml_writer->xmlElement("fieldentry", NULL, $fieldValue);
189  $a_xml_writer->xmlEndTag("qtimetadatafield");
190  }
191 
200  final protected function addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
201  {
202  $this->addQtiMetaDataField(
203  $a_xml_writer, 'additional_cont_edit_mode', $this->object->getAdditionalContentEditingMode()
204  );
205  }
206 
210  protected function addGeneralMetadata(ilXmlWriter $xmlwriter)
211  {
212  $this->addQtiMetaDataField($xmlwriter, 'externalId', $this->object->getExternalId());
213  }
214 }
215 
216 ?>
__construct($a_object)
assQuestionExport constructor
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
exportFeedbackOnly($a_xml_writer)
XML writer class.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
Class for question exports.
addAnswerSpecificFeedback(ilXmlWriter $a_xml_writer, $answers)
addGeneralMetadata(ilXmlWriter $xmlwriter)
xmlEndTag($tag)
Writes an endtag.
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 ...
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...
addGenericFeedback(ilXmlWriter $a_xml_writer)
Create new PHPExcel object
obj_idprivate
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.