ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assLongMenuExport Class Reference
+ Inheritance diagram for assLongMenuExport:
+ Collaboration diagram for assLongMenuExport:

Public Member Functions

 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 
- Public Member Functions inherited from assQuestionExport
 __construct ($a_object)
 assQuestionExport constructor More...
 
 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. More...
 

Data Fields

 $object
 
- Data Fields inherited from assQuestionExport
 $object
 

Additional Inherited Members

- Protected Member Functions inherited from assQuestionExport
 addAnswerSpecificFeedback (ilXmlWriter $a_xml_writer, $answers)
 
 addGenericFeedback (ilXmlWriter $a_xml_writer)
 
 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 context of opened "qtimetadata" tag) More...
 
 addAdditionalContentEditingModeInformation (ilXmlWriter $a_xml_writer)
 adds a qti meta data field for ilias specific information of "additional content editing mode" (xml writer must be in context of opened "qtimetadata" tag) More...
 
 addGeneralMetadata (ilXmlWriter $xmlwriter)
 

Detailed Description

Definition at line 3 of file class.assLongMenuExport.php.

Member Function Documentation

◆ toXML()

assLongMenuExport::toXML (   $a_include_header = true,
  $a_include_binary = true,
  $a_shuffle = false,
  $test_output = false,
  $force_image_references = false 
)

Definition at line 10 of file class.assLongMenuExport.php.

References $DIC, $i, $index, $key, $values, $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), and LONG_MENU_QUESTION_IDENTIFIER.

