2 require_once
'Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php';
10 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
14 $correct_answers = $this->
object->getCorrectAnswers();
15 $answers = $this->
object->getAnswers();
17 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
21 $xml->xmlStartTag(
"questestinterop");
24 "ident" =>
"il_".IL_INST_ID.
"_qst_".$this->object->getId(),
25 "title" => $this->
object->getTitle(),
26 "maxattempts" => $this->
object->getNrOfTries()
28 $xml->xmlStartTag(
"item", $attrs);
29 $xml->xmlElement(
"qticomment", NULL, $this->
object->getComment());
31 $workingtime = $this->
object->getEstimatedWorkingTime();
32 $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
33 $xml->xmlElement(
"duration", NULL,
$duration);
35 $xml->xmlStartTag(
"itemmetadata");
36 $xml->xmlStartTag(
"qtimetadata");
37 $xml->xmlStartTag(
"qtimetadatafield");
38 $xml->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
39 $xml->xmlElement(
"fieldentry", NULL, $ilias->getSetting(
"ilias_version"));
40 $xml->xmlEndTag(
"qtimetadatafield");
41 $xml->xmlStartTag(
"qtimetadatafield");
42 $xml->xmlElement(
"fieldlabel", NULL,
"QUESTIONTYPE");
44 $xml->xmlEndTag(
"qtimetadatafield");
45 $xml->xmlStartTag(
"qtimetadatafield");
46 $xml->xmlElement(
"fieldlabel", NULL,
"AUTHOR");
47 $xml->xmlElement(
"fieldentry", NULL, $this->
object->getAuthor());
48 $xml->xmlEndTag(
"qtimetadatafield");
50 $xml->xmlStartTag(
"qtimetadatafield");
51 $xml->xmlElement(
"fieldlabel", NULL,
"minAutoCompleteLength");
52 $xml->xmlElement(
"fieldentry", NULL, $this->
object->getMinAutoComplete());
53 $xml->xmlEndTag(
"qtimetadatafield");
55 $xml->xmlStartTag(
"qtimetadatafield");
56 $xml->xmlElement(
"fieldlabel", NULL,
"gapTypes");
58 if(is_array($correct_answers))
60 foreach($correct_answers as $key => $value)
62 $gap_types[] = $value[2];
65 $xml->xmlElement(
"fieldentry", NULL, json_encode($gap_types));
66 $xml->xmlEndTag(
"qtimetadatafield");
72 $xml->xmlStartTag(
"qtimetadatafield");
73 $xml->xmlElement(
"fieldlabel", NULL,
"feedback_setting");
74 $xml->xmlElement(
"fieldentry", NULL, $this->
object->getSpecificFeedbackSetting());
75 $xml->xmlEndTag(
"qtimetadatafield");
77 $xml->xmlEndTag(
"qtimetadata");
78 $xml->xmlEndTag(
"itemmetadata");
79 $xml->xmlStartTag(
"presentation");
81 $xml->xmlStartTag(
"flow");
84 $this->
object->addQTIMaterial($xml, $this->
object->getQuestion());
85 $this->
object->addQTIMaterial($xml, $this->
object->getLongMenuTextValue());
87 foreach($answers as $key => $values)
91 "ident" =>
"LongMenu_" . $real_id,
92 "rcardinality" =>
"Single" 94 $xml->xmlStartTag(
"response_str", $attrs);
95 foreach($values as $index => $value)
97 $xml->xmlStartTag(
"response_label",
array(
'ident' => $index));
98 $xml->xmlStartTag(
"material");
99 $xml->xmlElement(
"fieldentry", NULL, $value);
100 $xml->xmlEndTag(
"material");
101 $xml->xmlEndTag(
"response_label");
103 $xml->xmlEndTag(
"response_str");
105 $xml->xmlEndTag(
"flow");
106 $xml->xmlEndTag(
"presentation");
108 $xml->xmlStartTag(
"resprocessing");
109 $xml->xmlStartTag(
"outcomes");
110 $xml->xmlElement(
"decvar");
111 $xml->xmlEndTag(
"outcomes");
112 foreach($answers as $key => $values)
115 foreach($values as $index => $value)
117 $xml->xmlStartTag(
"respcondition",
array(
'continue' =>
'Yes'));
118 $xml->xmlStartTag(
"conditionvar");
119 $xml->xmlElement(
"varequal",
array(
'respident' =>
"LongMenu_" . $real_id) ,$value);
120 $xml->xmlEndTag(
"conditionvar");
122 if(in_array($value, $correct_answers[$key][0]))
124 $xml->xmlElement(
"setvar",
array(
'action' =>
"Add"), $correct_answers[$key][1]);
128 $xml->xmlElement(
"setvar",
array(
'action' =>
"Add"), 0);
130 $xml->xmlElement(
"displayfeedback",
array(
'feedbacktype' =>
"Response",
'linkrefid' => $key .
'_Response_' . $index));
131 $xml->xmlEndTag(
"respcondition");
134 $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
135 $this->
object->getId(), true
137 if(strlen($feedback_allcorrect) > 0)
139 $xml->xmlStartTag(
"respcondition",
array(
'continue' =>
'Yes'));
140 $xml->xmlStartTag(
"conditionvar");
141 foreach($correct_answers as $key => $values)
146 $xml->xmlStartTag(
"and");
149 foreach($values[0] as $index => $value)
153 $xml->xmlStartTag(
"or");
155 $xml->xmlElement(
"varequal",
array(
'respident' =>
"LongMenu_" . $real_id), $value);
158 $xml->xmlEndTag(
"or");
163 $xml->xmlEndTag(
"and");
166 $xml->xmlEndTag(
"conditionvar");
167 $xml->xmlElement(
"displayfeedback",
array(
'feedbacktype' =>
"Response",
'linkrefid' =>
'response_allcorrect'));
168 $xml->xmlEndTag(
"respcondition");
171 $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
172 $this->
object->getId(), false
174 if (strlen($feedback_onenotcorrect))
176 $xml->xmlStartTag(
"respcondition",
array(
'continue' =>
'Yes'));
177 $xml->xmlStartTag(
"conditionvar");
178 $xml->xmlStartTag(
"not");
179 foreach($correct_answers as $key => $values)
184 $xml->xmlStartTag(
"and");
187 foreach($values[0] as $index => $value)
191 $xml->xmlStartTag(
"or");
193 $xml->xmlElement(
"varequal",
array(
'respident' =>
"LongMenu_" . $real_id), $value);
196 $xml->xmlEndTag(
"or");
201 $xml->xmlEndTag(
"and");
204 $xml->xmlEndTag(
"not");
205 $xml->xmlEndTag(
"conditionvar");
206 $xml->xmlElement(
"displayfeedback",
array(
'feedbacktype' =>
"Response",
'linkrefid' =>
'response_onenotcorrect'));
207 $xml->xmlEndTag(
"respcondition");
210 $xml->xmlEndTag(
"resprocessing");
215 for ($i = 0; $i <
sizeof($correct_answers); $i++)
222 $xml->xmlStartTag(
"itemfeedback", $attrs);
224 $xml->xmlStartTag(
"flow_mat");
225 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
226 $this->
object->getId(), $i
228 $this->
object->addQTIMaterial($xml, $fb);
229 $xml->xmlEndTag(
"flow_mat");
230 $xml->xmlEndTag(
"itemfeedback");
233 if(strlen($feedback_allcorrect) > 0)
235 $xml->xmlStartTag(
"itemfeedback",
array(
'ident' =>
'response_allcorrect',
'view' =>
'All'));
236 $xml->xmlStartTag(
"flow_mat");
237 $xml->xmlStartTag(
"material");
238 $xml->xmlElement(
"mattext",
array(
'texttype' =>
'text/xhtml'), $feedback_allcorrect);
239 $xml->xmlEndTag(
"material");
240 $xml->xmlEndTag(
"flow_mat");
241 $xml->xmlEndTag(
"itemfeedback");
243 if(strlen($feedback_onenotcorrect) > 0)
245 $xml->xmlStartTag(
"itemfeedback",
array(
'ident' =>
'response_onenotcorrect',
'view' =>
'All'));
246 $xml->xmlStartTag(
"flow_mat");
247 $xml->xmlStartTag(
"material");
248 $xml->xmlElement(
"mattext",
array(
'texttype' =>
'text/xhtml'), $feedback_onenotcorrect);
249 $xml->xmlEndTag(
"material");
250 $xml->xmlEndTag(
"flow_mat");
251 $xml->xmlEndTag(
"itemfeedback");
254 $xml->xmlEndTag(
"item");
255 $xml->xmlEndTag(
"questestinterop");
257 $xml = $xml->xmlDumpMem(FALSE);
258 if (!$a_include_header)
260 $pos = strpos($xml,
"?>");
261 $xml = substr($xml, $pos + 2);
const LONG_MENU_QUESTION_IDENTIFIER
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
xmlHeader()
Writes xml header public.
Create styles array
The data for the language used.
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
Create new PHPExcel object
obj_idprivate