ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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)
 
 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
 assQuestionExport (&$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() [1/2]

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 assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), LONG_MENU_QUESTION_IDENTIFIER, and ilXmlWriter\xmlHeader().

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

◆ toXML() [2/2]

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 assLongMenu\GAP_PLACEHOLDER, and ilXmlWriter\xmlHeader().

11  {
12  global $ilias;
13 
14  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
15  $xml = new ilXmlWriter;
16  // set xml header
17  $xml->xmlHeader();
18  $attrs = array(
19  'xmlns' => "http://www.imsglobal.org/xsd/imsqti_v2p1",
20  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
21  'xsi:schemaLocation' => 'http://www.imsglobal.org/xsd/imsqti_v2p1 http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1p1.xsd http://www.w3.org/1998/Math/MathML http://www.w3.org/Math/XMLSchema/mathml2/mathml2.xsd',
22  "identifier" => "il_".IL_INST_ID."_qst_".$this->object->getId(),
23  "title" => $this->object->getTitle(),
24  //"maxattempts" => $this->object->getNrOfTries(),
25  'adaptive' => 'false',
26  'timeDependent' => 'false'
27  );
28  $xml->xmlStartTag("assessmentItem", $attrs, false, true, false);
29  // add question description
30  $correct_answers = $this->object->getCorrectAnswers();
31  $answers = $this->object->getAnswers();
32  $a = 0;
33  $inlineChoice = array();
34  foreach($answers as $key => $values)
35  {
36  $real_id = $key +1;
37  $inlineChoiceString = '<inlineChoiceInteraction responseIdentifier="LONGMENU_' . $real_id.'" shuffle="false" required="false">';
38  $attrs = array(
39  "identifier" => "LONGMENU_" . $real_id,
40  "cardinality" => "single",
41  "baseType" => "identifier"
42  );
43  $xml->xmlStartTag("responseDeclaration", $attrs);
44  $xml->xmlStartTag("correctResponse");
45  $xml->xmlElement("value", NULL, $correct_answers[$key][0][0]);
46  $xml->xmlEndTag("correctResponse");
47  $attrs = array(
48  "defaultValue" => "0",
49  "lowerBound" => "0",
50  "upperBound" => $correct_answers[$key][1]
51  );
52  $xml->xmlStartTag("mapping", $attrs);
53 
54  foreach($values as $index => $value)
55  {
56 
57  $points = 0;
58  if(in_array($value, $correct_answers[$key][0]))
59  {
60  $points = $correct_answers[$key][1];
61  }
62  $attrs = array(
63  "mapKey" => $value,
64  "mappedValue" => $points
65  );
66  $inlineChoiceString .= '<inlineChoice identifier="'.$value.'" fixed="false" showHide="show">'.$value.'</inlineChoice>';
67  $xml->xmlElement("mapEntry", $attrs);
68  }
69  $xml->xmlEndTag("mapping");
70  $xml->xmlEndTag("responseDeclaration");
71  $inlineChoiceString .= '</inlineChoiceInteraction>';
72  $inlineChoice[$real_id] = $inlineChoiceString;
73  }
74  $attrs = array(
75  "identifier" => "SCORE",
76  "cardinality" => "single",
77  "baseType" => "float"
78  );
79  $xml->xmlStartTag("outcomeDeclaration", $attrs);
80  $xml->xmlStartTag("defaultValue");
81  $xml->xmlElement("value", NULL, 0);
82  $xml->xmlEndTag("defaultValue");
83  $xml->xmlEndTag("outcomeDeclaration");
84 
85  $attrs = array(
86  "identifier" => "MAXSCORE",
87  "cardinality" => "single",
88  "baseType" => "float"
89  );
90  $xml->xmlStartTag("outcomeDeclaration", $attrs);
91  $xml->xmlStartTag("defaultValue");
92  $xml->xmlElement("value", NULL, $this->object->getMaximumPoints());
93  $xml->xmlEndTag("defaultValue");
94  $xml->xmlEndTag("outcomeDeclaration");
95 
96  $attrs = array(
97  "identifier" => "FEEDBACKBASIC",
98  "cardinality" => "single",
99  "baseType" => "identifier",
100  "view" => "testConstructor"
101  );
102 
103  $xml->xmlStartTag("outcomeDeclaration", $attrs);
104  $xml->xmlStartTag("defaultValue");
105  $xml->xmlElement("value", NULL, "TODO IMPLEMENT FEEDBACK");
106  $xml->xmlEndTag("defaultValue");
107  $xml->xmlEndTag("outcomeDeclaration");
108 
109  $longmenu_text = $this->object->getLongMenuTextValue();
110 
111  for($i = 1; $i <= sizeof($answers); $i++ )
112  {
113  $longmenu_text = preg_replace("/\\[".assLongMenu::GAP_PLACEHOLDER." ".$i."]/", $inlineChoice[$i], $longmenu_text);
114  }
115  $longmenu_text = $this->object->getQuestion() . $longmenu_text;
116  $xml->xmlStartTag("itemBody", $attrs);
117  $xml->xmlElement("div", NULL, $longmenu_text, true, false);
118  $xml->xmlEndTag("itemBody");
119 
120  $xml->xmlStartTag("responseProcessing");
121  foreach($answers as $key => $values)
122  {
123  $xml->xmlStartTag("responseCondition");
124  $xml->xmlStartTag("responseIf");
125  $xml->xmlStartTag("not");
126  $xml->xmlStartTag("isNull");
127  $xml->xmlElement("variable", array("identifier" => 'LONGMENU_'. ($key + 1) ));
128  $xml->xmlEndTag("isNull");
129  $xml->xmlEndTag("not");
130  $xml->xmlStartTag("setOutcomeValue", array("identifier" => 'SCORE'));
131  $xml->xmlStartTag("sum");
132  $xml->xmlElement("variable", array("identifier" => 'SCORE'));
133  $xml->xmlElement("mapResponse", array("identifier" => 'LONGMENU_'. ($key + 1) ));
134  $xml->xmlEndTag("sum");
135  $xml->xmlEndTag("setOutcomeValue");
136  $xml->xmlStartTag("setOutcomeValue", array("identifier" => 'FEEDBACKBASIC'));
137  $xml->xmlElement("value", array('baseType' => 'identifier'), "incorrect");
138  $xml->xmlEndTag("setOutcomeValue");
139  $xml->xmlEndTag("responseIf");
140  $xml->xmlEndTag("responseCondition");
141  }
142  $xml->xmlEndTag("responseProcessing");
143  $xml->xmlEndTag("assessmentItem");
144  $xml = $xml->xmlDumpMem(FALSE);
145  if (!$a_include_header)
146  {
147  $pos = strpos($xml, "?>");
148  $xml = substr($xml, $pos + 2);
149  }
150  return $xml;
151  }
XML writer class.
xmlHeader()
Writes xml header public.
+ 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: