ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 Returns a QTI xml representation of the question. More...
 
- 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 
)

Returns a QTI xml representation of the question.

Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation

Returns
string The QTI xml representation of the question @access public

Reimplemented from assQuestionExport.

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

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

References $DIC, $i, $index, $key, $values, $xml, and assLongMenu\GAP_PLACEHOLDER.

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: