ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $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 public function exportFeedbackOnly($a_xml_writer)
70 {
71 $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
72 $this->object->getId(),
73 true
74 );
75 $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
76 $this->object->getId(),
77 false
78 );
79 if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
80 $a_xml_writer->xmlStartTag("resprocessing");
81 $a_xml_writer->xmlStartTag("outcomes");
82 $a_xml_writer->xmlStartTag("decvar");
83 $a_xml_writer->xmlEndTag("decvar");
84 $a_xml_writer->xmlEndTag("outcomes");
85
86 if (strlen($feedback_allcorrect)) {
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 $attrs = array(
109 "continue" => "Yes"
110 );
111 $a_xml_writer->xmlStartTag("respcondition", $attrs);
112 // qti conditionvar
113 $a_xml_writer->xmlStartTag("conditionvar");
114 $a_xml_writer->xmlStartTag("not");
115 $attrs = array(
116 "respident" => "points"
117 );
118 $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
119 $a_xml_writer->xmlEndTag("not");
120 $a_xml_writer->xmlEndTag("conditionvar");
121 // qti displayfeedback
122 $attrs = array(
123 "feedbacktype" => "Response",
124 "linkrefid" => "response_onenotcorrect"
125 );
126 $a_xml_writer->xmlElement("displayfeedback", $attrs);
127 $a_xml_writer->xmlEndTag("respcondition");
128 }
129 $a_xml_writer->xmlEndTag("resprocessing");
130 }
131
132 if (strlen($feedback_allcorrect)) {
133 $attrs = array(
134 "ident" => "response_allcorrect",
135 "view" => "All"
136 );
137 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
138 // qti flow_mat
139 $a_xml_writer->xmlStartTag("flow_mat");
140 $this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
141 $a_xml_writer->xmlEndTag("flow_mat");
142 $a_xml_writer->xmlEndTag("itemfeedback");
143 }
144 if (strlen($feedback_onenotcorrect)) {
145 $attrs = array(
146 "ident" => "response_onenotcorrect",
147 "view" => "All"
148 );
149 $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
150 // qti flow_mat
151 $a_xml_writer->xmlStartTag("flow_mat");
152 $this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
153 $a_xml_writer->xmlEndTag("flow_mat");
154 $a_xml_writer->xmlEndTag("itemfeedback");
155 }
156 }
157
167 public function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
168 {
169 }
170
181 final protected function addQtiMetaDataField(ilXmlWriter $a_xml_writer, $fieldLabel, $fieldValue)
182 {
183 $a_xml_writer->xmlStartTag("qtimetadatafield");
184 $a_xml_writer->xmlElement("fieldlabel", null, $fieldLabel);
185 $a_xml_writer->xmlElement("fieldentry", null, $fieldValue);
186 $a_xml_writer->xmlEndTag("qtimetadatafield");
187 }
188
197 final protected function addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
198 {
199 $this->addQtiMetaDataField(
200 $a_xml_writer,
201 'additional_cont_edit_mode',
202 $this->object->getAdditionalContentEditingMode()
203 );
204 }
205
209 protected function addGeneralMetadata(ilXmlWriter $xmlwriter)
210 {
211 $this->addQtiMetaDataField($xmlwriter, 'externalId', $this->object->getExternalId());
212 }
213}
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:60