11  {
12  global $DIC;
13  $ilias = $DIC['ilias'];
14 
15  $correct_answers = $this->object->getCorrectAnswers();
16  $answers = $this->object->getAnswers();
17 
18  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
19  $xml = new ilXmlWriter;
20  // set xml header
21  $xml->xmlHeader();
22  $xml->xmlStartTag("questestinterop");
23  // add question description
24  $attrs = array(
25  "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
26  "title" => $this->object->getTitle(),
27  "maxattempts" => $this->object->getNrOfTries()
28  );
29  $xml->xmlStartTag("item", $attrs);
30  $xml->xmlElement("qticomment", null, $this->object->getComment());
31  // add estimated working time
32  $workingtime = $this->object->getEstimatedWorkingTime();
33  $duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
34  $xml->xmlElement("duration", null, $duration);
35  // add ILIAS specific metadata
36  $xml->xmlStartTag("itemmetadata");
37  $xml->xmlStartTag("qtimetadata");
38  $xml->xmlStartTag("qtimetadatafield");
39  $xml->xmlElement("fieldlabel", null, "ILIAS_VERSION");
40  $xml->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
41  $xml->xmlEndTag("qtimetadatafield");
42  $xml->xmlStartTag("qtimetadatafield");
43  $xml->xmlElement("fieldlabel", null, "QUESTIONTYPE");
44  $xml->xmlElement("fieldentry", null, LONG_MENU_QUESTION_IDENTIFIER);
45  $xml->xmlEndTag("qtimetadatafield");
46  $xml->xmlStartTag("qtimetadatafield");
47  $xml->xmlElement("fieldlabel", null, "AUTHOR");
48  $xml->xmlElement("fieldentry", null, $this->object->getAuthor());
49  $xml->xmlEndTag("qtimetadatafield");
50 
51  $xml->xmlStartTag("qtimetadatafield");
52  $xml->xmlElement("fieldlabel", null, "minAutoCompleteLength");
53  $xml->xmlElement("fieldentry", null, $this->object->getMinAutoComplete());
54  $xml->xmlEndTag("qtimetadatafield");
55  $xml->xmlStartTag("qtimetadatafield");
56  $xml->xmlElement("fieldlabel", null, "identical_scoring");
57  $xml->xmlElement("fieldentry", null, $this->object->getIdenticalScoring());
58  $xml->xmlEndTag("qtimetadatafield");
59 
60  $xml->xmlStartTag("qtimetadatafield");
61  $xml->xmlElement("fieldlabel", null, "gapTypes");
62  $gap_types = array();
63  if (is_array($correct_answers)) {
64  foreach ($correct_answers as $key => $value) {
65  $gap_types[] = $value[2];
66  }
67  }
68  $xml->xmlElement("fieldentry", null, json_encode($gap_types));
69  $xml->xmlEndTag("qtimetadatafield");
70 
71  // additional content editing information
73  $this->addGeneralMetadata($xml);
74 
75  $xml->xmlStartTag("qtimetadatafield");
76  $xml->xmlElement("fieldlabel", null, "feedback_setting");
77  $xml->xmlElement("fieldentry", null, $this->object->getSpecificFeedbackSetting());
78  $xml->xmlEndTag("qtimetadatafield");
79 
80  $xml->xmlEndTag("qtimetadata");
81  $xml->xmlEndTag("itemmetadata");
82  $xml->xmlStartTag("presentation");
83  // add flow to presentation
84  $xml->xmlStartTag("flow");
85 
86 
87  $this->object->addQTIMaterial($xml, $this->object->getQuestion());
88  $this->object->addQTIMaterial($xml, $this->object->getLongMenuTextValue());
89 
90  foreach ($answers as $key => $values) {
91  $real_id = $key + 1;
92  $attrs = array(
93  "ident" => "LongMenu_" . $real_id,
94  "rcardinality" => "Single"
95  );
96  $xml->xmlStartTag("response_str", $attrs);
97  foreach ($values as $index => $value) {
98  $xml->xmlStartTag("response_label", array('ident' => $index));
99  $xml->xmlStartTag("material");
100  $xml->xmlElement("fieldentry", null, $value);
101  $xml->xmlEndTag("material");
102  $xml->xmlEndTag("response_label");
103  }
104  $xml->xmlEndTag("response_str");
105  }
106  $xml->xmlEndTag("flow");
107  $xml->xmlEndTag("presentation");
108 
109  $xml->xmlStartTag("resprocessing");
110  $xml->xmlStartTag("outcomes");
111  $xml->xmlElement("decvar");
112  $xml->xmlEndTag("outcomes");
113  foreach ($answers as $key => $values) {
114  $real_id = $key + 1;
115  foreach ($values as $index => $value) {
116  $xml->xmlStartTag("respcondition", array('continue' => 'Yes'));
117  $xml->xmlStartTag("conditionvar");
118  $xml->xmlElement("varequal", array('respident' => "LongMenu_" . $real_id), $value);
119  $xml->xmlEndTag("conditionvar");
120 
121  if (in_array($value, $correct_answers[$key][0])) {
122  $xml->xmlElement("setvar", array('action' => "Add"), $correct_answers[$key][1]);
123  } else {
124  $xml->xmlElement("setvar", array('action' => "Add"), 0);
125  }
126  $xml->xmlElement("displayfeedback", array('feedbacktype' => "Response", 'linkrefid' => $key . '_Response_' . $index));
127  $xml->xmlEndTag("respcondition");
128  }
129  }
130  $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
131  $this->object->getId(),
132  true
133  );
134  if (strlen($feedback_allcorrect) > 0) {
135  $xml->xmlStartTag("respcondition", array('continue' => 'Yes'));
136  $xml->xmlStartTag("conditionvar");
137  foreach ($correct_answers as $key => $values) {
138  $real_id = $key + 1;
139  if ($key > 0) {
140  $xml->xmlStartTag("and");
141  }
142 
143  foreach ($values[0] as $index => $value) {
144  if ($index > 0) {
145  $xml->xmlStartTag("or");
146  }
147  $xml->xmlElement("varequal", array('respident' => "LongMenu_" . $real_id), $value);
148  if ($index > 0) {
149  $xml->xmlEndTag("or");
150  }
151  }
152  if ($key > 0) {
153  $xml->xmlEndTag("and");
154  }
155  }
156  $xml->xmlEndTag("conditionvar");
157  $xml->xmlElement("displayfeedback", array('feedbacktype' => "Response", 'linkrefid' => 'response_allcorrect'));
158  $xml->xmlEndTag("respcondition");
159  }
160 
161  $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation(
162  $this->object->getId(),
163  false
164  );
165  if (strlen($feedback_onenotcorrect)) {
166  $xml->xmlStartTag("respcondition", array('continue' => 'Yes'));
167  $xml->xmlStartTag("conditionvar");
168  $xml->xmlStartTag("not");
169  foreach ($correct_answers as $key => $values) {
170  $real_id = $key + 1;
171  if ($key > 0) {
172  $xml->xmlStartTag("and");
173  }
174 
175  foreach ($values[0] as $index => $value) {
176  if ($index > 0) {
177  $xml->xmlStartTag("or");
178  }
179  $xml->xmlElement("varequal", array('respident' => "LongMenu_" . $real_id), $value);
180  if ($index > 0) {
181  $xml->xmlEndTag("or");
182  }
183  }
184  if ($key > 0) {
185  $xml->xmlEndTag("and");
186  }
187  }
188  $xml->xmlEndTag("not");
189  $xml->xmlEndTag("conditionvar");
190  $xml->xmlElement("displayfeedback", array('feedbacktype' => "Response", 'linkrefid' => 'response_onenotcorrect'));
191  $xml->xmlEndTag("respcondition");
192  }
193 
194  $xml->xmlEndTag("resprocessing");
195 
196 
197 
198 
199  for ($i = 0; $i < sizeof($correct_answers); $i++) {
200  $attrs = array(
201  "ident" => $i,
202  "view" => "All"
203  );
204  $xml->xmlStartTag("itemfeedback", $attrs);
205  // qti flow_mat
206  $xml->xmlStartTag("flow_mat");
207  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
208  $this->object->getId(),
209  0,
210  $i
211  );
212  $this->object->addQTIMaterial($xml, $fb);
213  $xml->xmlEndTag("flow_mat");
214  $xml->xmlEndTag("itemfeedback");
215  }
216 
217  if (strlen($feedback_allcorrect) > 0) {
218  $xml->xmlStartTag("itemfeedback", array('ident' => 'response_allcorrect','view' => 'All'));
219  $xml->xmlStartTag("flow_mat");
220  $xml->xmlStartTag("material");
221  $xml->xmlElement("mattext", array('texttype' => 'text/xhtml'), $feedback_allcorrect);
222  $xml->xmlEndTag("material");
223  $xml->xmlEndTag("flow_mat");
224  $xml->xmlEndTag("itemfeedback");
225  }
226  if (strlen($feedback_onenotcorrect) > 0) {
227  $xml->xmlStartTag("itemfeedback", array('ident' => 'response_onenotcorrect', 'view' => 'All'));
228  $xml->xmlStartTag("flow_mat");
229  $xml->xmlStartTag("material");
230  $xml->xmlElement("mattext", array('texttype' => 'text/xhtml'), $feedback_onenotcorrect);
231  $xml->xmlEndTag("material");
232  $xml->xmlEndTag("flow_mat");
233  $xml->xmlEndTag("itemfeedback");
234  }
235 
236  $xml->xmlEndTag("item");
237  $xml->xmlEndTag("questestinterop");
238 
239  $xml = $xml->xmlDumpMem(false);
240  if (!$a_include_header) {
241  $pos = strpos($xml, "?>");
242  $xml = substr($xml, $pos + 2);
243  }
244  return $xml;
245  }
global $DIC
Definition: saml.php:7
const LONG_MENU_QUESTION_IDENTIFIER
XML writer class.
$index
Definition: metadata.php:60
addGeneralMetadata(ilXmlWriter $xmlwriter)
$values
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
$i
Definition: disco.tpl.php:19
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

Field Documentation

◆ $object

assLongMenuExport::$object

Definition at line 8 of file class.assLongMenuExport.php.


The documentation for this class was generated from the following file: