25 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false): string
28 $ilias = $DIC[
'ilias'];
30 $correct_answers = $this->
object->getCorrectAnswers();
31 $answers = $this->
object->getAnswers();
36 $xml->xmlStartTag(
"questestinterop");
39 "ident" =>
"il_" .
IL_INST_ID .
"_qst_" . $this->
object->getId(),
40 "title" => $this->
object->getTitle(),
41 "maxattempts" => $this->
object->getNrOfTries()
43 $xml->xmlStartTag(
"item", $attrs);
45 $xml->xmlElement(
"qticomment",
null, $this->
object->getComment());
46 $xml->xmlStartTag(
"itemmetadata");
47 $xml->xmlStartTag(
"qtimetadata");
48 $xml->xmlStartTag(
"qtimetadatafield");
49 $xml->xmlElement(
"fieldlabel",
null,
"ILIAS_VERSION");
50 $xml->xmlElement(
"fieldentry",
null, $ilias->getSetting(
"ilias_version"));
51 $xml->xmlEndTag(
"qtimetadatafield");
52 $xml->xmlStartTag(
"qtimetadatafield");
53 $xml->xmlElement(
"fieldlabel",
null,
"QUESTIONTYPE");
54 $xml->xmlElement(
"fieldentry",
null, $this->
object->getQuestionType());
55 $xml->xmlEndTag(
"qtimetadatafield");
56 $xml->xmlStartTag(
"qtimetadatafield");
57 $xml->xmlElement(
"fieldlabel",
null,
"AUTHOR");
58 $xml->xmlElement(
"fieldentry",
null, $this->
object->getAuthor());
59 $xml->xmlEndTag(
"qtimetadatafield");
61 $xml->xmlStartTag(
"qtimetadatafield");
62 $xml->xmlElement(
"fieldlabel",
null,
"minAutoCompleteLength");
63 $xml->xmlElement(
"fieldentry",
null, $this->
object->getMinAutoComplete());
64 $xml->xmlEndTag(
"qtimetadatafield");
65 $xml->xmlStartTag(
"qtimetadatafield");
66 $xml->xmlElement(
"fieldlabel",
null,
"identical_scoring");
67 $xml->xmlElement(
"fieldentry",
null, $this->
object->getIdenticalScoring());
68 $xml->xmlEndTag(
"qtimetadatafield");
70 $xml->xmlStartTag(
"qtimetadatafield");
71 $xml->xmlElement(
"fieldlabel",
null,
"gapTypes");
73 if (is_array($correct_answers)) {
74 foreach ($correct_answers as $key => $value) {
75 $gap_types[] = $value[2];
78 $xml->xmlElement(
"fieldentry",
null, json_encode($gap_types));
79 $xml->xmlEndTag(
"qtimetadatafield");
85 $xml->xmlStartTag(
"qtimetadatafield");
86 $xml->xmlElement(
"fieldlabel",
null,
"feedback_setting");
87 $xml->xmlElement(
"fieldentry",
null, $this->
object->getSpecificFeedbackSetting());
88 $xml->xmlEndTag(
"qtimetadatafield");
90 $xml->xmlEndTag(
"qtimetadata");
91 $xml->xmlEndTag(
"itemmetadata");
92 $xml->xmlStartTag(
"presentation");
94 $xml->xmlStartTag(
"flow");
100 foreach ($answers as $key => $values) {
103 "ident" =>
"LongMenu_" . $real_id,
104 "rcardinality" =>
"Single" 106 $xml->xmlStartTag(
"response_str", $attrs);
107 foreach ($values as $index => $value) {
108 $xml->xmlStartTag(
"response_label", [
'ident' => $index]);
109 $xml->xmlStartTag(
"material");
110 $xml->xmlElement(
"fieldentry",
null, $value);
111 $xml->xmlEndTag(
"material");
112 $xml->xmlEndTag(
"response_label");
114 $xml->xmlEndTag(
"response_str");
116 $xml->xmlEndTag(
"flow");
118 $xml->xmlEndTag(
"presentation");
120 $xml->xmlStartTag(
"resprocessing");
121 $xml->xmlStartTag(
"outcomes");
122 $xml->xmlElement(
"decvar");
123 $xml->xmlEndTag(
"outcomes");
124 foreach ($answers as $key => $values) {
126 foreach ($values as $index => $value) {
127 $xml->xmlStartTag(
"respcondition", [
'continue' =>
'Yes']);
128 $xml->xmlStartTag(
"conditionvar");
129 $xml->xmlElement(
"varequal", [
'respident' =>
"LongMenu_" . $real_id], $value);
130 $xml->xmlEndTag(
"conditionvar");
132 if (in_array($value, $correct_answers[$key][0])) {
133 $xml->xmlElement(
"setvar", [
'action' =>
"Add"], $correct_answers[$key][1]);
135 $xml->xmlElement(
"setvar", [
'action' =>
"Add"], 0);
137 $xml->xmlElement(
"displayfeedback", [
'feedbacktype' =>
"Response",
'linkrefid' => $key .
'_Response_' . $index]);
138 $xml->xmlEndTag(
"respcondition");
141 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
145 if (strlen($feedback_allcorrect) > 0) {
146 $xml->xmlStartTag(
"respcondition", [
'continue' =>
'Yes']);
147 $xml->xmlStartTag(
"conditionvar");
148 foreach ($correct_answers as $key => $values) {
151 $xml->xmlStartTag(
"and");
154 foreach ($values[0] as $index => $value) {
156 $xml->xmlStartTag(
"or");
158 $xml->xmlElement(
"varequal", [
'respident' =>
"LongMenu_" . $real_id], $value);
160 $xml->xmlEndTag(
"or");
164 $xml->xmlEndTag(
"and");
167 $xml->xmlEndTag(
"conditionvar");
168 $xml->xmlElement(
"displayfeedback", [
'feedbacktype' =>
"Response",
'linkrefid' =>
'response_allcorrect']);
169 $xml->xmlEndTag(
"respcondition");
172 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
176 if (strlen($feedback_onenotcorrect)) {
177 $xml->xmlStartTag(
"respcondition", [
'continue' =>
'Yes']);
178 $xml->xmlStartTag(
"conditionvar");
179 $xml->xmlStartTag(
"not");
180 foreach ($correct_answers as $key => $values) {
183 $xml->xmlStartTag(
"and");
186 foreach ($values[0] as $index => $value) {
188 $xml->xmlStartTag(
"or");
190 $xml->xmlElement(
"varequal", [
'respident' =>
"LongMenu_" . $real_id], $value);
192 $xml->xmlEndTag(
"or");
196 $xml->xmlEndTag(
"and");
199 $xml->xmlEndTag(
"not");
200 $xml->xmlEndTag(
"conditionvar");
201 $xml->xmlElement(
"displayfeedback", [
'feedbacktype' =>
"Response",
'linkrefid' =>
'response_onenotcorrect']);
202 $xml->xmlEndTag(
"respcondition");
205 $xml->xmlEndTag(
"resprocessing");
210 for ($i = 0; $i <
sizeof($correct_answers); $i++) {
215 $xml->xmlStartTag(
"itemfeedback", $attrs);
217 $xml->xmlStartTag(
"flow_mat");
218 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
224 $xml->xmlEndTag(
"flow_mat");
225 $xml->xmlEndTag(
"itemfeedback");
228 if (strlen($feedback_allcorrect) > 0) {
229 $xml->xmlStartTag(
"itemfeedback", [
'ident' =>
'response_allcorrect',
'view' =>
'All']);
230 $xml->xmlStartTag(
"flow_mat");
231 $xml->xmlStartTag(
"material");
232 $xml->xmlElement(
"mattext", [
'texttype' =>
'text/xhtml'], $feedback_allcorrect);
233 $xml->xmlEndTag(
"material");
234 $xml->xmlEndTag(
"flow_mat");
235 $xml->xmlEndTag(
"itemfeedback");
237 if (strlen($feedback_onenotcorrect) > 0) {
238 $xml->xmlStartTag(
"itemfeedback", [
'ident' =>
'response_onenotcorrect',
'view' =>
'All']);
239 $xml->xmlStartTag(
"flow_mat");
240 $xml->xmlStartTag(
"material");
241 $xml->xmlElement(
"mattext", [
'texttype' =>
'text/xhtml'], $feedback_onenotcorrect);
242 $xml->xmlEndTag(
"material");
243 $xml->xmlEndTag(
"flow_mat");
244 $xml->xmlEndTag(
"itemfeedback");
249 $xml->xmlEndTag(
"item");
250 $xml->xmlEndTag(
"questestinterop");
252 $xml = $xml->xmlDumpMem(
false);
253 if (!$a_include_header) {
254 $pos = strpos($xml,
"?>");
255 $xml = substr($xml, $pos + 2);
addQTIMaterial(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
addSuggestedSolution(ilXmlWriter $writer)
addSolutionHints(ilXmlWriter $writer)