ILIAS  release_4-4 Revision
class.assErrorTextExport.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
5 
14 {
22  function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
23  {
24  global $ilias;
25 
26  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
27  $a_xml_writer = new ilXmlWriter;
28  // set xml header
29  $a_xml_writer->xmlHeader();
30  $a_xml_writer->xmlStartTag("questestinterop");
31  $attrs = array(
32  "ident" => "il_".IL_INST_ID."_qst_".$this->object->getId(),
33  "title" => $this->object->getTitle(),
34  "maxattempts" => $this->object->getNrOfTries()
35  );
36  $a_xml_writer->xmlStartTag("item", $attrs);
37  // add question description
38  $a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
39  // add estimated working time
40  $workingtime = $this->object->getEstimatedWorkingTime();
41  $duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
42  $a_xml_writer->xmlElement("duration", NULL, $duration);
43  // add ILIAS specific metadata
44  $a_xml_writer->xmlStartTag("itemmetadata");
45  $a_xml_writer->xmlStartTag("qtimetadata");
46  $a_xml_writer->xmlStartTag("qtimetadatafield");
47  $a_xml_writer->xmlElement("fieldlabel", NULL, "ILIAS_VERSION");
48  $a_xml_writer->xmlElement("fieldentry", NULL, $ilias->getSetting("ilias_version"));
49  $a_xml_writer->xmlEndTag("qtimetadatafield");
50  $a_xml_writer->xmlStartTag("qtimetadatafield");
51  $a_xml_writer->xmlElement("fieldlabel", NULL, "QUESTIONTYPE");
52  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getQuestionType());
53  $a_xml_writer->xmlEndTag("qtimetadatafield");
54  $a_xml_writer->xmlStartTag("qtimetadatafield");
55  $a_xml_writer->xmlElement("fieldlabel", NULL, "AUTHOR");
56  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getAuthor());
57  $a_xml_writer->xmlEndTag("qtimetadatafield");
58 
59  // additional content editing information
60  $this->addAdditionalContentEditingModeInformation($a_xml_writer);
61  $this->addGeneralMetadata($a_xml_writer);
62 
63  $a_xml_writer->xmlStartTag("qtimetadatafield");
64  $a_xml_writer->xmlElement("fieldlabel", NULL, "points_wrong");
65  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getPointsWrong());
66  $a_xml_writer->xmlEndTag("qtimetadatafield");
67  $a_xml_writer->xmlStartTag("qtimetadatafield");
68  $a_xml_writer->xmlElement("fieldlabel", NULL, "errortext");
69  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getErrorText());
70  $a_xml_writer->xmlEndTag("qtimetadatafield");
71  $a_xml_writer->xmlStartTag("qtimetadatafield");
72  $a_xml_writer->xmlElement("fieldlabel", NULL, "textsize");
73  $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getTextSize());
74  $a_xml_writer->xmlEndTag("qtimetadatafield");
75  $a_xml_writer->xmlStartTag("qtimetadatafield");
76  $a_xml_writer->xmlElement("fieldlabel", NULL, "errordata");
77  $serialized = array();
78  foreach ($this->object->getErrorData() as $data)
79  {
80  array_push($serialized, array($data->text_correct, $data->text_wrong, $data->points));
81  }
82  $a_xml_writer->xmlElement("fieldentry", NULL, serialize($serialized));
83  $a_xml_writer->xmlEndTag("qtimetadatafield");
84  $a_xml_writer->xmlEndTag("qtimetadata");
85  $a_xml_writer->xmlEndTag("itemmetadata");
86 
87  // PART I: qti presentation
88  $attrs = array(
89  "label" => $this->object->getTitle()
90  );
91  $a_xml_writer->xmlStartTag("presentation", $attrs);
92  // add flow to presentation
93  $a_xml_writer->xmlStartTag("flow");
94  // add material with question text to presentation
95  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
96  // add answers to presentation
97  $a_xml_writer->xmlEndTag("flow");
98  $a_xml_writer->xmlEndTag("presentation");
99 
100  $a_xml_writer->xmlEndTag("item");
101  $a_xml_writer->xmlEndTag("questestinterop");
102 
103  $xml = $a_xml_writer->xmlDumpMem(FALSE);
104  if (!$a_include_header)
105  {
106  $pos = strpos($xml, "?>");
107  $xml = substr($xml, $pos + 2);
108  }
109  return $xml;
110  }
111 
112 }
113 
114 ?>
XML writer class.
Class for question exports.
Class for error text question exports.
addGeneralMetadata(ilXmlWriter $xmlwriter)
xmlHeader()
Writes xml header public.
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
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...