ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assLongMenuExportQti21 Class Reference
+ Inheritance diagram for assLongMenuExportQti21:
+ Collaboration diagram for assLongMenuExportQti21:

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.assLongMenuExportQti21.php.

Member Function Documentation

◆ toXML()

assLongMenuExportQti21::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.assLongMenuExportQti21.php.

References $i, $index, $key, $xml, array, assLongMenu\GAP_PLACEHOLDER, and object.

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  $real_id = $key +1;
36  $inlineChoiceString = '<inlineChoiceInteraction responseIdentifier="LONGMENU_' . $real_id . '" shuffle="false" required="false">';
37  $attrs = array(
38  "identifier" => "LONGMENU_" . $real_id,
39  "cardinality" => "single",
40  "baseType" => "identifier"
41  );
42  $xml->xmlStartTag("responseDeclaration", $attrs);
43  $xml->xmlStartTag("correctResponse");
44  $xml->xmlElement("value", null, $correct_answers[$key][0][0]);
45  $xml->xmlEndTag("correctResponse");
46  $attrs = array(
47  "defaultValue" => "0",
48  "lowerBound" => "0",
49  "upperBound" => $correct_answers[$key][1]
50  );
51  $xml->xmlStartTag("mapping", $attrs);
52 
53  foreach ($values as $index => $value) {
54  $points = 0;
55  if (in_array($value, $correct_answers[$key][0])) {
56  $points = $correct_answers[$key][1];
57  }
58  $attrs = array(
59  "mapKey" => $value,
60  "mappedValue" => $points
61  );
62  $inlineChoiceString .= '<inlineChoice identifier="' . $value . '" fixed="false" showHide="show">' . $value . '</inlineChoice>';
63  $xml->xmlElement("mapEntry", $attrs);
64  }
65  $xml->xmlEndTag("mapping");
66  $xml->xmlEndTag("responseDeclaration");
67  $inlineChoiceString .= '</inlineChoiceInteraction>';
68  $inlineChoice[$real_id] = $inlineChoiceString;
69  }
70  $attrs = array(
71  "identifier" => "SCORE",
72  "cardinality" => "single",
73  "baseType" => "float"
74  );
75  $xml->xmlStartTag("outcomeDeclaration", $attrs);
76  $xml->xmlStartTag("defaultValue");
77  $xml->xmlElement("value", null, 0);
78  $xml->xmlEndTag("defaultValue");
79  $xml->xmlEndTag("outcomeDeclaration");
80 
81  $attrs = array(
82  "identifier" => "MAXSCORE",
83  "cardinality" => "single",
84  "baseType" => "float"
85  );
86  $xml->xmlStartTag("outcomeDeclaration", $attrs);
87  $xml->xmlStartTag("defaultValue");
88  $xml->xmlElement("value", null, $this->object->getMaximumPoints());
89  $xml->xmlEndTag("defaultValue");
90  $xml->xmlEndTag("outcomeDeclaration");
91 
92  $attrs = array(
93  "identifier" => "FEEDBACKBASIC",
94  "cardinality" => "single",
95  "baseType" => "identifier",
96  "view" => "testConstructor"
97  );
98 
99  $xml->xmlStartTag("outcomeDeclaration", $attrs);
100  $xml->xmlStartTag("defaultValue");
101  $xml->xmlElement("value", null, "TODO IMPLEMENT FEEDBACK");
102  $xml->xmlEndTag("defaultValue");
103  $xml->xmlEndTag("outcomeDeclaration");
104 
105  $longmenu_text = $this->object->getLongMenuTextValue();
106 
107  for ($i = 1; $i <= sizeof($answers); $i++) {
108  $longmenu_text = preg_replace("/\\[" . assLongMenu::GAP_PLACEHOLDER . " " . $i . "]/", $inlineChoice[$i], $longmenu_text);
109  }
110  $longmenu_text = $this->object->getQuestion() . $longmenu_text;
111  $xml->xmlStartTag("itemBody", $attrs);
112  $xml->xmlElement("div", null, $longmenu_text, true, false);
113  $xml->xmlEndTag("itemBody");
114 
115  $xml->xmlStartTag("responseProcessing");
116  foreach ($answers as $key => $values) {
117  $xml->xmlStartTag("responseCondition");
118  $xml->xmlStartTag("responseIf");
119  $xml->xmlStartTag("not");
120  $xml->xmlStartTag("isNull");
121  $xml->xmlElement("variable", array("identifier" => 'LONGMENU_' . ($key + 1) ));
122  $xml->xmlEndTag("isNull");
123  $xml->xmlEndTag("not");
124  $xml->xmlStartTag("setOutcomeValue", array("identifier" => 'SCORE'));
125  $xml->xmlStartTag("sum");
126  $xml->xmlElement("variable", array("identifier" => 'SCORE'));
127  $xml->xmlElement("mapResponse", array("identifier" => 'LONGMENU_' . ($key + 1) ));
128  $xml->xmlEndTag("sum");
129  $xml->xmlEndTag("setOutcomeValue");
130  $xml->xmlStartTag("setOutcomeValue", array("identifier" => 'FEEDBACKBASIC'));
131  $xml->xmlElement("value", array('baseType' => 'identifier'), "incorrect");
132  $xml->xmlEndTag("setOutcomeValue");
133  $xml->xmlEndTag("responseIf");
134  $xml->xmlEndTag("responseCondition");
135  }
136  $xml->xmlEndTag("responseProcessing");
137  $xml->xmlEndTag("assessmentItem");
138  $xml = $xml->xmlDumpMem(false);
139  if (!$a_include_header) {
140  $pos = strpos($xml, "?>");
141  $xml = substr($xml, $pos + 2);
142  }
143  return $xml;
144  }
XML writer class.
$index
Definition: metadata.php:60
$xml
Definition: metadata.php:240
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
$i
Definition: disco.tpl.php:19
$key
Definition: croninfo.php:18

Field Documentation

◆ $object

assLongMenuExportQti21::$object

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


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