35 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false):
string
38 $ilias =
$DIC[
'ilias'];
42 $a_xml_writer->xmlHeader();
43 $a_xml_writer->xmlStartTag(
"questestinterop");
45 "ident" =>
"il_" .
IL_INST_ID .
"_qst_" . $this->
object->getId(),
46 "title" => $this->
object->getTitle()
48 $a_xml_writer->xmlStartTag(
"item", $attrs);
50 $a_xml_writer->xmlElement(
"qticomment",
null, $this->
object->getComment());
51 $a_xml_writer->xmlStartTag(
"itemmetadata");
52 $a_xml_writer->xmlStartTag(
"qtimetadata");
53 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
54 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"ILIAS_VERSION");
55 $a_xml_writer->xmlElement(
"fieldentry",
null, $ilias->getSetting(
"ilias_version"));
56 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
57 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
58 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"QUESTIONTYPE");
59 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getQuestionType());
60 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
61 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
62 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"AUTHOR");
63 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getAuthor());
64 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
65 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
66 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"points");
67 $a_xml_writer->xmlElement(
"fieldentry",
null, $this->
object->getPoints());
68 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
72 $unit_repository =
$object->getUnitRepository();
74 $question_id = $this->
object->getId();
75 $unit_categories = array_filter(
76 $unit_repository->getAllUnitCategories(),
77 static fn(
object $object):
bool =>
$object->getQuestionFi() === $question_id,
80 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
81 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"unit_categories");
83 foreach ($unit_categories as $unit_category) {
84 $a_xml_writer->xmlElement(
86 [
"id" => $unit_category->getId(),
"question_fi" => $unit_category->getQuestionFi()],
87 $unit_category->getCategory()
90 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
92 $categorized_units = array_filter(
93 $unit_repository->getCategorizedUnits(),
97 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
98 $a_xml_writer->xmlElement(
"fieldlabel",
null,
"units");
100 foreach ($categorized_units as $categorized_unit) {
101 $a_xml_writer->xmlElement(
104 "id" => $categorized_unit->getId(),
105 "sequence" => $categorized_unit->getSequence(),
106 "factor" => $categorized_unit->getFactor(),
107 "base_unit" => $categorized_unit->getBaseUnit(),
108 "base_unit_title" => $categorized_unit->getBaseunitTitle(),
109 "category" => $categorized_unit->getCategory()
111 $categorized_unit->getUnit()
114 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
116 foreach ($this->
object->getVariables() as $variable) {
118 "precision" => $variable->getPrecision(),
119 "intprecision" => $variable->getIntprecision(),
120 "rangemin" => $variable->getRangeMin(),
121 "rangemax" => $variable->getRangeMax(),
122 "unit" => (is_object($variable->getUnit())) ? $variable->getUnit()->getUnit() :
"",
123 "unitvalue" => (is_object($variable->getUnit())) ? $variable->getUnit()->getId() :
""
125 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
126 $a_xml_writer->xmlElement(
"fieldlabel",
null, $variable->getVariable());
127 $a_xml_writer->xmlElement(
"fieldentry",
null, serialize($var));
128 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
130 foreach ($this->
object->getResults() as $result) {
131 $resultunits = $this->
object->getResultUnits($result);
133 foreach ($resultunits as $unit) {
134 array_push($ru, [
"unit" => $unit->getUnit(),
"unitvalue" => $unit->getId()]);
137 "precision" => $result->getPrecision(),
138 "tolerance" => $result->getTolerance(),
139 "rangemin" => $result->getRangeMin(),
140 "rangemax" => $result->getRangeMax(),
141 "points" => $result->getPoints(),
142 "formula" => $result->getFormula(),
143 "rating" => ($result->getRatingSimple()) ?
"" : [
"sign" => $result->getRatingSign(),
"value" => $result->getRatingValue(),
"unit" => $result->getRatingUnit()],
144 "unit" => (is_object($result->getUnit())) ? $result->getUnit()->getUnit() :
"",
145 "unitvalue" => (is_object($result->getUnit())) ? $result->getUnit()->getId() :
"",
146 "resultunits" => $ru,
147 "resulttype" => $result->getResultType()
149 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
150 $a_xml_writer->xmlElement(
"fieldlabel",
null, $result->getResult());
151 $a_xml_writer->xmlElement(
"fieldentry",
null, serialize(
$res));
152 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
159 $a_xml_writer->xmlEndTag(
"qtimetadata");
160 $a_xml_writer->xmlEndTag(
"itemmetadata");
164 "label" => $this->
object->getTitle()
166 $a_xml_writer->xmlStartTag(
"presentation", $attrs);
168 $a_xml_writer->xmlStartTag(
"flow");
172 $a_xml_writer->xmlEndTag(
"flow");
174 $a_xml_writer->xmlEndTag(
"presentation");
178 $a_xml_writer->xmlEndTag(
"item");
179 $a_xml_writer->xmlEndTag(
"questestinterop");
181 $xml = $a_xml_writer->xmlDumpMem(
false);
182 if (!$a_include_header) {
183 $pos = strpos($xml,
"?>");
184 $xml = substr($xml, $pos + 2);
Class for question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
addQTIMaterial(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
addSuggestedSolution(ilXmlWriter $writer)
addGenericFeedback(ilXmlWriter $a_xml_writer)
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...