ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assFormulaQuestionExport Class Reference

Class for formula question question exports. More...

+ Inheritance diagram for assFormulaQuestionExport:
+ Collaboration diagram for assFormulaQuestionExport:

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. 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
 
- 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 formula question question exports.

assSingleChoiceExport is a class for single choice 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
class.assFormulaQuestionExport.php 1185 2010-02-02 08:36:26Z hschottm

Definition at line 15 of file class.assFormulaQuestionExport.php.

Member Function Documentation

◆ toXML()

assFormulaQuestionExport::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 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 26 of file class.assFormulaQuestionExport.php.

References $res, $result, $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), assQuestionExport\addGenericFeedback(), array, object, and ilXmlWriter\xmlHeader().

27  {
28  global $ilias;
29 
30  include_once 'Services/Xml/classes/class.ilXmlWriter.php';
31  $a_xml_writer = new ilXmlWriter;
32  // set xml header
33  $a_xml_writer->xmlHeader();
34  $a_xml_writer->xmlStartTag("questestinterop");
35  $attrs = array(
36  "ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(),
37  "title" => $this->object->getTitle()
38  );
39  $a_xml_writer->xmlStartTag("item", $attrs);
40  // add question description
41  $a_xml_writer->xmlElement("qticomment", null, $this->object->getComment());
42  // add estimated working time
43  $workingtime = $this->object->getEstimatedWorkingTime();
44  $duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
45  $a_xml_writer->xmlElement("duration", null, $duration);
46  // add ILIAS specific metadata
47  $a_xml_writer->xmlStartTag("itemmetadata");
48  $a_xml_writer->xmlStartTag("qtimetadata");
49  $a_xml_writer->xmlStartTag("qtimetadatafield");
50  $a_xml_writer->xmlElement("fieldlabel", null, "ILIAS_VERSION");
51  $a_xml_writer->xmlElement("fieldentry", null, $ilias->getSetting("ilias_version"));
52  $a_xml_writer->xmlEndTag("qtimetadatafield");
53  $a_xml_writer->xmlStartTag("qtimetadatafield");
54  $a_xml_writer->xmlElement("fieldlabel", null, "QUESTIONTYPE");
55  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getQuestionType());
56  $a_xml_writer->xmlEndTag("qtimetadatafield");
57  $a_xml_writer->xmlStartTag("qtimetadatafield");
58  $a_xml_writer->xmlElement("fieldlabel", null, "AUTHOR");
59  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getAuthor());
60  $a_xml_writer->xmlEndTag("qtimetadatafield");
61  $a_xml_writer->xmlStartTag("qtimetadatafield");
62  $a_xml_writer->xmlElement("fieldlabel", null, "points");
63  $a_xml_writer->xmlElement("fieldentry", null, $this->object->getPoints());
64  $a_xml_writer->xmlEndTag("qtimetadatafield");
65  foreach ($this->object->getVariables() as $variable) {
66  $var = array(
67  "precision" => $variable->getPrecision(),
68  "intprecision" => $variable->getIntprecision(),
69  "rangemin" => $variable->getRangeMin(),
70  "rangemax" => $variable->getRangeMax(),
71  "unit" => (is_object($variable->getUnit())) ? $variable->getUnit()->getUnit() : "",
72  "unitvalue" => (is_object($variable->getUnit())) ? $variable->getUnit()->getId() : ""
73  );
74  $a_xml_writer->xmlStartTag("qtimetadatafield");
75  $a_xml_writer->xmlElement("fieldlabel", null, $variable->getVariable());
76  $a_xml_writer->xmlElement("fieldentry", null, serialize($var));
77  $a_xml_writer->xmlEndTag("qtimetadatafield");
78  }
79  foreach ($this->object->getResults() as $result) {
80  $resultunits = $this->object->getResultUnits($result);
81  $ru = array();
82  foreach ($resultunits as $unit) {
83  array_push($ru, array("unit" => $unit->getUnit(), "unitvalue" => $unit->getId()));
84  }
85  $res = array(
86  "precision" => $result->getPrecision(),
87  "tolerance" => $result->getTolerance(),
88  "rangemin" => $result->getRangeMin(),
89  "rangemax" => $result->getRangeMax(),
90  "points" => $result->getPoints(),
91  "formula" => $result->getFormula(),
92  "rating" => ($result->getRatingSimple()) ? "" : array("sign" => $result->getRatingSign(), "value" => $result->getRatingValue(), "unit" => $result->getRatingUnit()),
93  "unit" => (is_object($result->getUnit())) ? $result->getUnit()->getUnit() : "",
94  "unitvalue" => (is_object($result->getUnit())) ? $result->getUnit()->getId() : "",
95  "resultunits" => $ru
96  );
97  $a_xml_writer->xmlStartTag("qtimetadatafield");
98  $a_xml_writer->xmlElement("fieldlabel", null, $result->getResult());
99  $a_xml_writer->xmlElement("fieldentry", null, serialize($res));
100  $a_xml_writer->xmlEndTag("qtimetadatafield");
101  }
102 
103  // additional content editing information
104  $this->addAdditionalContentEditingModeInformation($a_xml_writer);
105  $this->addGeneralMetadata($a_xml_writer);
106 
107  $a_xml_writer->xmlEndTag("qtimetadata");
108  $a_xml_writer->xmlEndTag("itemmetadata");
109 
110  // PART I: qti presentation
111  $attrs = array(
112  "label" => $this->object->getTitle()
113  );
114  $a_xml_writer->xmlStartTag("presentation", $attrs);
115  // add flow to presentation
116  $a_xml_writer->xmlStartTag("flow");
117  // add material with question text to presentation
118  $this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
119  // add answers to presentation
120  $a_xml_writer->xmlEndTag("flow");
121  $a_xml_writer->xmlEndTag("presentation");
122 
123  $this->addGenericFeedback($a_xml_writer);
124 
125  $a_xml_writer->xmlEndTag("item");
126  $a_xml_writer->xmlEndTag("questestinterop");
127 
128  $xml = $a_xml_writer->xmlDumpMem(false);
129  if (!$a_include_header) {
130  $pos = strpos($xml, "?>");
131  $xml = substr($xml, $pos + 2);
132  }
133  return $xml;
134  }
$result
XML writer class.
addGeneralMetadata(ilXmlWriter $xmlwriter)
$xml
Definition: metadata.php:240
foreach($_POST as $key=> $value) $res
xmlHeader()
Writes xml header public.
Create styles array
The data for the language used.
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)
Create new PHPExcel object
obj_idprivate
+ Here is the call graph for this function:

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