本文整理汇总了PHP中ilXmlWriter::xmlHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP ilXmlWriter::xmlHeader方法的具体用法?PHP ilXmlWriter::xmlHeader怎么用?PHP ilXmlWriter::xmlHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilXmlWriter
的用法示例。
在下文中一共展示了ilXmlWriter::xmlHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportScorm
/**
* Export (authoring) scorm package
*/
function exportScorm($a_inst, $a_target_dir, $ver, &$expLog)
{
$a_xml_writer = new ilXmlWriter();
// export metadata
$this->exportXMLMetaData($a_xml_writer);
$metadata_xml = $a_xml_writer->xmlDumpMem(false);
$a_xml_writer->_XmlWriter;
$xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/metadata.xsl");
$args = array('/_xml' => $metadata_xml, '/_xsl' => $xsl);
$xh = xslt_create();
$output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
xslt_free($xh);
file_put_contents($a_target_dir . '/indexMD.xml', $output);
// export glossary
if ($this->getAssignedGlossary() != 0) {
ilUtil::makeDir($a_target_dir . "/glossary");
include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
include_once "./Modules/Glossary/classes/class.ilGlossaryExport.php";
$glo_xml_writer = new ilXmlWriter();
$glo_xml_writer->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
// set xml header
$glo_xml_writer->xmlHeader();
$glos = new ilObjGlossary($this->getAssignedGlossary(), false);
//$glos->exportHTML($a_target_dir."/glossary", $expLog);
$glos_export = new ilGlossaryExport($glos, "xml");
$glos->exportXML($glo_xml_writer, $glos_export->getInstId(), $a_target_dir . "/glossary", $expLog);
$glo_xml_writer->xmlDumpFile($a_target_dir . "/glossary/glossary.xml");
$glo_xml_writer->_XmlWriter;
}
$a_xml_writer = new ilXmlWriter();
// set dtd definition
$a_xml_writer->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
// set generated comment
$a_xml_writer->xmlSetGenCmt("Export of ILIAS Content Module " . $this->getId() . " of installation " . $a_inst . ".");
// set xml header
$a_xml_writer->xmlHeader();
global $ilBench;
$a_xml_writer->xmlStartTag("ContentObject", array("Type" => "SCORM2004LearningModule"));
// MetaData
$this->exportXMLMetaData($a_xml_writer);
$this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
// SCO Objects
$expLog->write(date("[y-m-d H:i:s] ") . "Start Export Sco Objects");
$this->exportXMLScoObjects($a_inst, $a_target_dir, $ver, $expLog);
$expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Sco Objects");
$a_xml_writer->xmlEndTag("ContentObject");
$a_xml_writer->xmlDumpFile($a_target_dir . '/index.xml', false);
if ($ver == "2004 4th") {
$revision = "4th";
$ver = "2004";
}
if ($ver == "2004 3rd") {
$revision = "3rd";
$ver = "2004";
}
// add content css (note: this is also done per item)
$css_dir = $a_target_dir . "/ilias_css_4_2";
ilUtil::makeDir($css_dir);
include_once "./Modules/Scorm2004/classes/class.ilScormExportUtil.php";
ilScormExportUtil::exportContentCSS($this, $css_dir);
// add manifest
include_once "./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php";
$manifestBuilder = new ilContObjectManifestBuilder($this);
$manifestBuilder->buildManifest($ver, $revision);
$manifestBuilder->dump($a_target_dir);
$xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/module.xsl");
$args = array('/_xml' => file_get_contents($a_target_dir . "/imsmanifest.xml"), '/_xsl' => $xsl);
$xh = xslt_create();
$output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
xslt_free($xh);
fputs(fopen($a_target_dir . '/index.html', 'w+'), $output);
// copy xsd files to target
switch ($ver) {
case "2004":
if ($revision == "3rd") {
ilUtil::rCopy('./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004', $a_target_dir, false);
}
if ($revision == "4th") {
ilUtil::rCopy('./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004_4th', $a_target_dir, false);
}
break;
case "12":
ilUtil::rCopy('./Modules/Scorm2004/templates/xsd/adlcp_120_export_12', $a_target_dir, false);
break;
}
$a_xml_writer->_XmlWriter;
}
示例2: exportScorm
function exportScorm($a_inst, $a_target_dir, $ver, &$expLog)
{
copy('./xml/ilias_co_3_7.dtd', $a_target_dir . '/ilias_co_3_7.dtd');
copy('./Modules/Scorm2004/templates/xsl/sco.xsl', $a_target_dir . '/sco.xsl');
$a_xml_writer = new ilXmlWriter();
// MetaData
//file_put_contents($a_target_dir.'/indexMD.xml','<lom xmlns="http://ltsc.ieee.org/xsd/LOM"><general/><classification/></lom>');
$this->exportXMLMetaData($a_xml_writer);
$metadata_xml = $a_xml_writer->xmlDumpMem(false);
$a_xml_writer->_XmlWriter;
$xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/metadata.xsl");
$args = array('/_xml' => $metadata_xml, '/_xsl' => $xsl);
$xh = xslt_create();
$output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
xslt_free($xh);
file_put_contents($a_target_dir . '/indexMD.xml', $output);
$a_xml_writer = new ilXmlWriter();
// set dtd definition
$a_xml_writer->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
// set generated comment
$a_xml_writer->xmlSetGenCmt("Export of ILIAS Content Module " . $this->getId() . " of installation " . $a_inst . ".");
// set xml header
$a_xml_writer->xmlHeader();
global $ilBench;
$a_xml_writer->xmlStartTag("ContentObject", array("Type" => "SCORM2004SCO"));
$this->exportXMLMetaData($a_xml_writer);
$this->exportXMLPageObjects($a_target_dir, $a_xml_writer, $a_inst, $expLog);
$this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
$this->exportHTML($a_inst, $a_target_dir, $expLog);
//overwrite scorm.js for scrom 1.2
if ($ver == "12") {
copy('./Modules/Scorm2004/scripts/scorm_12.js', $a_target_dir . '/js/scorm.js');
}
$a_xml_writer->xmlEndTag("ContentObject");
$a_xml_writer->xmlDumpFile($a_target_dir . '/index.xml', false);
$a_xml_writer->_XmlWriter;
// export sco data (currently only objective) to sco.xml
if ($this->getType() == "sco") {
$objectives_text = "";
$a_xml_writer = new ilXmlWriter();
$tr_data = $this->getObjectives();
foreach ($tr_data as $data) {
$objectives_text .= $data->getObjectiveID();
}
$a_xml_writer->xmlStartTag("sco");
$a_xml_writer->xmlElement("objective", null, $objectives_text);
$a_xml_writer->xmlEndTag("sco");
$a_xml_writer->xmlDumpFile($a_target_dir . '/sco.xml', false);
$a_xml_writer->_XmlWriter;
}
}
示例3: toXML
/**
* export questions to xml
*/
function toXML($questions)
{
if (!is_array($questions)) {
$questions =& $this->getQuestions();
}
if (count($questions) == 0) {
$questions =& $this->getQuestions();
}
$xml = "";
include_once "./Services/Xml/classes/class.ilXmlWriter.php";
$a_xml_writer = new ilXmlWriter();
// set xml header
$a_xml_writer->xmlHeader();
$attrs = array("xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd");
$a_xml_writer->xmlStartTag("surveyobject", $attrs);
$attrs = array("id" => "qpl_" . $this->getId(), "label" => $this->getTitle(), "online" => $this->getOnline());
$a_xml_writer->xmlStartTag("surveyquestions", $attrs);
$a_xml_writer->xmlElement("dummy", NULL, "dummy");
// add ILIAS specific metadata
$a_xml_writer->xmlStartTag("metadata");
$a_xml_writer->xmlStartTag("metadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
include_once "./Services/MetaData/classes/class.ilMD.php";
$md = new ilMD($this->getId(), 0, $this->getType());
$writer = new ilXmlWriter();
$md->toXml($writer);
$metadata = $writer->xmlDumpMem();
$a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
$a_xml_writer->xmlEndTag("metadatafield");
$a_xml_writer->xmlEndTag("metadata");
$a_xml_writer->xmlEndTag("surveyquestions");
$a_xml_writer->xmlEndTag("surveyobject");
$xml = $a_xml_writer->xmlDumpMem(FALSE);
$questionxml = "";
foreach ($questions as $key => $value) {
$questiontype = $this->getQuestiontype($value);
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
SurveyQuestion::_includeClass($questiontype);
$question = new $questiontype();
$question->loadFromDb($value);
$questionxml .= $question->toXML(false);
}
$xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
return $xml;
}
示例4: toXML
/**
* 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
*
* @return string The QTI xml representation of the question
* @access public
*/
function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
{
global $ilias;
include_once "./Services/Xml/classes/class.ilXmlWriter.php";
$a_xml_writer = new ilXmlWriter();
// set xml header
$a_xml_writer->xmlHeader();
$a_xml_writer->xmlStartTag("questestinterop");
$attrs = array("ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(), "title" => $this->object->getTitle(), "maxattempts" => $this->object->getNrOfTries());
$a_xml_writer->xmlStartTag("item", $attrs);
// add question description
$a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
// add estimated working time
$workingtime = $this->object->getEstimatedWorkingTime();
$duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
$a_xml_writer->xmlElement("duration", NULL, $duration);
// add ILIAS specific metadata
$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, NUMERIC_QUESTION_IDENTIFIER);
$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");
// additional content editing information
$this->addAdditionalContentEditingModeInformation($a_xml_writer);
$this->addGeneralMetadata($a_xml_writer);
$a_xml_writer->xmlEndTag("qtimetadata");
$a_xml_writer->xmlEndTag("itemmetadata");
// PART I: qti presentation
$attrs = array("label" => $this->object->getTitle());
$a_xml_writer->xmlStartTag("presentation", $attrs);
// add flow to presentation
$a_xml_writer->xmlStartTag("flow");
// add material with question text to presentation
$this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
// add answers to presentation
$attrs = array("ident" => "NUM", "rcardinality" => "Single", "numtype" => "Decimal");
$a_xml_writer->xmlStartTag("response_num", $attrs);
$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");
}
}
// shuffle output
$attrs = array("fibtype" => "Decimal", "maxchars" => $this->object->getMaxChars());
$a_xml_writer->xmlStartTag("render_fib", $attrs);
$a_xml_writer->xmlEndTag("render_fib");
$a_xml_writer->xmlEndTag("response_num");
$a_xml_writer->xmlEndTag("flow");
$a_xml_writer->xmlEndTag("presentation");
// PART II: qti resprocessing
$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");
// add response conditions
$a_xml_writer->xmlStartTag("respcondition");
// qti conditionvar
$a_xml_writer->xmlStartTag("conditionvar");
$attrs = array("respident" => "NUM");
$a_xml_writer->xmlElement("vargte", $attrs, $this->object->getLowerLimit());
$a_xml_writer->xmlElement("varlte", $attrs, $this->object->getUpperLimit());
$a_xml_writer->xmlEndTag("conditionvar");
// qti setvar
$attrs = array("action" => "Add");
$a_xml_writer->xmlElement("setvar", $attrs, $this->object->getPoints());
// qti displayfeedback
$attrs = array("feedbacktype" => "Response", "linkrefid" => "Correct");
$a_xml_writer->xmlElement("displayfeedback", $attrs);
$a_xml_writer->xmlEndTag("respcondition");
$feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation($this->object->getId(), true);
if (strlen($feedback_allcorrect)) {
$attrs = array("continue" => "Yes");
$a_xml_writer->xmlStartTag("respcondition", $attrs);
//.........这里部分代码省略.........
示例5: toXML
/**
* Returns a QTI xml representation of the test
*
* @return string The QTI xml representation of the test
*/
public function toXML()
{
include_once "./Services/Xml/classes/class.ilXmlWriter.php";
$a_xml_writer = new ilXmlWriter();
// set xml header
$a_xml_writer->xmlHeader();
$a_xml_writer->xmlSetDtdDef("<!DOCTYPE questestinterop SYSTEM \"ims_qtiasiv1p2p1.dtd\">");
$a_xml_writer->xmlStartTag("questestinterop");
$attrs = array("ident" => "il_" . IL_INST_ID . "_tst_" . $this->getTestId(), "title" => $this->getTitle());
$a_xml_writer->xmlStartTag("assessment", $attrs);
// add qti comment
$a_xml_writer->xmlElement("qticomment", NULL, $this->getDescription());
// add qti duration
if ($this->enable_processing_time) {
preg_match("/(\\d+):(\\d+):(\\d+)/", $this->processing_time, $matches);
$a_xml_writer->xmlElement("duration", NULL, sprintf("P0Y0M0DT%dH%dM%dS", $matches[1], $matches[2], $matches[3]));
}
// add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI
$a_xml_writer->xmlStartTag("qtimetadata");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "ILIAS_VERSION");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->ilias->getSetting("ilias_version"));
$a_xml_writer->xmlEndTag("qtimetadatafield");
// anonymity
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "anonymity");
$a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getAnonymity()));
$a_xml_writer->xmlEndTag("qtimetadatafield");
// question set type (fixed, random, dynamic, ...)
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "question_set_type");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getQuestionSetType());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// sequence settings
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "sequence_settings");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getSequenceSettings());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// author
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "author");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getAuthor());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// reset processing time
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "reset_processing_time");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getResetProcessingTime());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// count system
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "count_system");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getCountSystem());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// multiple choice scoring
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "mc_scoring");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getMCScoring());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// multiple choice scoring
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "score_cutting");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getScoreCutting());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// multiple choice scoring
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "password");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getPassword());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// allowed users
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "allowedUsers");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getAllowedUsers());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// allowed users time gap
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "allowedUsersTimeGap");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getAllowedUsersTimeGap());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// pass scoring
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "pass_scoring");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getPassScoring());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// score reporting date
if ($this->getReportingDate()) {
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "reporting_date");
preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->reporting_date, $matches);
$a_xml_writer->xmlElement("fieldentry", NULL, sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
$a_xml_writer->xmlEndTag("qtimetadatafield");
}
// number of tries
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "nr_of_tries");
$a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getNrOfTries()));
//.........这里部分代码省略.........
示例6: toXML
/**
* 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
*
* @return string The QTI xml representation of the question
* @access public
*/
function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
{
global $ilias;
include_once "./classes/class.ilXmlWriter.php";
$a_xml_writer = new ilXmlWriter();
// set xml header
$a_xml_writer->xmlHeader();
$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);
// add question description
$a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
// add estimated working time
$workingtime = $this->object->getEstimatedWorkingTime();
$duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
$a_xml_writer->xmlElement("duration", NULL, $duration);
// add ILIAS specific metadata
$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");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "textrating");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getTextRating());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "requestedanswers");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getCorrectAnswers());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlEndTag("qtimetadata");
// removed additional metadata from assFormulaQuestion
$a_xml_writer->xmlEndTag("itemmetadata");
// PART I: qti presentation
$attrs = array("label" => $this->object->getTitle());
$a_xml_writer->xmlStartTag("presentation", $attrs);
// add flow to presentation
$a_xml_writer->xmlStartTag("flow");
// add material with question text to presentation
$this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
// add answers to presentation
$attrs = array();
$attrs = array("ident" => "SYNTAX TREE", "rcardinality" => "Multiple");
$a_xml_writer->xmlStartTag("response_lid", $attrs);
$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");
}
}
// shuffle output
$attrs = array();
$a_xml_writer->xmlStartTag("render_choice", $attrs);
$answers =& $this->object->getAnswers();
$akeys = array_keys($answers);
if ($this->object->getShuffle() && $a_shuffle) {
$akeys = $this->object->pcArrayShuffle($akeys);
}
// add answers
foreach ($akeys as $index) {
$answer = $answers[$index];
$attrs = array("ident" => $index);
$a_xml_writer->xmlStartTag("response_label", $attrs);
$this->object->addQTIMaterial($a_xml_writer, $answer->getAnswertext());
$a_xml_writer->xmlEndTag("response_label");
}
$a_xml_writer->xmlEndTag("render_choice");
$a_xml_writer->xmlEndTag("response_lid");
$a_xml_writer->xmlEndTag("flow");
$a_xml_writer->xmlEndTag("presentation");
// PART II: qti resprocessing
//.........这里部分代码省略.........
示例7: getXmlRepresentation
/**
* Get xml representation
* <dataset install_id="123" install_url="...">
* <types entity="table_name" version="4.0.1">
* <ftype name="field_1" type="text" />
* <ftype name="field_2" type="date" />
* <ftype name="field_3" type="integer" />
* </types>
* <types ...>
* ...
* </types>
* <set entity="table_name">
* <rec>
* <field_1>content</field_1>
* <field_2>my_date</field_2>
* <field_3>my_number</field_3>
* </rec>
* ...
* </set>
* </dataset>
*/
final function getXmlRepresentation($a_entity, $a_schema_version, $a_ids, $a_field = "", $a_omit_header = false, $a_omit_types = false)
{
$this->dircnt = 1;
// step 1: check target release and supported versions
// step 2: init writer
include_once "./Services/Xml/classes/class.ilXmlWriter.php";
$writer = new ilXmlWriter();
if (!$a_omit_header) {
$writer->xmlHeader();
}
// collect namespaces
$namespaces = $prefixes = array();
$this->getNamespaces($namespaces, $a_entity, $a_schema_version);
$atts = array("InstallationId" => IL_INST_ID, "InstallationUrl" => ILIAS_HTTP_PATH, "TopEntity" => $a_entity);
$cnt = 1;
foreach ($namespaces as $entity => $ns) {
$prefix = "ns" . $cnt;
$prefixes[$entity] = $prefix;
// $atts["xmlns:".$prefix] = $ns;
$cnt++;
}
$writer->xmlStartTag($this->getDSPrefixString() . 'DataSet', $atts);
// add types
if (!$a_omit_types) {
$this->addTypesXml($writer, $a_entity, $a_schema_version);
}
// add records
$this->addRecordsXml($writer, $prefixes, $a_entity, $a_schema_version, $a_ids, $a_field = "");
$writer->xmlEndTag($this->getDSPrefixString() . "DataSet");
//if ($a_entity == "mep")
//{
// echo "<pre>".htmlentities($writer->xmlDumpMem(true))."</pre>"; exit;
//}
return $writer->xmlDumpMem(false);
}
示例8: toXML
/**
* Returns a QTI xml representation of the question and sets the internal
* domxml variable with the DOM XML representation of the QTI xml representation
*
* @return string The QTI xml representation of the question
* @access public
*/
function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
{
global $ilias;
include_once "./Services/Xml/classes/class.ilXmlWriter.php";
$a_xml_writer = new ilXmlWriter();
// set xml header
$a_xml_writer->xmlHeader();
$a_xml_writer->xmlStartTag("questestinterop");
$attrs = array("ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(), "title" => $this->object->getTitle(), "maxattempts" => $this->object->getNrOfTries());
$a_xml_writer->xmlStartTag("item", $attrs);
// add question description
$a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
// add estimated working time
$workingtime = $this->object->getEstimatedWorkingTime();
$duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
$a_xml_writer->xmlElement("duration", NULL, $duration);
// add ILIAS specific metadata
$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");
// additional content editing information
$this->addAdditionalContentEditingModeInformation($a_xml_writer);
$this->addGeneralMetadata($a_xml_writer);
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "points_wrong");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getPointsWrong());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "errortext");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getErrorText());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "textsize");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getTextSize());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "errordata");
$serialized = array();
foreach ($this->object->getErrorData() as $data) {
array_push($serialized, array($data->text_correct, $data->text_wrong, $data->points));
}
$a_xml_writer->xmlElement("fieldentry", NULL, serialize($serialized));
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlEndTag("qtimetadata");
$a_xml_writer->xmlEndTag("itemmetadata");
// PART I: qti presentation
$attrs = array("label" => $this->object->getTitle());
$a_xml_writer->xmlStartTag("presentation", $attrs);
// add flow to presentation
$a_xml_writer->xmlStartTag("flow");
// add material with question text to presentation
$this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
// add answers to presentation
$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;
}
示例9: toXML
/**
* 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
*
* @return string The QTI xml representation of the question
* @access public
*/
function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
{
global $ilias;
include_once "./Services/Xml/classes/class.ilXmlWriter.php";
$a_xml_writer = new ilXmlWriter();
// set xml header
$a_xml_writer->xmlHeader();
$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);
// add question description
$a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
// add estimated working time
$workingtime = $this->object->getEstimatedWorkingTime();
$duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
$a_xml_writer->xmlElement("duration", NULL, $duration);
// add ILIAS specific metadata
$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");
//
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "option_string");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getOptionString());
$a_xml_writer->xmlEndTag("qtimetadatafield");
//
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "sample_solution");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getSampleSolution());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlEndTag("qtimetadata");
$a_xml_writer->xmlEndTag("itemmetadata");
// PART I: qti presentation
$attrs = array("label" => $this->object->getTitle());
$a_xml_writer->xmlStartTag("presentation", $attrs);
// add flow to presentation
$a_xml_writer->xmlStartTag("flow");
// add material with question text to presentation
$this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
$a_xml_writer->xmlEndTag("flow");
$a_xml_writer->xmlEndTag("presentation");
// PART III: qti itemfeedback
$feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation($this->object->getId(), true);
$feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation($this->object->getId(), false);
$attrs = array("ident" => "Correct", "view" => "All");
$a_xml_writer->xmlStartTag("itemfeedback", $attrs);
// qti flow_mat
$a_xml_writer->xmlStartTag("flow_mat");
$a_xml_writer->xmlStartTag("material");
$a_xml_writer->xmlElement("mattext");
$a_xml_writer->xmlEndTag("material");
$a_xml_writer->xmlEndTag("flow_mat");
$a_xml_writer->xmlEndTag("itemfeedback");
if (strlen($feedback_allcorrect)) {
$attrs = array("ident" => "response_allcorrect", "view" => "All");
$a_xml_writer->xmlStartTag("itemfeedback", $attrs);
// qti flow_mat
$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);
// qti flow_mat
$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, "?>");
//.........这里部分代码省略.........
示例10: toXML
/**
* 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
*
* @return string The QTI xml representation of the question
* @access public
*/
function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
{
global $ilias;
include_once "./Services/Xml/classes/class.ilXmlWriter.php";
$a_xml_writer = new ilXmlWriter();
// set xml header
$a_xml_writer->xmlHeader();
$a_xml_writer->xmlStartTag("questestinterop");
$attrs = array("ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(), "title" => $this->object->getTitle(), "maxattempts" => $this->object->getNrOfTries());
$a_xml_writer->xmlStartTag("item", $attrs);
// add question description
$a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
// add estimated working time
$workingtime = $this->object->getEstimatedWorkingTime();
$duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
$a_xml_writer->xmlElement("duration", NULL, $duration);
// add ILIAS specific metadata
$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");
// additional content editing information
$this->addAdditionalContentEditingModeInformation($a_xml_writer);
$this->addGeneralMetadata($a_xml_writer);
$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");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "width");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getWidth());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "height");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getHeight());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "applet");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getApplet());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "swf");
$flashpath = $this->object->getFlashPath() . $this->object->getApplet();
$fh = @fopen($flashpath, "rb");
$base64 = "";
if ($fh != FALSE) {
$flashfile = fread($fh, filesize($flashpath));
fclose($fh);
$base64 = base64_encode($flashfile);
}
$a_xml_writer->xmlElement("fieldentry", NULL, $base64);
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "params");
$a_xml_writer->xmlElement("fieldentry", NULL, serialize($this->object->getParameters()));
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlEndTag("qtimetadata");
$a_xml_writer->xmlEndTag("itemmetadata");
// PART I: qti presentation
$attrs = array("label" => $this->object->getTitle());
$a_xml_writer->xmlStartTag("presentation", $attrs);
// add flow to presentation
$a_xml_writer->xmlStartTag("flow");
// add material with question text to presentation
$this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
// add answers to presentation
$a_xml_writer->xmlEndTag("flow");
$a_xml_writer->xmlEndTag("presentation");
$this->exportFeedbackOnly($a_xml_writer);
$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;
}
示例11: toXML
/**
* 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
*
* @return string The QTI xml representation of the question
* @access public
*/
function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
{
global $ilias;
include_once 'Services/Xml/classes/class.ilXmlWriter.php';
$a_xml_writer = new ilXmlWriter();
// set xml header
$a_xml_writer->xmlHeader();
$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);
// add question description
$a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
// add estimated working time
$workingtime = $this->object->getEstimatedWorkingTime();
$duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
$a_xml_writer->xmlElement("duration", NULL, $duration);
// add ILIAS specific metadata
$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()));
}
$res = array("precision" => $result->getPrecision(), "tolerance" => $result->getTolerance(), "rangemin" => $result->getRangeMin(), "rangemax" => $result->getRangeMax(), "points" => $result->getPoints(), "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");
}
// additional content editing information
$this->addAdditionalContentEditingModeInformation($a_xml_writer);
$this->addGeneralMetadata($a_xml_writer);
$a_xml_writer->xmlEndTag("qtimetadata");
$a_xml_writer->xmlEndTag("itemmetadata");
// PART I: qti presentation
$attrs = array("label" => $this->object->getTitle());
$a_xml_writer->xmlStartTag("presentation", $attrs);
// add flow to presentation
$a_xml_writer->xmlStartTag("flow");
// add material with question text to presentation
$this->object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
// add answers to presentation
$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;
}
示例12: processExporter
/**
* Process exporter
*
* @param
* @return
*/
function processExporter($a_comp, $a_class, $a_entity, $a_target_release, $a_id)
{
$success = true;
if (!is_array($a_id)) {
if ($a_id == "") {
return;
}
$a_id = array($a_id);
}
// get exporter object
$export_class_file = "./" . $a_comp . "/classes/class." . $a_class . ".php";
//echo "1-".$export_class_file."-"; exit;
if (!is_file($export_class_file)) {
echo "1-not found:" . $export_class_file . "-";
exit;
return false;
}
include_once $export_class_file;
$exp = new $a_class();
if (!isset($this->cnt[$a_comp])) {
$this->cnt[$a_comp] = 1;
} else {
$this->cnt[$a_comp]++;
}
$set_dir_relative = $a_comp . "/set_" . $this->cnt[$a_comp];
$set_dir_absolute = $this->export_run_dir . "/" . $set_dir_relative;
ilUtil::makeDirParents($set_dir_absolute);
$exp->init();
$sv = $exp->determineSchemaVersion($a_entity, $a_target_release);
// process head dependencies
$sequence = $exp->getXmlExportHeadDependencies($a_entity, $a_target_release, $a_id);
foreach ($sequence as $s) {
$comp = explode("/", $s["component"]);
$exp_class = "il" . $comp[1] . "Exporter";
$s = $this->processExporter($s["component"], $exp_class, $s["entity"], $a_target_release, $s["ids"]);
if (!$s) {
$success = false;
}
}
// write export.xml file
$export_writer = new ilXmlWriter();
$export_writer->xmlHeader();
$attribs = array("InstallationId" => IL_INST_ID, "InstallationUrl" => ILIAS_HTTP_PATH, "Entity" => $a_entity, "SchemaVersion" => $sv["schema_version"], "TargetRelease" => $a_target_release, "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xmlns:exp" => "http://www.ilias.de/Services/Export/exp/4_1", "xsi:schemaLocation" => "http://www.ilias.de/Services/Export/exp/4_1 " . ILIAS_HTTP_PATH . "/xml/ilias_export_4_1.xsd");
if ($sv["namespace"] != "" && $sv["xsd_file"] != "") {
$attribs["xsi:schemaLocation"] .= " " . $sv["namespace"] . " " . ILIAS_HTTP_PATH . "/xml/" . $sv["xsd_file"];
$attribs["xmlns"] = $sv["namespace"];
}
if ($sv["uses_dataset"]) {
$attribs["xsi:schemaLocation"] .= " " . "http://www.ilias.de/Services/DataSet/ds/4_3 " . ILIAS_HTTP_PATH . "/xml/ilias_ds_4_3.xsd";
$attribs["xmlns:ds"] = "http://www.ilias.de/Services/DataSet/ds/4_3";
}
$export_writer->xmlStartTag('exp:Export', $attribs);
$dir_cnt = 1;
foreach ($a_id as $id) {
$exp->setExportDirectories($set_dir_relative . "/expDir_" . $dir_cnt, $set_dir_absolute . "/expDir_" . $dir_cnt);
$export_writer->xmlStartTag('exp:ExportItem', array("Id" => $id));
//$xml = $exp->getXmlRepresentation($a_entity, $a_target_release, $id);
$xml = $exp->getXmlRepresentation($a_entity, $sv["schema_version"], $id);
$export_writer->appendXml($xml);
$export_writer->xmlEndTag('exp:ExportItem');
$dir_cnt++;
}
$export_writer->xmlEndTag('exp:Export');
$export_writer->xmlDumpFile($set_dir_absolute . "/export.xml", false);
$this->manifest_writer->xmlElement("ExportFile", array("Component" => $a_comp, "Path" => $set_dir_relative . "/export.xml"));
// process tail dependencies
$sequence = $exp->getXmlExportTailDependencies($a_entity, $a_target_release, $a_id);
foreach ($sequence as $s) {
$comp = explode("/", $s["component"]);
$exp_class = "il" . $comp[1] . "Exporter";
$s = $this->processExporter($s["component"], $exp_class, $s["entity"], $a_target_release, $s["ids"]);
if (!$s) {
$success = false;
}
}
return $success;
}
示例13: toXML
public function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
{
global $ilias;
include_once "./Services/Xml/classes/class.ilXmlWriter.php";
$xml = new ilXmlWriter();
// set xml header
$xml->xmlHeader();
$xml->xmlStartTag("questestinterop");
$attrs = array("ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(), "title" => $this->object->getTitle(), "maxattempts" => $this->object->getNrOfTries());
$xml->xmlStartTag("item", $attrs);
// add question description
$xml->xmlElement("qticomment", NULL, $this->object->getComment());
// add estimated working time
$workingtime = $this->object->getEstimatedWorkingTime();
$duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
$xml->xmlElement("duration", NULL, $duration);
// add ILIAS specific metadata
$xml->xmlStartTag("itemmetadata");
$xml->xmlStartTag("qtimetadata");
$xml->xmlStartTag("qtimetadatafield");
$xml->xmlElement("fieldlabel", NULL, "ILIAS_VERSION");
$xml->xmlElement("fieldentry", NULL, $ilias->getSetting("ilias_version"));
$xml->xmlEndTag("qtimetadatafield");
$xml->xmlStartTag("qtimetadatafield");
$xml->xmlElement("fieldlabel", NULL, "QUESTIONTYPE");
$xml->xmlElement("fieldentry", NULL, KPRIM_CHOICE_QUESTION_IDENTIFIER);
$xml->xmlEndTag("qtimetadatafield");
$xml->xmlStartTag("qtimetadatafield");
$xml->xmlElement("fieldlabel", NULL, "AUTHOR");
$xml->xmlElement("fieldentry", NULL, $this->object->getAuthor());
$xml->xmlEndTag("qtimetadatafield");
// additional content editing information
$this->addAdditionalContentEditingModeInformation($xml);
$this->addGeneralMetadata($xml);
$xml->xmlStartTag("qtimetadatafield");
$xml->xmlElement("fieldlabel", NULL, "answer_type");
$xml->xmlElement("fieldentry", NULL, $this->object->getAnswerType());
$xml->xmlEndTag("qtimetadatafield");
$xml->xmlStartTag("qtimetadatafield");
$xml->xmlElement("fieldlabel", NULL, "thumb_size");
$xml->xmlElement("fieldentry", NULL, $this->object->getThumbSize());
$xml->xmlEndTag("qtimetadatafield");
$xml->xmlStartTag("qtimetadatafield");
$xml->xmlElement("fieldlabel", NULL, "option_label_setting");
$xml->xmlElement("fieldentry", NULL, $this->object->getOptionLabel());
$xml->xmlEndTag("qtimetadatafield");
$xml->xmlStartTag("qtimetadatafield");
$xml->xmlElement("fieldlabel", NULL, "custom_true_option_label");
$xml->xmlElement("fieldentry", NULL, $this->object->getCustomTrueOptionLabel());
$xml->xmlEndTag("qtimetadatafield");
$xml->xmlStartTag("qtimetadatafield");
$xml->xmlElement("fieldlabel", NULL, "custom_false_option_label");
$xml->xmlElement("fieldentry", NULL, $this->object->getCustomFalseOptionLabel());
$xml->xmlEndTag("qtimetadatafield");
$xml->xmlStartTag("qtimetadatafield");
$xml->xmlElement("fieldlabel", NULL, "feedback_setting");
$xml->xmlElement("fieldentry", NULL, $this->object->getSpecificFeedbackSetting());
$xml->xmlEndTag("qtimetadatafield");
$xml->xmlEndTag("qtimetadata");
$xml->xmlEndTag("itemmetadata");
// PART I: qti presentation
$attrs = array("label" => $this->object->getTitle());
$xml->xmlStartTag("presentation", $attrs);
// add flow to presentation
$xml->xmlStartTag("flow");
// add material with question text to presentation
$this->object->addQTIMaterial($xml, $this->object->getQuestion());
// add answers to presentation
$attrs = array("ident" => "MCMR", "rcardinality" => "Multiple");
$xml->xmlStartTag("response_lid", $attrs);
$solution = $this->object->getSuggestedSolution(0);
if (count($solution)) {
if (preg_match("/il_(\\d*?)_(\\w+)_(\\d+)/", $solution["internal_link"], $matches)) {
$xml->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");
$xml->xmlElement("mattext", $attrs, $intlink);
$xml->xmlEndTag("material");
}
}
// shuffle output
$attrs = array();
if ($this->object->isShuffleAnswersEnabled()) {
$attrs = array("shuffle" => "Yes");
} else {
$attrs = array("shuffle" => "No");
}
$xml->xmlStartTag("render_choice", $attrs);
// add answers
$answers =& $this->object->getAnswers();
$akeys = array_keys($answers);
foreach ($akeys as $index) {
$answer = $this->object->getAnswer($index);
$xml->xmlStartTag('response_label', array('ident' => $answer->getPosition()));
if (strlen($answer->getImageFile())) {
$this->object->addQTIMaterial($xml, $answer->getAnswertext(), FALSE, FALSE);
$imagetype = "image/jpeg";
//.........这里部分代码省略.........
示例14: toXML
/**
* 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
*
* @return string The QTI xml representation of the question
* @access public
*/
function toXML($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
{
global $ilias;
include_once "./Services/Math/classes/class.EvalMath.php";
$eval = new EvalMath();
$eval->suppress_errors = TRUE;
include_once "./Services/Xml/classes/class.ilXmlWriter.php";
$a_xml_writer = new ilXmlWriter();
// set xml header
$a_xml_writer->xmlHeader();
$a_xml_writer->xmlStartTag("questestinterop");
$attrs = array("ident" => "il_" . IL_INST_ID . "_qst_" . $this->object->getId(), "title" => $this->object->getTitle(), "maxattempts" => $this->object->getNrOfTries());
$a_xml_writer->xmlStartTag("item", $attrs);
// add question description
$a_xml_writer->xmlElement("qticomment", NULL, $this->object->getComment());
// add estimated working time
$workingtime = $this->object->getEstimatedWorkingTime();
$duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
$a_xml_writer->xmlElement("duration", NULL, $duration);
// add ILIAS specific metadata
$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, CLOZE_TEST_IDENTIFIER);
$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");
// additional content editing information
$this->addAdditionalContentEditingModeInformation($a_xml_writer);
$this->addGeneralMetadata($a_xml_writer);
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "textgaprating");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getTextgapRating());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "fixedTextLength");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getFixedTextLength());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "identicalScoring");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getIdenticalScoring());
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "combinations");
$a_xml_writer->xmlElement("fieldentry", NULL, base64_encode(json_encode($this->object->getGapCombinations())));
$a_xml_writer->xmlEndTag("qtimetadatafield");
$a_xml_writer->xmlEndTag("qtimetadata");
$a_xml_writer->xmlEndTag("itemmetadata");
// PART I: qti presentation
$attrs = array("label" => $this->object->getTitle());
$a_xml_writer->xmlStartTag("presentation", $attrs);
// add flow to presentation
$a_xml_writer->xmlStartTag("flow");
$questionText = $this->object->getQuestion() ? $this->object->getQuestion() : ' ';
$this->object->addQTIMaterial($a_xml_writer, $questionText);
$text_parts = preg_split("/\\[gap.*?\\[\\/gap\\]/", $this->object->getClozeText());
// add material with question text to presentation
for ($i = 0; $i <= $this->object->getGapCount(); $i++) {
$this->object->addQTIMaterial($a_xml_writer, $text_parts[$i]);
if ($i < $this->object->getGapCount()) {
// add gap
$gap = $this->object->getGap($i);
switch ($gap->getType()) {
case CLOZE_SELECT:
// comboboxes
$attrs = array("ident" => "gap_{$i}", "rcardinality" => "Single");
$a_xml_writer->xmlStartTag("response_str", $attrs);
$solution = $this->object->getSuggestedSolution($i);
if (count($solution)) {
if (preg_match("/il_(\\d*?)_(\\w+)_(\\d+)/", $solution["internal_link"], $matches)) {
$attrs = array("label" => "suggested_solution");
$a_xml_writer->xmlStartTag("material", $attrs);
$intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
if (strcmp($matches[1], "") != 0) {
$intlink = $solution["internal_link"];
}
$a_xml_writer->xmlElement("mattext", NULL, $intlink);
$a_xml_writer->xmlEndTag("material");
}
}
$attrs = array("shuffle" => $gap->getShuffle() ? "Yes" : "No");
$a_xml_writer->xmlStartTag("render_choice", $attrs);
// add answers
foreach ($gap->getItems() as $answeritem) {
//.........这里部分代码省略.........
示例15: toXML
/**
* Returns a QTI xml representation of the test
*
* @return string The QTI xml representation of the test
* @access public
*/
function toXML()
{
include_once "./Services/Xml/classes/class.ilXmlWriter.php";
$a_xml_writer = new ilXmlWriter();
// set xml header
$a_xml_writer->xmlHeader();
$a_xml_writer->xmlSetDtdDef("<!DOCTYPE questestinterop SYSTEM \"ims_qtiasiv1p2p1.dtd\">");
$a_xml_writer->xmlStartTag("questestinterop");
$attrs = array("ident" => "il_" . IL_INST_ID . "_tst_" . $this->getTestId(), "title" => $this->getTitle());
$a_xml_writer->xmlStartTag("assessment", $attrs);
// add qti comment
$a_xml_writer->xmlElement("qticomment", NULL, $this->getDescription());
// add qti duration
if ($this->enable_processing_time) {
preg_match("/(\\d+):(\\d+):(\\d+)/", $this->processing_time, $matches);
$a_xml_writer->xmlElement("duration", NULL, sprintf("P0Y0M0DT%dH%dM%dS", $matches[1], $matches[2], $matches[3]));
}
// add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI
$a_xml_writer->xmlStartTag("qtimetadata");
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "ILIAS_VERSION");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->ilias->getSetting("ilias_version"));
$a_xml_writer->xmlEndTag("qtimetadatafield");
// anonymity
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "anonymity");
$a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getAnonymity()));
$a_xml_writer->xmlEndTag("qtimetadatafield");
// random test
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "random_test");
$a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->isRandomTest()));
$a_xml_writer->xmlEndTag("qtimetadatafield");
// sequence settings
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "sequence_settings");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getSequenceSettings());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// author
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "author");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getAuthor());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// reset processing time
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "reset_processing_time");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getResetProcessingTime());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// count system
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "count_system");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getCountSystem());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// multiple choice scoring
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "mc_scoring");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getMCScoring());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// multiple choice scoring
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "score_cutting");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getScoreCutting());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// multiple choice scoring
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "password");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getPassword());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// allowed users
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "allowedUsers");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getAllowedUsers());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// allowed users time gap
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "allowedUsersTimeGap");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getAllowedUsersTimeGap());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// pass scoring
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "pass_scoring");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getPassScoring());
$a_xml_writer->xmlEndTag("qtimetadatafield");
// score reporting date
if ($this->getReportingDate()) {
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "reporting_date");
preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->reporting_date, $matches);
$a_xml_writer->xmlElement("fieldentry", NULL, sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
$a_xml_writer->xmlEndTag("qtimetadatafield");
}
// number of tries
$a_xml_writer->xmlStartTag("qtimetadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "nr_of_tries");
//.........这里部分代码省略.........