ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.assErrorTextExport.php
Go to the documentation of this file.
1 <?php
2 
27 {
32  public function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false): string
33  {
34  global $DIC;
35  $ilias = $DIC['ilias'];
36 
37  $a_xml_writer = new ilXmlWriter();
38  // set xml header
39  $a_xml_writer->xmlHeader();
40  $a_xml_writer->xmlStartTag("questestinterop");
41  $attrs = [
42  "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
43  "title" => $this->object->getTitle(),
44  "maxattempts" => $this->object->getNrOfTries()
45  ];
46  $a_xml_writer->xmlStartTag("item", $attrs);
47  // add question description
48  $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
49  $a_xml_writer->xmlStartTag("itemmetadata");
50  $a_xml_writer->xmlStartTag("qtimetadata");
51  $a_xml_writer->xmlStartTag("qtimetadatafield");
52  $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
53  $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
54  $a_xml_writer->xmlEndTag("qtimetadatafield");
55  $a_xml_writer->xmlStartTag("qtimetadatafield");
56  $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
57  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getQuestionType());
58  $a_xml_writer->xmlEndTag("qtimetadatafield");
59  $a_xml_writer->xmlStartTag("qtimetadatafield");
60  $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
61  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getAuthor());
62  $a_xml_writer->xmlEndTag("qtimetadatafield");
63 
64  // additional content editing information
65  $this->addAdditionalContentEditingModeInformation($a_xml_writer);
66  $this->addGeneralMetadata($a_xml_writer);
67 
68  $a_xml_writer->xmlStartTag("qtimetadatafield");
69  $a_xml_writer->xmlElement("fieldlabel", null, "points_wrong");
70  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getPointsWrong());
71  $a_xml_writer->xmlEndTag("qtimetadatafield");
72  $a_xml_writer->xmlStartTag("qtimetadatafield");
73  $a_xml_writer->xmlElement("fieldlabel", null, "errortext");
74  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getErrorText());
75  $a_xml_writer->xmlEndTag("qtimetadatafield");
76  $a_xml_writer->xmlStartTag("qtimetadatafield");
77  $a_xml_writer->xmlElement("fieldlabel", null, "parsederrortext");
78  $a_xml_writer->xmlElement("fieldentry", null, serialize($this->object->getParsedErrorText()));
79  $a_xml_writer->xmlEndTag("qtimetadatafield");
80  $a_xml_writer->xmlStartTag("qtimetadatafield");
81  $a_xml_writer->xmlElement("fieldlabel", null, "textsize");
82  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getTextSize());
83  $a_xml_writer->xmlEndTag("qtimetadatafield");
84  $a_xml_writer->xmlStartTag("qtimetadatafield");
85  $a_xml_writer->xmlElement("fieldlabel", null, "errordata");
86  $serialized = [];
87  foreach ($this->object->getErrorData() as $data) {
88  array_push(
89  $serialized,
90  [
91  $data->getTextCorrect(),
92  $data->getTextWrong(),
93  $data->getPoints(),
94  $data->getPosition()
95  ]
96  );
97  }
98  $a_xml_writer->xmlElement("fieldentry", null, serialize($serialized));
99  $a_xml_writer->xmlEndTag("qtimetadatafield");
100  $a_xml_writer->xmlEndTag("qtimetadata");
101  $a_xml_writer->xmlEndTag("itemmetadata");
102 
103  // PART I: qti presentation
104  $attrs = [
105  "label" => $this->object->getTitle()
106  ];
107  $a_xml_writer->xmlStartTag("presentation", $attrs);
108  // add flow to presentation
109  $a_xml_writer->xmlStartTag("flow");
110  // add material with question text to presentation
111  $this->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
112  // add answers to presentation
113  $a_xml_writer->xmlEndTag("flow");
114  $a_xml_writer = $this->addSuggestedSolution($a_xml_writer);
115  $a_xml_writer->xmlEndTag("presentation");
116 
117  $this->addGenericFeedback($a_xml_writer);
118 
119  $this->addAnswerSpecificFeedback($a_xml_writer, $this->object->getErrorData());
120 
121  $a_xml_writer->xmlEndTag("item");
122  $a_xml_writer->xmlEndTag("questestinterop");
123 
124  $xml = $a_xml_writer->xmlDumpMem(false);
125  if (!$a_include_header) {
126  $pos = strpos($xml, "?>");
127  $xml = substr($xml, $pos + 2);
128  }
129  return $xml;
130  }
131 }
const IL_INST_ID
Definition: constants.php:40
addQTIMaterial(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
Class for question exports.
addAnswerSpecificFeedback(ilXmlWriter $a_xml_writer, $answers)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addGeneralMetadata(ilXmlWriter $xmlwriter)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
addSuggestedSolution(ilXmlWriter $writer)
addGenericFeedback(ilXmlWriter $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 and sets the internal domxml variable with the DOM X...