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("./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->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->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());
$solution = $this->object->getSuggestedSolution(0);
if (count($solution))
{
if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches))
{
$a_xml_writer->xmlStartTag("material");
$intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
if (strcmp($matches[1], "") != 0)
{
$intlink = $solution["internal_link"];
}
$attrs = array(
"label" => "suggested_solution"
);
$a_xml_writer->xmlElement("mattext", $attrs, $intlink);
$a_xml_writer->xmlEndTag("material");
}
}
$a_xml_writer->xmlStartTag("material");
$attrs = array(
"label" => "applet data",
"uri" => $this->object->getJavaAppletFilename(),
"height" => $this->object->getJavaHeight(),
"width" => $this->object->getJavaWidth(),
"embedded" => "base64"
);
$javapath = $this->object->getJavaPath() . $this->object->getJavaAppletFilename();
$fh = @fopen($javapath, "rb");
if ($fh == false)
{
return;
}
$javafile = fread($fh, filesize($javapath));
fclose($fh);
$base64 = base64_encode($javafile);
$a_xml_writer->xmlElement("matapplet", $attrs, $base64);
if ($this->object->buildParamsOnly())
{
if ($this->object->getJavaCode())
{
$attrs = array(
"label" => "java_code"
);
$a_xml_writer->xmlElement("mattext", $attrs, $this->object->getJavaCode());
}
if ($this->object->getJavaCodebase())
{
$attrs = array(
"label" => "java_codebase"
);
$a_xml_writer->xmlElement("mattext", $attrs, $this->object->getJavaCodebase());
}
if ($this->object->getJavaArchive())
{
$attrs = array(
"label" => "java_archive"
);
$a_xml_writer->xmlElement("mattext", $attrs, $this->object->getJavaArchive());
}
for ($i = 0; $i < $this->object->getParameterCount(); $i++)
{
$param = $this->object->getParameter($i);
$attrs = array(
"label" => $param["name"]
);
$a_xml_writer->xmlElement("mattext", $attrs, $param["value"]);
}
}
$a_xml_writer->xmlEndTag("material");
$a_xml_writer->xmlStartTag("material");
$attrs = array(
"label" => "points"
);
$a_xml_writer->xmlElement("mattext", $attrs, $this->object->getPoints());
$a_xml_writer->xmlEndTag("material");
$a_xml_writer->xmlEndTag("flow");
$a_xml_writer->xmlEndTag("presentation");
$feedback_allcorrect = $this->object->getFeedbackGeneric(1);
$feedback_onenotcorrect = $this->object->getFeedbackGeneric(0);
if (strlen($feedback_allcorrect . $feedback_onenotcorrect))
{
$a_xml_writer->xmlStartTag("resprocessing");
$a_xml_writer->xmlStartTag("outcomes");
$a_xml_writer->xmlStartTag("decvar");
$a_xml_writer->xmlEndTag("decvar");
$a_xml_writer->xmlEndTag("outcomes");
if (strlen($feedback_allcorrect))
{
$attrs = array(
"continue" => "Yes"
);
$a_xml_writer->xmlStartTag("respcondition", $attrs);
$a_xml_writer->xmlStartTag("conditionvar");
$attrs = array(
"respident" => "points"
);
$a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
$a_xml_writer->xmlEndTag("conditionvar");
$attrs = array(
"feedbacktype" => "Response",
"linkrefid" => "response_allcorrect"
);
$a_xml_writer->xmlElement("displayfeedback", $attrs);
$a_xml_writer->xmlEndTag("respcondition");
}
if (strlen($feedback_onenotcorrect))
{
$attrs = array(
"continue" => "Yes"
);
$a_xml_writer->xmlStartTag("respcondition", $attrs);
$a_xml_writer->xmlStartTag("conditionvar");
$a_xml_writer->xmlStartTag("not");
$attrs = array(
"respident" => "points"
);
$a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
$a_xml_writer->xmlEndTag("not");
$a_xml_writer->xmlEndTag("conditionvar");
$attrs = array(
"feedbacktype" => "Response",
"linkrefid" => "response_onenotcorrect"
);
$a_xml_writer->xmlElement("displayfeedback", $attrs);
$a_xml_writer->xmlEndTag("respcondition");
}
$a_xml_writer->xmlEndTag("resprocessing");
}
if (strlen($feedback_allcorrect))
{
$attrs = array(
"ident" => "response_allcorrect",
"view" => "All"
);
$a_xml_writer->xmlStartTag("itemfeedback", $attrs);
$a_xml_writer->xmlStartTag("flow_mat");
$this->object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
$a_xml_writer->xmlEndTag("flow_mat");
$a_xml_writer->xmlEndTag("itemfeedback");
}
if (strlen($feedback_onenotcorrect))
{
$attrs = array(
"ident" => "response_onenotcorrect",
"view" => "All"
);
$a_xml_writer->xmlStartTag("itemfeedback", $attrs);
$a_xml_writer->xmlStartTag("flow_mat");
$this->object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
$a_xml_writer->xmlEndTag("flow_mat");
$a_xml_writer->xmlEndTag("itemfeedback");
}
$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;
}