ILIAS  release_8 Revision v8.24
class.assQuestionExport.php
Go to the documentation of this file.
1<?php
18include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
19
30{
34 public $object;
35
42 public function __construct($a_object)
43 {
44 $this->object = $a_object;
45 }
46
50 protected function addAnswerSpecificFeedback(ilXmlWriter $a_xml_writer, $answers): void
51 {
52 foreach ($answers as $index => $answer) {
53 $linkrefid = "response_$index";
54 $attrs = array(
55 "ident" => $linkrefid,
56 "view" => "All"
57 );
58 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
59 // qti flow_mat
60 $a_xml_writer->xmlStartTag("flow_mat");
61 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
62 $this->object->getId(),
63 0,
64 $index
65 );
66 $this->object->addQTIMaterial($a_xml_writer, $fb);
67 $a_xml_writer->xmlEndTag("flow_mat");
68 $a_xml_writer->xmlEndTag("itemfeedback");
69 }
70 }
71
75 protected function addGenericFeedback(ilXmlWriter $a_xml_writer): void
76 {
77 $this->exportFeedbackOnly($a_xml_writer);
78 }
79
80 public function exportFeedbackOnly($a_xml_writer): void
81 {
82 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
83 $this->object->getId(),
84 true
85 );
86 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
87 $this->object->getId(),
88 false
89 );
90 if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
91 $a_xml_writer->xmlStartTag("resprocessing");
92 $a_xml_writer->xmlStartTag("outcomes");
93 $a_xml_writer->xmlStartTag("decvar");
94 $a_xml_writer->xmlEndTag("decvar");
95 $a_xml_writer->xmlEndTag("outcomes");
96
97 if (strlen($feedback_allcorrect)) {
98 $attrs = array(
99 "continue" => "Yes"
100 );
101 $a_xml_writer->xmlStartTag("respcondition", $attrs);
102 // qti conditionvar
103 $a_xml_writer->xmlStartTag("conditionvar");
104 $attrs = array(
105 "respident" => "points"
106 );
107 $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
108 $a_xml_writer->xmlEndTag("conditionvar");
109 // qti displayfeedback
110 $attrs = array(
111 "feedbacktype" => "Response",
112 "linkrefid" => "response_allcorrect"
113 );
114 $a_xml_writer->xmlElement("displayfeedback", $attrs);
115 $a_xml_writer->xmlEndTag("respcondition");
116 }
117
118 if (strlen($feedback_onenotcorrect)) {
119 $attrs = array(
120 "continue" => "Yes"
121 );
122 $a_xml_writer->xmlStartTag("respcondition", $attrs);
123 // qti conditionvar
124 $a_xml_writer->xmlStartTag("conditionvar");
125 $a_xml_writer->xmlStartTag("not");
126 $attrs = array(
127 "respident" => "points"
128 );
129 $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
130 $a_xml_writer->xmlEndTag("not");
131 $a_xml_writer->xmlEndTag("conditionvar");
132 // qti displayfeedback
133 $attrs = array(
134 "feedbacktype" => "Response",
135 "linkrefid" => "response_onenotcorrect"
136 );
137 $a_xml_writer->xmlElement("displayfeedback", $attrs);
138 $a_xml_writer->xmlEndTag("respcondition");
139 }
140 $a_xml_writer->xmlEndTag("resprocessing");
141 }
142
143 if (strlen($feedback_allcorrect)) {
144 $attrs = array(
145 "ident" => "response_allcorrect",
146 "view" => "All"
147 );
148 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
149 // qti flow_mat
150 $a_xml_writer->xmlStartTag("flow_mat");
151 $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
152 $a_xml_writer->xmlEndTag("flow_mat");
153 $a_xml_writer->xmlEndTag("itemfeedback");
154 }
155 if (strlen($feedback_onenotcorrect)) {
156 $attrs = array(
157 "ident" => "response_onenotcorrect",
158 "view" => "All"
159 );
160 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
161 // qti flow_mat
162 $a_xml_writer->xmlStartTag("flow_mat");
163 $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
164 $a_xml_writer->xmlEndTag("flow_mat");
165 $a_xml_writer->xmlEndTag("itemfeedback");
166 }
167 }
168
174 public function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false): string
175 {
176 return '';
177 }
178
189 final protected function addQtiMetaDataField(ilXmlWriter $a_xml_writer, $fieldLabel, $fieldValue): void
190 {
191 $a_xml_writer->xmlStartTag("qtimetadatafield");
192 $a_xml_writer->xmlElement("fieldlabel", null, $fieldLabel);
193 $a_xml_writer->xmlElement("fieldentry", null, $fieldValue);
194 $a_xml_writer->xmlEndTag("qtimetadatafield");
195 }
196
205 final protected function addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer): void
206 {
207 $this->addQtiMetaDataField(
208 $a_xml_writer,
209 'additional_cont_edit_mode',
210 $this->object->getAdditionalContentEditingMode()
211 );
212 }
213
217 protected function addGeneralMetadata(ilXmlWriter $xmlwriter): void
218 {
219 $this->addQtiMetaDataField($xmlwriter, 'externalId', $this->object->getExternalId());
220
221 $this->addQtiMetaDataField(
222 $xmlwriter,
223 'ilias_lifecycle',
224 $this->object->getLifecycle()->getIdentifier()
225 );
226
227 $this->addQtiMetaDataField(
228 $xmlwriter,
229 'lifecycle',
230 $this->object->getLifecycle()->getMappedLomLifecycle()
231 );
232 }
233
234 public const ITEM_SOLUTIONHINT = 'solutionhint';
235
236 protected function addSolutionHints(ilXmlWriter $writer): ilXmlWriter
237 {
238 $question_id = (int) $this->object->getId();
239 $list = ilAssQuestionHintList::getListByQuestionId($question_id);
240
241 foreach ($list as $hint) {
242 $attrs = [
243 'index' => $hint->getIndex(),
244 'points' => $hint->getPoints()
245 ];
246 $data = $hint->getText();
247 $writer->xmlElement(self::ITEM_SOLUTIONHINT, $attrs, $data);
248 }
249 return $writer;
250 }
251}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
addSolutionHints(ilXmlWriter $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 Returns a QTI xml representation of the question and...
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
$index
Definition: metadata.php:145