ILIAS  release_7 Revision v7.30-3-g800a261c036
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{
20 public $object;
21
28 public function __construct($a_object)
29 {
30 $this->object = $a_object;
31 }
32
36 protected function addAnswerSpecificFeedback(ilXmlWriter $a_xml_writer, $answers)
37 {
38 foreach ($answers as $index => $answer) {
39 $linkrefid = "response_$index";
40 $attrs = array(
41 "ident" => $linkrefid,
42 "view" => "All"
43 );
44 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
45 // qti flow_mat
46 $a_xml_writer->xmlStartTag("flow_mat");
47 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
48 $this->object->getId(),
49 0,
50 $index
51 );
52 $this->object->addQTIMaterial($a_xml_writer, $fb);
53 $a_xml_writer->xmlEndTag("flow_mat");
54 $a_xml_writer->xmlEndTag("itemfeedback");
55 }
56 }
57
61 protected function addGenericFeedback(ilXmlWriter $a_xml_writer)
62 {
63 $this->exportFeedbackOnly($a_xml_writer);
64 }
65
66 public function exportFeedbackOnly($a_xml_writer)
67 {
68 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
69 $this->object->getId(),
70 true
71 );
72 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
73 $this->object->getId(),
74 false
75 );
76 if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
77 $a_xml_writer->xmlStartTag("resprocessing");
78 $a_xml_writer->xmlStartTag("outcomes");
79 $a_xml_writer->xmlStartTag("decvar");
80 $a_xml_writer->xmlEndTag("decvar");
81 $a_xml_writer->xmlEndTag("outcomes");
82
83 if (strlen($feedback_allcorrect)) {
84 $attrs = array(
85 "continue" => "Yes"
86 );
87 $a_xml_writer->xmlStartTag("respcondition", $attrs);
88 // qti conditionvar
89 $a_xml_writer->xmlStartTag("conditionvar");
90 $attrs = array(
91 "respident" => "points"
92 );
93 $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
94 $a_xml_writer->xmlEndTag("conditionvar");
95 // qti displayfeedback
96 $attrs = array(
97 "feedbacktype" => "Response",
98 "linkrefid" => "response_allcorrect"
99 );
100 $a_xml_writer->xmlElement("displayfeedback", $attrs);
101 $a_xml_writer->xmlEndTag("respcondition");
102 }
103
104 if (strlen($feedback_onenotcorrect)) {
105 $attrs = array(
106 "continue" => "Yes"
107 );
108 $a_xml_writer->xmlStartTag("respcondition", $attrs);
109 // qti conditionvar
110 $a_xml_writer->xmlStartTag("conditionvar");
111 $a_xml_writer->xmlStartTag("not");
112 $attrs = array(
113 "respident" => "points"
114 );
115 $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
116 $a_xml_writer->xmlEndTag("not");
117 $a_xml_writer->xmlEndTag("conditionvar");
118 // qti displayfeedback
119 $attrs = array(
120 "feedbacktype" => "Response",
121 "linkrefid" => "response_onenotcorrect"
122 );
123 $a_xml_writer->xmlElement("displayfeedback", $attrs);
124 $a_xml_writer->xmlEndTag("respcondition");
125 }
126 $a_xml_writer->xmlEndTag("resprocessing");
127 }
128
129 if (strlen($feedback_allcorrect)) {
130 $attrs = array(
131 "ident" => "response_allcorrect",
132 "view" => "All"
133 );
134 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
135 // qti flow_mat
136 $a_xml_writer->xmlStartTag("flow_mat");
137 $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
138 $a_xml_writer->xmlEndTag("flow_mat");
139 $a_xml_writer->xmlEndTag("itemfeedback");
140 }
141 if (strlen($feedback_onenotcorrect)) {
142 $attrs = array(
143 "ident" => "response_onenotcorrect",
144 "view" => "All"
145 );
146 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
147 // qti flow_mat
148 $a_xml_writer->xmlStartTag("flow_mat");
149 $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
150 $a_xml_writer->xmlEndTag("flow_mat");
151 $a_xml_writer->xmlEndTag("itemfeedback");
152 }
153 }
154
164 public function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
165 {
166 }
167
178 final protected function addQtiMetaDataField(ilXmlWriter $a_xml_writer, $fieldLabel, $fieldValue)
179 {
180 $a_xml_writer->xmlStartTag("qtimetadatafield");
181 $a_xml_writer->xmlElement("fieldlabel", null, $fieldLabel);
182 $a_xml_writer->xmlElement("fieldentry", null, $fieldValue);
183 $a_xml_writer->xmlEndTag("qtimetadatafield");
184 }
185
194 final protected function addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
195 {
196 $this->addQtiMetaDataField(
197 $a_xml_writer,
198 'additional_cont_edit_mode',
199 $this->object->getAdditionalContentEditingMode()
200 );
201 }
202
206 protected function addGeneralMetadata(ilXmlWriter $xmlwriter)
207 {
208 $this->addQtiMetaDataField($xmlwriter, 'externalId', $this->object->getExternalId());
209
210 $this->addQtiMetaDataField(
211 $xmlwriter,
212 'ilias_lifecycle',
213 $this->object->getLifecycle()->getIdentifier()
214 );
215
216 $this->addQtiMetaDataField(
217 $xmlwriter,
218 'lifecycle',
219 $this->object->getLifecycle()->getMappedLomLifecycle()
220 );
221 }
222
223 const ITEM_SOLUTIONHINT = 'solutionhint';
224
225 protected function addSolutionHints(ilXmlWriter $writer) : ilXmlWriter
226 {
227 $question_id = (int) $this->object->getId();
228 $list = ilAssQuestionHintList::getListByQuestionId($question_id);
229
230 foreach ($list as $hint) {
231 $attrs = [
232 'index' => $hint->getIndex(),
233 'points' => $hint->getPoints()
234 ];
235 $data = $hint->getText();
236 $writer->xmlElement(self::ITEM_SOLUTIONHINT, $attrs, $data);
237 }
238 return $writer;
239 }
240}
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)
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.
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
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
$data
Definition: storeScorm.php:23