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
{
global $ilias;
include_once 'Services/Xml/classes/class.ilXmlWriter.php';
$a_xml_writer->xmlStartTag("questestinterop");
$attrs = array(
"ident" => "il_".IL_INST_ID."_qst_".$this->object->getId(),
"title" => $this->object->getTitle()
);
$a_xml_writer->xmlStartTag("item", $attrs);
$a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
$workingtime = $this->object->getEstimatedWorkingTime();
$duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
$a_xml_writer->xmlElement("duration", NULL, $duration);
$a_xml_writer->xmlStartTag("itemmetadata");
$a_xml_writer->xmlStartTag("qtimetadata");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "ILIAS_VERSION");
$a_xml_writer->xmlElement("fieldentry", NULL, $ilias->getSetting("ilias_version"));
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "QUESTIONTYPE");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getQuestionType());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "AUTHOR");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getAuthor());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "points");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getPoints());
$a_xml_writer->xmlEndTag("qtimetadatafield");
foreach ($this->object->getVariables() as $variable)
{
$var = array(
"precision" => $variable->getPrecision(),
"intprecision" => $variable->getIntprecision(),
"rangemin" => $variable->getRangeMin(),
"rangemax" => $variable->getRangeMax(),
"unit" => (is_object($variable->getUnit())) ? $variable->getUnit()->getUnit() : "",
"unitvalue" => (is_object($variable->getUnit())) ? $variable->getUnit()->getId() : ""
);
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, $variable->getVariable());
$a_xml_writer->xmlElement("fieldentry", NULL, serialize($var));
$a_xml_writer->xmlEndTag("qtimetadatafield");
}
foreach ($this->object->getResults() as
$result)
{
$resultunits = $this->
object->getResultUnits(
$result);
$ru = array();
foreach ($resultunits as $unit)
{
array_push($ru, array("unit" => $unit->getUnit(), "unitvalue" => $unit->getId()));
}
"precision" =>
$result->getPrecision(),
"tolerance" =>
$result->getTolerance(),
"rangemin" =>
$result->getRangeMin(),
"rangemax" =>
$result->getRangeMax(),
"formula" =>
$result->getFormula(),
"rating" => (
$result->getRatingSimple()) ?
"" : array(
"sign" =>
$result->getRatingSign(),
"value" =>
$result->getRatingValue(),
"unit" =>
$result->getRatingUnit()),
"unit" => (is_object(
$result->getUnit())) ?
$result->getUnit()->getUnit() :
"",
"unitvalue" => (is_object(
$result->getUnit())) ?
$result->getUnit()->getId() :
"",
"resultunits" => $ru
);
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement(
"fieldlabel", NULL,
$result->getResult());
$a_xml_writer->xmlElement(
"fieldentry", NULL, serialize(
$res));
$a_xml_writer->xmlEndTag("qtimetadatafield");
}
$a_xml_writer->xmlEndTag("qtimetadata");
$a_xml_writer->xmlEndTag("itemmetadata");
$attrs = array(
"label" => $this->object->getTitle()
);
$a_xml_writer->xmlStartTag("presentation", $attrs);
$a_xml_writer->xmlStartTag("flow");
$this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
$a_xml_writer->xmlEndTag("flow");
$a_xml_writer->xmlEndTag("presentation");
$a_xml_writer->xmlEndTag("item");
$a_xml_writer->xmlEndTag("questestinterop");
$xml = $a_xml_writer->xmlDumpMem(FALSE);
if (!$a_include_header)
{
$pos = strpos($xml, "?>");
$xml = substr($xml, $pos + 2);
}
return $xml;
}