ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
- 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...
 

Data Fields

 $object
 
- Data Fields inherited from assQuestionExport
 $object
 
const ITEM_SOLUTIONHINT = 'solutionhint'
 

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)
 
 addSolutionHints (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 
)

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

References Vendor\Package\$a, $DIC, $i, $index, ILIAS\LTI\ToolProvider\$key, $xml, assLongMenu\GAP_PLACEHOLDER, IL_INST_ID, and ILIAS\Repository\object().

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