ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 
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 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 $DIC, $res, $result, $xml, assQuestionExport\addAdditionalContentEditingModeInformation(), assQuestionExport\addGeneralMetadata(), assQuestionExport\addGenericFeedback(), assQuestionExport\addSolutionHints(), IL_INST_ID, and ilXmlWriter\xmlHeader().

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