ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 __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. More...
 

Additional Inherited Members

- Data Fields inherited from assQuestionExport
 $object
 
const ITEM_SOLUTIONHINT = 'solutionhint'
 
- 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

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, $DIC, $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addAnswerSpecificFeedback(), assQuestionExport\addGeneralMetadata(), assQuestionExport\addGenericFeedback(), assQuestionExport\addSolutionHints(), IL_INST_ID, and ilXmlWriter\xmlHeader().

23  {
24  global $DIC;
25  $ilias = $DIC['ilias'];
26 
27  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
28  $a_xml_writer = new ilXmlWriter;
29  // set xml header
30  $a_xml_writer->xmlHeader();
31  $a_xml_writer->xmlStartTag("questestinterop");
32  $attrs = array(
33  "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
34  "title" => $this->object->getTitle(),
35  "maxattempts" => $this->object->getNrOfTries()
36  );
37  $a_xml_writer->xmlStartTag("item", $attrs);
38  // add question description
39  $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
40  // add estimated working time
41  $workingtime = $this->object->getEstimatedWorkingTime();
42  $duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
43  $a_xml_writer->xmlElement("duration", null, $duration);
44  // add ILIAS specific metadata
45  $a_xml_writer->xmlStartTag("itemmetadata");
46  $a_xml_writer->xmlStartTag("qtimetadata");
47  $a_xml_writer->xmlStartTag("qtimetadatafield");
48  $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
49  $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
50  $a_xml_writer->xmlEndTag("qtimetadatafield");
51  $a_xml_writer->xmlStartTag("qtimetadatafield");
52  $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
53  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getQuestionType());
54  $a_xml_writer->xmlEndTag("qtimetadatafield");
55  $a_xml_writer->xmlStartTag("qtimetadatafield");
56  $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
57  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getAuthor());
58  $a_xml_writer->xmlEndTag("qtimetadatafield");
59 
60  // additional content editing information
61  $this->addAdditionalContentEditingModeInformation($a_xml_writer);
62  $this->addGeneralMetadata($a_xml_writer);
63 
64  $a_xml_writer->xmlStartTag("qtimetadatafield");
65  $a_xml_writer->xmlElement("fieldlabel", null, "points_wrong");
66  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getPointsWrong());
67  $a_xml_writer->xmlEndTag("qtimetadatafield");
68  $a_xml_writer->xmlStartTag("qtimetadatafield");
69  $a_xml_writer->xmlElement("fieldlabel", null, "errortext");
70  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getErrorText());
71  $a_xml_writer->xmlEndTag("qtimetadatafield");
72  $a_xml_writer->xmlStartTag("qtimetadatafield");
73  $a_xml_writer->xmlElement("fieldlabel", null, "textsize");
74  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getTextSize());
75  $a_xml_writer->xmlEndTag("qtimetadatafield");
76  $a_xml_writer->xmlStartTag("qtimetadatafield");
77  $a_xml_writer->xmlElement("fieldlabel", null, "errordata");
78  $serialized = array();
79  foreach ($this->object->getErrorData() as $data) {
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 = $this->addSolutionHints($a_xml_writer);
105 
106  $a_xml_writer->xmlEndTag("item");
107  $a_xml_writer->xmlEndTag("questestinterop");
108 
109  $xml = $a_xml_writer->xmlDumpMem(false);
110  if (!$a_include_header) {
111  $pos = strpos($xml, "?>");
112  $xml = substr($xml, $pos + 2);
113  }
114  return $xml;
115  }
$data
Definition: storeScorm.php:23
const IL_INST_ID
Definition: constants.php:38
XML writer class.
addAnswerSpecificFeedback(ilXmlWriter $a_xml_writer, $answers)
addGeneralMetadata(ilXmlWriter $xmlwriter)
global $DIC
Definition: goto.php:24
xmlHeader()
Writes xml header public.
$xml
Definition: metadata.php:332
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
addSolutionHints(ilXmlWriter $writer)
addGenericFeedback(ilXmlWriter $a_xml_writer)
+ Here is the call graph for this function:

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