ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
assLongMenuExportQti21 Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ 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 Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation. 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 Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation. More...
 
 addQTIMaterial (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
 

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)
 
 addSuggestedSolution (ilXmlWriter $writer)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 19 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.

Reimplemented from assQuestionExport.

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

26 : string
27 {
28 global $DIC;
29 $ilias = $DIC['ilias'];
30
31 $xml = new ilXmlWriter();
32 // set xml header
33 $xml->xmlHeader();
34 $attrs = [
35 'xmlns' => "http://www.imsglobal.org/xsd/imsqti_v2p1",
36 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
37 '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',
38 "identifier" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
39 "title" => $this->object->getTitle(),
40 //"maxattempts" => $this->object->getNrOfTries(),
41 'adaptive' => 'false',
42 'timeDependent' => 'false'
43 ];
44 $xml->xmlStartTag("assessmentItem", $attrs, false, true, false);
45 // add question description
46 $correct_answers = $this->object->getCorrectAnswers();
47 $answers = $this->object->getAnswers();
48 $a = 0;
49 $inlineChoice = [];
50 foreach ($answers as $key => $values) {
51 $real_id = $key + 1;
52 $inlineChoiceString = '<inlineChoiceInteraction responseIdentifier="LONGMENU_' . $real_id . '" shuffle="false" required="false">';
53 $attrs = [
54 "identifier" => "LONGMENU_" . $real_id,
55 "cardinality" => "single",
56 "baseType" => "identifier"
57 ];
58 $xml->xmlStartTag("responseDeclaration", $attrs);
59 $xml->xmlStartTag("correctResponse");
60 $xml->xmlElement("value", null, $correct_answers[$key][0][0]);
61 $xml->xmlEndTag("correctResponse");
62 $attrs = [
63 "defaultValue" => "0",
64 "lowerBound" => "0",
65 "upperBound" => $correct_answers[$key][1]
66 ];
67 $xml->xmlStartTag("mapping", $attrs);
68
69 foreach ($values as $index => $value) {
70 $points = 0;
71 if (in_array($value, $correct_answers[$key][0])) {
72 $points = $correct_answers[$key][1];
73 }
74 $attrs = [
75 "mapKey" => $value,
76 "mappedValue" => $points
77 ];
78 $inlineChoiceString .= '<inlineChoice identifier="' . $value . '" fixed="false" showHide="show">' . $value . '</inlineChoice>';
79 $xml->xmlElement("mapEntry", $attrs);
80 }
81 $xml->xmlEndTag("mapping");
82 $xml->xmlEndTag("responseDeclaration");
83 $inlineChoiceString .= '</inlineChoiceInteraction>';
84 $inlineChoice[$real_id] = $inlineChoiceString;
85 }
86 $attrs = [
87 "identifier" => "SCORE",
88 "cardinality" => "single",
89 "baseType" => "float"
90 ];
91 $xml->xmlStartTag("outcomeDeclaration", $attrs);
92 $xml->xmlStartTag("defaultValue");
93 $xml->xmlElement("value", null, 0);
94 $xml->xmlEndTag("defaultValue");
95 $xml->xmlEndTag("outcomeDeclaration");
96
97 $attrs = [
98 "identifier" => "MAXSCORE",
99 "cardinality" => "single",
100 "baseType" => "float"
101 ];
102 $xml->xmlStartTag("outcomeDeclaration", $attrs);
103 $xml->xmlStartTag("defaultValue");
104 $xml->xmlElement("value", null, $this->object->getMaximumPoints());
105 $xml->xmlEndTag("defaultValue");
106 $xml->xmlEndTag("outcomeDeclaration");
107
108 $attrs = [
109 "identifier" => "FEEDBACKBASIC",
110 "cardinality" => "single",
111 "baseType" => "identifier",
112 "view" => "testConstructor"
113 ];
114
115 $xml->xmlStartTag("outcomeDeclaration", $attrs);
116 $xml->xmlStartTag("defaultValue");
117 $xml->xmlElement("value", null, "TODO IMPLEMENT FEEDBACK");
118 $xml->xmlEndTag("defaultValue");
119 $xml->xmlEndTag("outcomeDeclaration");
120
121 $longmenu_text = $this->object->getLongMenuTextValue();
122
123 for ($i = 1; $i <= sizeof($answers); $i++) {
124 $longmenu_text = preg_replace("/\\[" . assLongMenu::GAP_PLACEHOLDER . " " . $i . "]/", $inlineChoice[$i], $longmenu_text);
125 }
126 $longmenu_text = $this->object->getQuestion() . $longmenu_text;
127 $xml->xmlStartTag("itemBody", $attrs);
128 $xml->xmlElement("div", null, $longmenu_text, true, false);
129 $xml->xmlEndTag("itemBody");
130
131 $xml->xmlStartTag("responseProcessing");
132 foreach ($answers as $key => $values) {
133 $xml->xmlStartTag("responseCondition");
134 $xml->xmlStartTag("responseIf");
135 $xml->xmlStartTag("not");
136 $xml->xmlStartTag("isNull");
137 $xml->xmlElement("variable", ["identifier" => 'LONGMENU_' . ($key + 1) ]);
138 $xml->xmlEndTag("isNull");
139 $xml->xmlEndTag("not");
140 $xml->xmlStartTag("setOutcomeValue", ["identifier" => 'SCORE']);
141 $xml->xmlStartTag("sum");
142 $xml->xmlElement("variable", ["identifier" => 'SCORE']);
143 $xml->xmlElement("mapResponse", ["identifier" => 'LONGMENU_' . ($key + 1) ]);
144 $xml->xmlEndTag("sum");
145 $xml->xmlEndTag("setOutcomeValue");
146 $xml->xmlStartTag("setOutcomeValue", ["identifier" => 'FEEDBACKBASIC']);
147 $xml->xmlElement("value", ['baseType' => 'identifier'], "incorrect");
148 $xml->xmlEndTag("setOutcomeValue");
149 $xml->xmlEndTag("responseIf");
150 $xml->xmlEndTag("responseCondition");
151 }
152 $xml->xmlEndTag("responseProcessing");
153 $xml->xmlEndTag("assessmentItem");
154 $xml = $xml->xmlDumpMem(false);
155 if (!$a_include_header) {
156 $pos = strpos($xml, "?>");
157 $xml = substr($xml, $pos + 2);
158 }
159 return $xml;
160 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_INST_ID
Definition: constants.php:40
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
global $DIC
Definition: shib_login.php:26

References Vendor\Package\$a, $DIC, assLongMenu\GAP_PLACEHOLDER, IL_INST_ID, and ILIAS\Repository\object().

+ Here is the call graph for this function:

Field Documentation

◆ $object

assLongMenuExportQti21::$object

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


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