ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
4include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
5
16{
24 public $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 $linkrefid = "response_$index";
44 $attrs = array(
45 "ident" => $linkrefid,
46 "view" => "All"
47 );
48 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
49 // qti flow_mat
50 $a_xml_writer->xmlStartTag("flow_mat");
51 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
52 $this->object->getId(),
53 0,
54 $index
55 );
56 $this->object->addQTIMaterial($a_xml_writer, $fb);
57 $a_xml_writer->xmlEndTag("flow_mat");
58 $a_xml_writer->xmlEndTag("itemfeedback");
59 }
60 }
61
65 protected function addGenericFeedback(ilXmlWriter $a_xml_writer)
66 {
67 $this->exportFeedbackOnly($a_xml_writer);
68 }
69
70 public function exportFeedbackOnly($a_xml_writer)
71 {
72 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
73 $this->object->getId(),
74 true
75 );
76 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
77 $this->object->getId(),
78 false
79 );
80 if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
81 $a_xml_writer->xmlStartTag("resprocessing");
82 $a_xml_writer->xmlStartTag("outcomes");
83 $a_xml_writer->xmlStartTag("decvar");
84 $a_xml_writer->xmlEndTag("decvar");
85 $a_xml_writer->xmlEndTag("outcomes");
86
87 if (strlen($feedback_allcorrect)) {
88 $attrs = array(
89 "continue" => "Yes"
90 );
91 $a_xml_writer->xmlStartTag("respcondition", $attrs);
92 // qti conditionvar
93 $a_xml_writer->xmlStartTag("conditionvar");
94 $attrs = array(
95 "respident" => "points"
96 );
97 $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
98 $a_xml_writer->xmlEndTag("conditionvar");
99 // qti displayfeedback
100 $attrs = array(
101 "feedbacktype" => "Response",
102 "linkrefid" => "response_allcorrect"
103 );
104 $a_xml_writer->xmlElement("displayfeedback", $attrs);
105 $a_xml_writer->xmlEndTag("respcondition");
106 }
107
108 if (strlen($feedback_onenotcorrect)) {
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 $attrs = array(
135 "ident" => "response_allcorrect",
136 "view" => "All"
137 );
138 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
139 // qti flow_mat
140 $a_xml_writer->xmlStartTag("flow_mat");
141 $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
142 $a_xml_writer->xmlEndTag("flow_mat");
143 $a_xml_writer->xmlEndTag("itemfeedback");
144 }
145 if (strlen($feedback_onenotcorrect)) {
146 $attrs = array(
147 "ident" => "response_onenotcorrect",
148 "view" => "All"
149 );
150 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
151 // qti flow_mat
152 $a_xml_writer->xmlStartTag("flow_mat");
153 $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
154 $a_xml_writer->xmlEndTag("flow_mat");
155 $a_xml_writer->xmlEndTag("itemfeedback");
156 }
157 }
158
168 public function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
169 {
170 }
171
182 final protected function addQtiMetaDataField(ilXmlWriter $a_xml_writer, $fieldLabel, $fieldValue)
183 {
184 $a_xml_writer->xmlStartTag("qtimetadatafield");
185 $a_xml_writer->xmlElement("fieldlabel", null, $fieldLabel);
186 $a_xml_writer->xmlElement("fieldentry", null, $fieldValue);
187 $a_xml_writer->xmlEndTag("qtimetadatafield");
188 }
189
198 final protected function addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
199 {
200 $this->addQtiMetaDataField(
201 $a_xml_writer,
202 'additional_cont_edit_mode',
203 $this->object->getAdditionalContentEditingMode()
204 );
205 }
206
210 protected function addGeneralMetadata(ilXmlWriter $xmlwriter)
211 {
212 $this->addQtiMetaDataField($xmlwriter, 'externalId', $this->object->getExternalId());
213
214 $this->addQtiMetaDataField(
215 $xmlwriter,
216 'ilias_lifecycle',
217 $this->object->getLifecycle()->getIdentifier()
218 );
219
220 $this->addQtiMetaDataField(
221 $xmlwriter,
222 'lifecycle',
223 $this->object->getLifecycle()->getMappedLomLifecycle()
224 );
225 }
226}
An exception for terminatinating execution or to throw for unit testing.
Class for question exports.
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 ...
__construct($a_object)
assQuestionExport constructor
addAnswerSpecificFeedback(ilXmlWriter $a_xml_writer, $answers)
addGenericFeedback(ilXmlWriter $a_xml_writer)
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
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.
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$index
Definition: metadata.php:128