ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
assErrorTextExport Class Reference

Class for error text question exports. More...

+ Inheritance diagram for assErrorTextExport:
+ Collaboration diagram for assErrorTextExport:

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 and sets the internal domxml variable with the DOM XML representation of the QTI xml representation. More...
 
- Public Member Functions inherited from assQuestionExport
 assQuestionExport (&$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. More...
 

Additional Inherited Members

- Data Fields inherited from assQuestionExport
 $object
 
- 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)
 

Detailed Description

Class for error text question exports.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 13 of file class.assErrorTextExport.php.

Member Function Documentation

◆ toXML()

assErrorTextExport::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 XML representation of the QTI xml representation.

Returns
string The QTI xml representation of the question public

Definition at line 22 of file class.assErrorTextExport.php.

References $data, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addAnswerSpecificFeedback(), assQuestionExport\addGeneralMetadata(), assQuestionExport\addGenericFeedback(), and ilXmlWriter\xmlHeader().

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  $this->addGenericFeedback($a_xml_writer);
101 
102  $this->addAnswerSpecificFeedback($a_xml_writer, $this->object->getErrorData());
103 
104  $a_xml_writer->xmlEndTag("item");
105  $a_xml_writer->xmlEndTag("questestinterop");
106 
107  $xml = $a_xml_writer->xmlDumpMem(FALSE);
108  if (!$a_include_header)
109  {
110  $pos = strpos($xml, "?>");
111  $xml = substr($xml, $pos + 2);
112  }
113  return $xml;
114  }
XML writer class.
addAnswerSpecificFeedback(ilXmlWriter $a_xml_writer, $answers)
addGeneralMetadata(ilXmlWriter $xmlwriter)
$data
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...
addGenericFeedback(ilXmlWriter $a_xml_writer)
+ Here is the call graph for this function:

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