/**
  * Write xml
  * @param ilXmlWriter $writer
  */
 public function toXml(ilXmlWriter $writer)
 {
     switch ($this->getPatternSubType()) {
         case ilDidacticTemplateFilterPattern::PATTERN_SUBTYPE_REGEX:
         default:
             $writer->xmlElement('excludePattern', array('preg' => $this->getPattern()));
     }
 }
 /**
  * Get xml of object values
  *
  * @access public
  * @static
  * @param object instance of ilXmlWriter
  * @param int $a_obj_id
  */
 public static function _appendXMLByObjId(ilXmlWriter $xml_writer, $a_obj_id)
 {
     global $ilDB;
     $type = ilObject::_lookupType($a_obj_id);
     // Get active field_definitions
     $query = "SELECT field_id FROM adv_md_record amr " . "JOIN adv_md_record_objs amro ON amr.record_id = amro.record_id " . "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id " . "WHERE active = 1 " . "AND obj_type = " . $ilDB->quote($type, 'text') . " ";
     $xml_writer->xmlStartTag('AdvancedMetaData');
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php';
         $value = ilAdvancedMDValue::_getInstance($a_obj_id, $row->field_id);
         $value->appendXML($xml_writer);
     }
     $xml_writer->xmlEndTag('AdvancedMetaData');
 }
 /**
  * Constructor
  *
  * @access public
  * @param
  * 
  */
 public function __construct($a_record_ids)
 {
     global $ilSetting;
     parent::ilXmlWriter();
     $this->settings = $ilSetting;
     $this->record_ids = $a_record_ids ? $a_record_ids : array();
 }
 /**
  * constructor
  * @param	string	xml version
  * @param	string	output encoding
  * @param	string	input encoding
  * @access	public
  */
 function ilExerciseXMLWriter()
 {
     // @todo: needs to be revised for multiple assignments per exercise
     //die ("Needs revision for ILIAS 4.1");
     parent::ilXmlWriter();
     $this->attachFileContents = ilExerciseXMLWriter::$CONTENT_ATTACH_NO;
 }
 /**
  * constructor
  * @param	string	xml version
  * @param	string	output encoding
  * @param	string	input encoding
  * @access	public
  */
 function ilObjectXMLWriter()
 {
     global $ilias, $ilUser;
     parent::ilXmlWriter();
     $this->ilias =& $ilias;
     $this->user_id = $ilUser->getId();
 }
 /**
  * constructor
  * @param	string	xml version
  * @param	string	output encoding
  * @param	string	input encoding
  * @access	public
  */
 function ilCourseXMLWriter(&$course_obj)
 {
     global $ilias;
     parent::ilXmlWriter();
     $this->EXPORT_VERSION = "2";
     $this->ilias =& $ilias;
     $this->course_obj =& $course_obj;
 }
 /**
  * constructor
  * @param	string	xml version
  * @param	string	output encoding
  * @param	string	input encoding
  * @access	public
  */
 function ilGroupXMLWriter($group_obj)
 {
     global $ilias;
     parent::ilXmlWriter();
     $this->EXPORT_VERSION = "3";
     $this->ilias =& $ilias;
     $this->group_obj =& $group_obj;
     $this->participants = ilGroupParticipants::_getInstanceByObjId($this->group_obj->getId());
 }
 public function simpleExport($orgu_ref_id)
 {
     $nodes = $this->getStructure($orgu_ref_id);
     $writer = new ilXmlWriter();
     $writer->xmlStartTag("OrgUnits");
     foreach ($nodes as $orgu_ref_id) {
         $orgu = new ilObjOrgUnit($orgu_ref_id);
         if ($orgu->getRefId() == ilObjOrgUnit::getRootOrgRefId()) {
             continue;
         }
         $attrs = $this->getAttrForOrgu($orgu);
         $writer->xmlStartTag("OrgUnit", $attrs);
         $writer->xmlElement("reference_id", null, $orgu->getRefId());
         $writer->xmlElement("external_id", null, $orgu->getImportId());
         $writer->xmlElement("title", null, $orgu->getTitle());
         $writer->xmlElement("description", null, $orgu->getDescription());
         $writer->xmlEndTag("OrgUnit");
     }
     $writer->xmlEndTag("OrgUnits");
     return $writer;
 }
 /**
  * constructor
  * @param	string	xml version
  * @param	string	output encoding
  * @param	string	input encoding
  * @access	public
  */
 function ilUserXMLWriter()
 {
     global $ilias, $ilUser;
     parent::ilXmlWriter();
     $this->ilias =& $ilias;
     $this->user_id = $ilUser->getId();
     $this->attachRoles = false;
     /*		$this->exportablePrefs = array(
     			"priv_feed_pass", "language", "style", "skin", 'ilPageEditor_HTMLMode',
     			 'ilPageEditor_JavaScript', 'ilPageEditor_MediaMode', 'tst_javascript', 
     			 'tst_lastquestiontype', 'tst_multiline_answers', 'tst_use_previous_answers',
     			'graphicalAnswerSetting', "weekstart" 				
     		);*/
 }
 /**
  * Constructor
  * @access	public
  */
 function ilnetucateXMLAPI()
 {
     global $ilias;
     define('ILINC_MEMBER_NOTSET', 'ilinc_notset');
     define('ILINC_MEMBER_DOCENT', 'ilinc_docent');
     define('ILINC_MEMBER_STUDENT', 'ilinc_student');
     parent::ilXmlWriter();
     $this->ilias =& $ilias;
     $this->reg_login = $this->ilias->getSetting("ilinc_registrar_login");
     $this->reg_passwd = $this->ilias->getSetting("ilinc_registrar_passwd");
     $this->customer_id = $this->ilias->getSetting("ilinc_customer_id");
     $this->server_scheme = $this->ilias->getSetting("ilinc_protocol");
     $this->server_addr = $this->ilias->getSetting("ilinc_server");
     $this->server_path = $this->ilias->getSetting("ilinc_path");
     $this->server_port = $this->ilias->getSetting("ilinc_port");
     $this->server_timeout = $this->ilias->getSetting("ilinc_timeout");
     $this->user_max_strlen = 32;
     // Max string length of full username (title + firstname + lastname)
 }
 /**
  * To Xml.
  * This method writes only the subset Record (including all fields)
  * Use class.ilAdvancedMDRecordXMLWriter to generate a complete xml presentation.
  *
  * @access public
  * @param object ilXmlWriter
  * 
  */
 public function toXML(ilXmlWriter $writer)
 {
     $writer->xmlStartTag('Record', array('active' => $this->isActive() ? 1 : 0, 'id' => $this->generateImportId()));
     $writer->xmlElement('Title', null, $this->getTitle());
     $writer->xmlElement('Description', null, $this->getDescription());
     foreach ($this->getAssignedObjectTypes() as $obj_type) {
         $writer->xmlElement('ObjectType', null, $obj_type);
     }
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     foreach (ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($this->getRecordId()) as $definition) {
         $definition->toXML($writer);
     }
     $writer->xmlEndTag('Record');
 }
 /**
  * Returns an xml representation of the question
  *
  * @return string The xml representation of the question
  * @access public
  */
 function toXML($a_include_header = TRUE, $obligatory_state = "")
 {
     include_once "./Services/Xml/classes/class.ilXmlWriter.php";
     $a_xml_writer = new ilXmlWriter();
     $a_xml_writer->xmlHeader();
     $this->insertXML($a_xml_writer, $a_include_header, $obligatory_state);
     $xml = $a_xml_writer->xmlDumpMem(FALSE);
     if (!$a_include_header) {
         $pos = strpos($xml, "?>");
         $xml = substr($xml, $pos + 2);
     }
     return $xml;
 }
 /**
  * constructor
  * @param	string	xml version
  * @param	string	output encoding
  * @param	string	input encoding
  * @access	public
  */
 function ilSoapInstallationInfoXMLWriter()
 {
     parent::ilXmlWriter();
 }
 /**
  * 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
     $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
     foreach ($answers as $index => $answer) {
         $attrs = array("continue" => "Yes");
         $a_xml_writer->xmlStartTag("respcondition", $attrs);
         // qti conditionvar
         $a_xml_writer->xmlStartTag("conditionvar");
         $attrs = array();
         $attrs = array("respident" => "SyntaxTree");
         $a_xml_writer->xmlElement("varequal", $attrs, $index);
         $a_xml_writer->xmlEndTag("conditionvar");
         // qti setvar
         $attrs = array("action" => "Add");
         $a_xml_writer->xmlElement("setvar", $attrs, $answer->getPoints());
         // qti displayfeedback
         $linkrefid = "response_{$index}";
         $attrs = array("feedbacktype" => "Response", "linkrefid" => $linkrefid);
         $a_xml_writer->xmlElement("displayfeedback", $attrs);
         $a_xml_writer->xmlEndTag("respcondition");
     }
     $feedback_allcorrect = $this->object->getFeedbackGeneric(1);
     if (strlen($feedback_allcorrect)) {
         $attrs = array("continue" => "Yes");
         $a_xml_writer->xmlStartTag("respcondition", $attrs);
         // qti conditionvar
         $a_xml_writer->xmlStartTag("conditionvar");
         $bestindex = 0;
         $maxpoints = 0;
         foreach ($answers as $index => $answer) {
             if ($answer->getPoints() > $maxpoints) {
                 $maxpoints = $answer->getPoints();
                 $bestindex = $index;
             }
         }
         $attrs = array("respident" => "SyntaxTree");
         $a_xml_writer->xmlElement("varequal", $attrs, $bestindex);
         $a_xml_writer->xmlEndTag("conditionvar");
         // qti displayfeedback
         $attrs = array("feedbacktype" => "Response", "linkrefid" => "response_allcorrect");
         $a_xml_writer->xmlElement("displayfeedback", $attrs);
         $a_xml_writer->xmlEndTag("respcondition");
     }
     $feedback_onenotcorrect = $this->object->getFeedbackGeneric(0);
     if (strlen($feedback_onenotcorrect)) {
         $attrs = array("continue" => "Yes");
         $a_xml_writer->xmlStartTag("respcondition", $attrs);
         // qti conditionvar
         $a_xml_writer->xmlStartTag("conditionvar");
         $bestindex = 0;
         $maxpoints = 0;
         foreach ($answers as $index => $answer) {
             if ($answer->getPoints() > $maxpoints) {
                 $maxpoints = $answer->getPoints();
                 $bestindex = $index;
             }
         }
         $attrs = array("respident" => "SyntaxTree");
         $a_xml_writer->xmlStartTag("not");
         $a_xml_writer->xmlElement("varequal", $attrs, $bestindex);
         $a_xml_writer->xmlEndTag("not");
         $a_xml_writer->xmlEndTag("conditionvar");
         // qti displayfeedback
         $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);
         // 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, "?>");
         $xml = substr($xml, $pos + 2);
     }
     return $xml;
 }
Example #15
0
 /**
  * Constructor
  */
 public function __construct($a_add_header)
 {
     $this->add_header = $a_add_header;
     parent::__construct();
 }
 protected function addPropertiesToXML(ilXmlWriter $a_writer)
 {
     $a_writer->xmlElement('FieldValue', array("id" => "min"), $this->getMin());
     $a_writer->xmlElement('FieldValue', array("id" => "max"), $this->getMax());
     $a_writer->xmlElement('FieldValue', array("id" => "suffix"), $this->getSuffix());
 }
 /**
  * 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, IMAGEMAP_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");
     $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" => "IM", "rcardinality" => "Single");
     $a_xml_writer->xmlStartTag("response_xy", $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");
         }
     }
     $a_xml_writer->xmlStartTag("render_hotspot");
     $a_xml_writer->xmlStartTag("material");
     $imagetype = "image/jpeg";
     if (preg_match("/.*\\.(png|gif)\$/", $this->object->getImageFilename(), $matches)) {
         $imagetype = "image/" . $matches[1];
     }
     $attrs = array("imagtype" => $imagetype, "label" => $this->object->getImageFilename());
     if ($a_include_binary) {
         if ($force_image_references) {
             $attrs["uri"] = $this->object->getImagePathWeb() . $this->object->getImageFilename();
             $a_xml_writer->xmlElement("matimage", $attrs);
         } else {
             $attrs["embedded"] = "base64";
             $imagepath = $this->object->getImagePath() . $this->object->getImageFilename();
             $fh = fopen($imagepath, "rb");
             if ($fh == false) {
                 global $ilErr;
                 $ilErr->raiseError($this->object->lng->txt("error_open_image_file"), $ilErr->MESSAGE);
                 return;
             }
             $imagefile = fread($fh, filesize($imagepath));
             fclose($fh);
             $base64 = base64_encode($imagefile);
             $a_xml_writer->xmlElement("matimage", $attrs, $base64, FALSE, FALSE);
         }
     } else {
         $a_xml_writer->xmlElement("matimage", $attrs);
     }
     $a_xml_writer->xmlEndTag("material");
     // add answers
     foreach ($this->object->getAnswers() as $index => $answer) {
         $rared = "";
         switch ($answer->getArea()) {
             case "rect":
                 $rarea = "Rectangle";
                 break;
             case "circle":
                 $rarea = "Ellipse";
                 break;
             case "poly":
                 $rarea = "Bounded";
                 break;
         }
         $attrs = array("ident" => $index, "rarea" => $rarea);
         $a_xml_writer->xmlStartTag("response_label", $attrs);
         $a_xml_writer->xmlData($answer->getCoords());
         $a_xml_writer->xmlStartTag("material");
         $a_xml_writer->xmlElement("mattext", NULL, $answer->getAnswertext());
         $a_xml_writer->xmlEndTag("material");
         $a_xml_writer->xmlEndTag("response_label");
     }
     $a_xml_writer->xmlEndTag("render_hotspot");
     $a_xml_writer->xmlEndTag("response_xy");
     $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
     foreach ($this->object->getAnswers() as $index => $answer) {
         $attrs = array("continue" => "Yes");
         $a_xml_writer->xmlStartTag("respcondition", $attrs);
         // qti conditionvar
         $a_xml_writer->xmlStartTag("conditionvar");
         if (!$answer->isStateSet()) {
             $a_xml_writer->xmlStartTag("not");
         }
         $areatype = "";
         switch ($answer->getArea()) {
             case "rect":
                 $areatype = "Rectangle";
                 break;
             case "circle":
                 $areatype = "Ellipse";
                 break;
             case "poly":
                 $areatype = "Bounded";
                 break;
         }
         $attrs = array("respident" => "IM", "areatype" => $areatype);
         $a_xml_writer->xmlElement("varinside", $attrs, $answer->getCoords());
         if (!$answer->isStateSet()) {
             $a_xml_writer->xmlEndTag("not");
         }
         $a_xml_writer->xmlEndTag("conditionvar");
         // qti setvar
         $attrs = array("action" => "Add");
         $a_xml_writer->xmlElement("setvar", $attrs, $answer->getPoints());
         $linkrefid = "response_{$index}";
         $attrs = array("feedbacktype" => "Response", "linkrefid" => $linkrefid);
         $a_xml_writer->xmlElement("displayfeedback", $attrs);
         $a_xml_writer->xmlEndTag("respcondition");
     }
     $answers = $this->object->getAnswers();
     $feedback_allcorrect = $this->object->getFeedbackGeneric(1);
     if (strlen($feedback_allcorrect)) {
         $attrs = array("continue" => "Yes");
         $a_xml_writer->xmlStartTag("respcondition", $attrs);
         // qti conditionvar
         $a_xml_writer->xmlStartTag("conditionvar");
         $bestindex = 0;
         $maxpoints = 0;
         foreach ($answers as $index => $answer) {
             if ($answer->getPoints() > $maxpoints) {
                 $maxpoints = $answer->getPoints();
                 $bestindex = $index;
             }
         }
         $attrs = array("respident" => "IM");
         $areatype = "";
         $answer = $answers[$bestindex];
         switch ($answer->getArea()) {
             case "rect":
                 $areatype = "Rectangle";
                 break;
             case "circle":
                 $areatype = "Ellipse";
                 break;
             case "poly":
                 $areatype = "Bounded";
                 break;
         }
         $attrs = array("respident" => "IM", "areatype" => $areatype);
         $a_xml_writer->xmlElement("varinside", $attrs, $answer->getCoords());
         $a_xml_writer->xmlEndTag("conditionvar");
         // qti displayfeedback
         $attrs = array("feedbacktype" => "Response", "linkrefid" => "response_allcorrect");
         $a_xml_writer->xmlElement("displayfeedback", $attrs);
         $a_xml_writer->xmlEndTag("respcondition");
     }
     $feedback_onenotcorrect = $this->object->getFeedbackGeneric(0);
     if (strlen($feedback_onenotcorrect)) {
         $attrs = array("continue" => "Yes");
         $a_xml_writer->xmlStartTag("respcondition", $attrs);
         // qti conditionvar
         $a_xml_writer->xmlStartTag("conditionvar");
         $bestindex = 0;
         $maxpoints = 0;
         foreach ($answers as $index => $answer) {
             if ($answer->getPoints() > $maxpoints) {
                 $maxpoints = $answer->getPoints();
                 $bestindex = $index;
             }
         }
         $attrs = array("respident" => "IM");
         $a_xml_writer->xmlStartTag("not");
         $areatype = "";
         $answer = $answers[$bestindex];
         switch ($answer->getArea()) {
             case "rect":
                 $areatype = "Rectangle";
                 break;
             case "circle":
                 $areatype = "Ellipse";
                 break;
             case "poly":
                 $areatype = "Bounded";
                 break;
         }
         $attrs = array("respident" => "IM", "areatype" => $areatype);
         $a_xml_writer->xmlElement("varinside", $attrs, $answer->getCoords());
         $a_xml_writer->xmlEndTag("not");
         $a_xml_writer->xmlEndTag("conditionvar");
         // qti displayfeedback
         $attrs = array("feedbacktype" => "Response", "linkrefid" => "response_onenotcorrect");
         $a_xml_writer->xmlElement("displayfeedback", $attrs);
         $a_xml_writer->xmlEndTag("respcondition");
     }
     $a_xml_writer->xmlEndTag("resprocessing");
     // PART III: qti itemfeedback
     foreach ($this->object->getAnswers() as $index => $answer) {
         $linkrefid = "";
         $linkrefid = "response_{$index}";
         $attrs = array("ident" => $linkrefid, "view" => "All");
         $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
         // qti flow_mat
         $a_xml_writer->xmlStartTag("flow_mat");
         $this->object->addQTIMaterial($a_xml_writer, $this->object->getFeedbackSingleAnswer($index));
         $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, "?>");
         $xml = substr($xml, $pos + 2);
     }
     return $xml;
 }
 /**
  * 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, JAVAAPPLET_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");
     $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());
     $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");
     // PART II: qti resprocessing
     $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);
             // qti conditionvar
             $a_xml_writer->xmlStartTag("conditionvar");
             $attrs = array("respident" => "points");
             $a_xml_writer->xmlElement("varequal", $attrs, $this->object->getPoints());
             $a_xml_writer->xmlEndTag("conditionvar");
             // qti displayfeedback
             $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);
             // qti conditionvar
             $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");
             // qti displayfeedback
             $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);
         // 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, "?>");
         $xml = substr($xml, $pos + 2);
     }
     return $xml;
 }
 /**
  * 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)
  * 
  * @final
  * @access protected
  * @param ilXmlWriter $a_xml_writer
  * @param string $fieldLabel
  * @param string $fieldValue
  */
 protected final function addQtiMetaDataField(ilXmlWriter $a_xml_writer, $fieldLabel, $fieldValue)
 {
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, $fieldLabel);
     $a_xml_writer->xmlElement("fieldentry", NULL, $fieldValue);
     $a_xml_writer->xmlEndTag("qtimetadatafield");
 }
Example #20
0
 function exportPDF($a_inst, $a_target_dir, &$expLog)
 {
     global $tpl, $lng, $ilCtrl;
     $a_xml_writer = new ilXmlWriter();
     $a_xml_writer->xmlStartTag("ContentObject", array("Type" => "SCORM2004SCO"));
     $this->exportPDFPrepareXmlNFiles($a_inst, $a_target_dir, $expLog, $a_xml_writer);
     $a_xml_writer->xmlEndTag("ContentObject");
     include_once 'Services/Transformation/classes/class.ilXML2FO.php';
     $xml2FO = new ilXML2FO();
     $xml2FO->setXSLTLocation('./Modules/Scorm2004/templates/xsl/contentobject2fo.xsl');
     $xml2FO->setXMLString($a_xml_writer->xmlDumpMem());
     $xml2FO->setXSLTParams(array('target_dir' => $a_target_dir));
     $xml2FO->transform();
     $fo_string = $xml2FO->getFOString();
     $fo_xml = simplexml_load_string($fo_string);
     $fo_ext = $fo_xml->xpath("//fo:declarations");
     $fo_ext = $fo_ext[0];
     $results = array();
     include_once "./Services/Utilities/classes/class.ilFileUtils.php";
     ilFileUtils::recursive_dirscan($a_target_dir . "/objects", $results);
     if (is_array($results["file"])) {
         foreach ($results["file"] as $key => $value) {
             $e = $fo_ext->addChild("fox:embedded-file", "", "http://xml.apache.org/fop/extensions");
             $e->addAttribute("src", $results[path][$key] . $value);
             $e->addAttribute("name", $value);
             $e->addAttribute("desc", "");
         }
     }
     $fo_string = $fo_xml->asXML();
     $a_xml_writer->_XmlWriter;
     return $fo_string;
 }
 /**
  * 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;
 }
Example #22
0
 function ilMD2XML($a_rbac_id, $a_obj_id, $a_type)
 {
     $this->md_obj =& new ilMD($a_rbac_id, $a_obj_id, $a_type);
     parent::ilXmlWriter();
 }
Example #23
0
 /**
  * 
  * @param object $a_table
  * @param object $a_file [optional]
  * @return 
  */
 function buildInsertStatementsXML($a_table, $a_basedir)
 {
     global $ilLog;
     include_once './Services/Xml/classes/class.ilXmlWriter.php';
     $w = new ilXmlWriter();
     $w->xmlStartTag('Table', array('name' => $a_table));
     $set = $this->il_db->query("SELECT * FROM `" . $a_table . "`");
     $ins_st = "";
     $first = true;
     while ($rec = $this->il_db->fetchAssoc($set)) {
         #$ilLog->write('Num: '.$num++);
         $w->xmlStartTag('Row');
         $fields = array();
         $types = array();
         $values = array();
         foreach ($rec as $f => $v) {
             if ($this->fields[$f]['type'] == 'text' and $this->fields[$f]['length'] >= 1000) {
                 $v = $this->shortenText($a_table, $f, $v, $this->fields[$f]['length']);
             }
             $w->xmlElement('Value', array('name' => $f, 'type' => $this->fields[$f]['type']), $v);
         }
         $w->xmlEndTag('Row');
     }
     $w->xmlEndTag('Table');
     $w->xmlDumpFile($a_basedir . '/' . $a_table . '.xml', 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
  *
  * @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() : '&nbsp;';
     $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) {
                         $attrs = array("ident" => $answeritem->getOrder());
                         $a_xml_writer->xmlStartTag("response_label", $attrs);
                         $a_xml_writer->xmlStartTag("material");
                         $a_xml_writer->xmlElement("mattext", NULL, $answeritem->getAnswertext());
                         $a_xml_writer->xmlEndTag("material");
                         $a_xml_writer->xmlEndTag("response_label");
                     }
                     $a_xml_writer->xmlEndTag("render_choice");
                     $a_xml_writer->xmlEndTag("response_str");
                     break;
                 case CLOZE_TEXT:
                     // text fields
                     $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("fibtype" => "String", "prompt" => "Box", "columns" => $gap->getGapSize());
                     $a_xml_writer->xmlStartTag("render_fib", $attrs);
                     $a_xml_writer->xmlEndTag("render_fib");
                     $a_xml_writer->xmlEndTag("response_str");
                     break;
                 case CLOZE_NUMERIC:
                     // numeric fields
                     $attrs = array("ident" => "gap_{$i}", "numtype" => "Decimal", "rcardinality" => "Single");
                     $a_xml_writer->xmlStartTag("response_num", $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");
                         }
                     }
                     $answeritem = $gap->getItem(0);
                     $attrs = array("fibtype" => "Decimal", "prompt" => "Box", "columns" => $gap->getGapSize());
                     if (is_object($answeritem)) {
                         if ($eval->e($answeritem->getLowerBound()) !== FALSE) {
                             $attrs["minnumber"] = $answeritem->getLowerBound();
                         }
                         if ($eval->e($answeritem->getUpperBound()) !== FALSE) {
                             $attrs["maxnumber"] = $answeritem->getUpperBound();
                         }
                     }
                     $a_xml_writer->xmlStartTag("render_fib", $attrs);
                     $a_xml_writer->xmlEndTag("render_fib");
                     $a_xml_writer->xmlEndTag("response_num");
                     break;
             }
         }
     }
     $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
     for ($i = 0; $i < $this->object->getGapCount(); $i++) {
         $gap = $this->object->getGap($i);
         switch ($gap->getType()) {
             case CLOZE_SELECT:
                 foreach ($gap->getItems() as $answer) {
                     $attrs = array("continue" => "Yes");
                     $a_xml_writer->xmlStartTag("respcondition", $attrs);
                     // qti conditionvar
                     $a_xml_writer->xmlStartTag("conditionvar");
                     $attrs = array("respident" => "gap_{$i}");
                     $a_xml_writer->xmlElement("varequal", $attrs, $answer->getAnswertext());
                     $a_xml_writer->xmlEndTag("conditionvar");
                     // qti setvar
                     $attrs = array("action" => "Add");
                     $a_xml_writer->xmlElement("setvar", $attrs, $answer->getPoints());
                     // qti displayfeedback
                     $linkrefid = "";
                     $linkrefid = "{$i}" . "_Response_" . $answer->getOrder();
                     $attrs = array("feedbacktype" => "Response", "linkrefid" => $linkrefid);
                     $a_xml_writer->xmlElement("displayfeedback", $attrs);
                     $a_xml_writer->xmlEndTag("respcondition");
                 }
                 break;
             case CLOZE_TEXT:
                 foreach ($gap->getItems() as $answer) {
                     $attrs = array("continue" => "Yes");
                     $a_xml_writer->xmlStartTag("respcondition", $attrs);
                     // qti conditionvar
                     $a_xml_writer->xmlStartTag("conditionvar");
                     $attrs = array("respident" => "gap_{$i}");
                     $a_xml_writer->xmlElement("varequal", $attrs, $answer->getAnswertext());
                     $a_xml_writer->xmlEndTag("conditionvar");
                     // qti setvar
                     $attrs = array("action" => "Add");
                     $a_xml_writer->xmlElement("setvar", $attrs, $answer->getPoints());
                     // qti displayfeedback
                     $linkrefid = "{$i}" . "_Response_" . $answer->getOrder();
                     $attrs = array("feedbacktype" => "Response", "linkrefid" => $linkrefid);
                     $a_xml_writer->xmlElement("displayfeedback", $attrs);
                     $a_xml_writer->xmlEndTag("respcondition");
                 }
                 break;
             case CLOZE_NUMERIC:
                 foreach ($gap->getItems() as $answer) {
                     $attrs = array("continue" => "Yes");
                     $a_xml_writer->xmlStartTag("respcondition", $attrs);
                     // qti conditionvar
                     $a_xml_writer->xmlStartTag("conditionvar");
                     $attrs = array("respident" => "gap_{$i}");
                     $a_xml_writer->xmlElement("varequal", $attrs, $answer->getAnswertext());
                     $a_xml_writer->xmlEndTag("conditionvar");
                     // qti setvar
                     $attrs = array("action" => "Add");
                     $a_xml_writer->xmlElement("setvar", $attrs, $answer->getPoints());
                     // qti displayfeedback
                     $linkrefid = "{$i}" . "_Response_" . $answer->getOrder();
                     $attrs = array("feedbacktype" => "Response", "linkrefid" => $linkrefid);
                     $a_xml_writer->xmlElement("displayfeedback", $attrs);
                     $a_xml_writer->xmlEndTag("respcondition");
                 }
                 break;
         }
     }
     $feedback_allcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation($this->object->getId(), true);
     if (strlen($feedback_allcorrect)) {
         $attrs = array("continue" => "Yes");
         $a_xml_writer->xmlStartTag("respcondition", $attrs);
         // qti conditionvar
         $a_xml_writer->xmlStartTag("conditionvar");
         for ($i = 0; $i < $this->object->getGapCount(); $i++) {
             $gap = $this->object->getGap($i);
             $indexes = $gap->getBestSolutionIndexes();
             if ($i > 0) {
                 $a_xml_writer->xmlStartTag("and");
             }
             switch ($gap->getType()) {
                 case CLOZE_SELECT:
                     $k = 0;
                     foreach ($indexes as $key) {
                         if ($k > 0) {
                             $a_xml_writer->xmlStartTag("or");
                         }
                         $attrs = array("respident" => "gap_{$i}");
                         $answer = $gap->getItem($key);
                         $a_xml_writer->xmlElement("varequal", $attrs, $answer->getAnswertext());
                         if ($k > 0) {
                             $a_xml_writer->xmlEndTag("or");
                         }
                         $k++;
                     }
                     break;
                 case CLOZE_TEXT:
                     $k = 0;
                     foreach ($indexes as $key) {
                         if ($k > 0) {
                             $a_xml_writer->xmlStartTag("or");
                         }
                         $attrs = array("respident" => "gap_{$i}");
                         $answer = $gap->getItem($key);
                         $a_xml_writer->xmlElement("varequal", $attrs, $answer->getAnswertext());
                         if ($k > 0) {
                             $a_xml_writer->xmlEndTag("or");
                         }
                         $k++;
                     }
                     break;
                 case CLOZE_NUMERIC:
                     $k = 0;
                     foreach ($indexes as $key) {
                         if ($k > 0) {
                             $a_xml_writer->xmlStartTag("or");
                         }
                         $attrs = array("respident" => "gap_{$i}");
                         $answer = $gap->getItem($key);
                         $a_xml_writer->xmlElement("varequal", $attrs, $answer->getAnswertext());
                         if ($k > 0) {
                             $a_xml_writer->xmlEndTag("or");
                         }
                         $k++;
                     }
                     break;
             }
             if ($i > 0) {
                 $a_xml_writer->xmlEndTag("and");
             }
         }
         $a_xml_writer->xmlEndTag("conditionvar");
         // qti displayfeedback
         $attrs = array("feedbacktype" => "Response", "linkrefid" => "response_allcorrect");
         $a_xml_writer->xmlElement("displayfeedback", $attrs);
         $a_xml_writer->xmlEndTag("respcondition");
     }
     $feedback_onenotcorrect = $this->object->feedbackOBJ->getGenericFeedbackExportPresentation($this->object->getId(), false);
     if (strlen($feedback_onenotcorrect)) {
         $attrs = array("continue" => "Yes");
         $a_xml_writer->xmlStartTag("respcondition", $attrs);
         // qti conditionvar
         $a_xml_writer->xmlStartTag("conditionvar");
         $a_xml_writer->xmlStartTag("not");
         for ($i = 0; $i < $this->object->getGapCount(); $i++) {
             $gap = $this->object->getGap($i);
             $indexes = $gap->getBestSolutionIndexes();
             if ($i > 0) {
                 $a_xml_writer->xmlStartTag("and");
             }
             switch ($gap->getType()) {
                 case CLOZE_SELECT:
                     $k = 0;
                     foreach ($indexes as $key) {
                         if ($k > 0) {
                             $a_xml_writer->xmlStartTag("or");
                         }
                         $attrs = array("respident" => "gap_{$i}");
                         $answer = $gap->getItem($key);
                         $a_xml_writer->xmlElement("varequal", $attrs, $answer->getAnswertext());
                         if ($k > 0) {
                             $a_xml_writer->xmlEndTag("or");
                         }
                         $k++;
                     }
                     break;
                 case CLOZE_TEXT:
                     $k = 0;
                     foreach ($indexes as $key) {
                         if ($k > 0) {
                             $a_xml_writer->xmlStartTag("or");
                         }
                         $attrs = array("respident" => "gap_{$i}");
                         $answer = $gap->getItem($key);
                         $a_xml_writer->xmlElement("varequal", $attrs, $answer->getAnswertext());
                         if ($k > 0) {
                             $a_xml_writer->xmlEndTag("or");
                         }
                         $k++;
                     }
                     break;
                 case CLOZE_NUMERIC:
                     $k = 0;
                     foreach ($indexes as $key) {
                         if ($k > 0) {
                             $a_xml_writer->xmlStartTag("or");
                         }
                         $attrs = array("respident" => "gap_{$i}");
                         $answer = $gap->getItem($key);
                         $a_xml_writer->xmlElement("varequal", $attrs, $answer->getAnswertext());
                         if ($k > 0) {
                             $a_xml_writer->xmlEndTag("or");
                         }
                         $k++;
                     }
                     break;
             }
             if ($i > 0) {
                 $a_xml_writer->xmlEndTag("and");
             }
         }
         $a_xml_writer->xmlEndTag("not");
         $a_xml_writer->xmlEndTag("conditionvar");
         // qti displayfeedback
         $attrs = array("feedbacktype" => "Response", "linkrefid" => "response_onenotcorrect");
         $a_xml_writer->xmlElement("displayfeedback", $attrs);
         $a_xml_writer->xmlEndTag("respcondition");
     }
     $a_xml_writer->xmlEndTag("resprocessing");
     // PART III: qti itemfeedback
     for ($i = 0; $i < $this->object->getGapCount(); $i++) {
         $gap = $this->object->getGap($i);
         switch ($gap->getType()) {
             case CLOZE_SELECT:
                 break;
             case CLOZE_TEXT:
                 break;
             case CLOZE_NUMERIC:
                 break;
         }
         /*foreach ($gap->getItems() as $answer)
         			{
         				$linkrefid = "$i" . "_Response_" . $answer->getOrder();
         				$attrs = array(
         					"ident" => $linkrefid,
         					"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");
         				$fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
         					$this->object->getId(), $index
         				);
         				$this->object->addQTIMaterial($a_xml_writer, $fb);
         				$a_xml_writer->xmlEndTag("flow_mat");
         				$a_xml_writer->xmlEndTag("itemfeedback");
         			}*/
         $attrs = array("ident" => $i, "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");
         $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->object->getId(), $i);
         $this->object->addQTIMaterial($a_xml_writer, $fb);
         $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, "?>");
         $xml = substr($xml, $pos + 2);
     }
     return $xml;
 }
 /**
  * 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;
 }
Example #26
0
 /**
  * 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()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // kiosk
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "kiosk");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getKiosk()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     //redirection_mode
     $a_xml_writer->xmlStartTag('qtimetadatafield');
     $a_xml_writer->xmlElement("fieldlabel", NULL, "redirection_mode");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getRedirectionMode());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     //redirection_url
     $a_xml_writer->xmlStartTag('qtimetadatafield');
     $a_xml_writer->xmlElement("fieldlabel", NULL, "redirection_url");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getRedirectionUrl());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // use previous answers
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "use_previous_answers");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getUsePreviousAnswers());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // hide title points
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "title_output");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getTitleOutput()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // results presentation
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "results_presentation");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getResultsPresentation()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // examid in test pass
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "examid_in_test_pass");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->isShowExamIdInTestPassEnabled()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // examid in kiosk
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "examid_in_test_res");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->isShowExamIdInTestResultsEnabled()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // solution details
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "show_summary");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getListOfQuestionsSettings()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // solution details
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "score_reporting");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getScoreReporting()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // solution details
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "instant_verification");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getInstantFeedbackSolution()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // answer specific feedback
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "answer_feedback");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getAnswerFeedback()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // answer specific feedback of reached points
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "answer_feedback_points");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getAnswerFeedbackPoints()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // highscore
     $highscore_metadata = array('highscore_enabled' => array('value' => $this->getHighscoreEnabled()), 'highscore_anon' => array('value' => $this->getHighscoreAnon()), 'highscore_achieved_ts' => array('value' => $this->getHighscoreAchievedTS()), 'highscore_score' => array('value' => $this->getHighscoreScore()), 'highscore_percentage' => array('value' => $this->getHighscorePercentage()), 'highscore_hints' => array('value' => $this->getHighscoreHints()), 'highscore_wtime' => array('value' => $this->getHighscoreWTime()), 'highscore_own_table' => array('value' => $this->getHighscoreOwnTable()), 'highscore_top_table' => array('value' => $this->getHighscoreTopTable()), 'highscore_top_num' => array('value' => $this->getHighscoreTopNum()));
     foreach ($highscore_metadata as $label => $data) {
         $a_xml_writer->xmlStartTag("qtimetadatafield");
         $a_xml_writer->xmlElement("fieldlabel", NULL, $label);
         $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $data['value']));
         $a_xml_writer->xmlEndTag("qtimetadatafield");
     }
     // show cancel
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "show_cancel");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowCancel()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // show marker
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "show_marker");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowMarker()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // fixed participants
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "fixed_participants");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getFixedParticipants()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // show final statement
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "showfinalstatement");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowFinalStatement() ? "1" : "0"));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // show introduction only
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "showinfo");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShowInfo() ? "1" : "0"));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // mail notification
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "mailnotification");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getMailNotification());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // mail notification type
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "mailnottype");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getMailNotificationType());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // export settings
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "exportsettings");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getExportSettings());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // force JavaScript
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "forcejs");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getForceJS() ? "1" : "0"));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // custom style
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "customstyle");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getCustomStyle());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // shuffle questions
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "shuffle_questions");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getShuffleQuestions()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // processing time
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "processing_time");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getProcessingTime());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // enable_examview
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "enable_examview");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getEnableExamview());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // show_examview_html
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "show_examview_html");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getShowExamviewHtml());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // show_examview_pdf
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "show_examview_pdf");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getShowExamviewPdf());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // enable_archiving
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "enable_archiving");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getEnableArchiving());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // sign_submission
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "sign_submission");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getSignSubmission());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // char_selector_availability
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "char_selector_availability");
     $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("%d", $this->getCharSelectorAvailability()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // char_selector_definition
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "char_selector_definition");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getCharSelectorDefinition());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // skill_service
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "skill_service");
     $a_xml_writer->xmlElement("fieldentry", NULL, (int) $this->isSkillServiceEnabled());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // result_tax_filters
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "result_tax_filters");
     $a_xml_writer->xmlElement("fieldentry", NULL, serialize((array) $this->getResultFilterTaxIds()));
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // show_grading_status
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "show_grading_status");
     $a_xml_writer->xmlElement("fieldentry", NULL, (int) $this->isShowGradingStatusEnabled());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // show_grading_mark
     $a_xml_writer->xmlStartTag("qtimetadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "show_grading_mark");
     $a_xml_writer->xmlElement("fieldentry", NULL, (int) $this->isShowGradingMarkEnabled());
     $a_xml_writer->xmlEndTag("qtimetadatafield");
     // starting time
     if ($this->getStartingTime()) {
         $a_xml_writer->xmlStartTag("qtimetadatafield");
         $a_xml_writer->xmlElement("fieldlabel", NULL, "starting_time");
         preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->starting_time, $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");
     }
     // ending time
     if ($this->getEndingTime()) {
         $a_xml_writer->xmlStartTag("qtimetadatafield");
         $a_xml_writer->xmlElement("fieldlabel", NULL, "ending_time");
         preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->ending_time, $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");
     }
     foreach ($this->mark_schema->mark_steps as $index => $mark) {
         // mark steps
         $a_xml_writer->xmlStartTag("qtimetadatafield");
         $a_xml_writer->xmlElement("fieldlabel", NULL, "mark_step_{$index}");
         $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("<short>%s</short><official>%s</official><percentage>%.2f</percentage><passed>%d</passed>", $mark->getShortName(), $mark->getOfficialName(), $mark->getMinimumLevel(), $mark->getPassed()));
         $a_xml_writer->xmlEndTag("qtimetadatafield");
     }
     $a_xml_writer->xmlEndTag("qtimetadata");
     // add qti objectives
     $a_xml_writer->xmlStartTag("objectives");
     $this->addQTIMaterial($a_xml_writer, $this->getIntroduction());
     $a_xml_writer->xmlEndTag("objectives");
     // add qti assessmentcontrol
     if ($this->getInstantFeedbackSolution() == 1) {
         $attrs = array("solutionswitch" => "Yes");
     } else {
         $attrs = NULL;
     }
     $a_xml_writer->xmlElement("assessmentcontrol", $attrs, NULL);
     if (strlen($this->getFinalStatement())) {
         // add qti presentation_material
         $a_xml_writer->xmlStartTag("presentation_material");
         $a_xml_writer->xmlStartTag("flow_mat");
         $this->addQTIMaterial($a_xml_writer, $this->getFinalStatement());
         $a_xml_writer->xmlEndTag("flow_mat");
         $a_xml_writer->xmlEndTag("presentation_material");
     }
     $attrs = array("ident" => "1");
     $a_xml_writer->xmlElement("section", $attrs, NULL);
     $a_xml_writer->xmlEndTag("assessment");
     $a_xml_writer->xmlEndTag("questestinterop");
     $xml = $a_xml_writer->xmlDumpMem(FALSE);
     foreach ($this->questions as $question_id) {
         $question =& ilObjTest::_instanciateQuestion($question_id);
         $qti_question = $question->toXML(false);
         $qti_question = preg_replace("/<questestinterop>/", "", $qti_question);
         $qti_question = preg_replace("/<\\/questestinterop>/", "", $qti_question);
         if (strpos($xml, "</section>") !== false) {
             $xml = str_replace("</section>", "{$qti_question}</section>", $xml);
         } else {
             $xml = str_replace("<section ident=\"1\"/>", "<section ident=\"1\">\n{$qti_question}</section>", $xml);
         }
     }
     return $xml;
 }
 /**
  *	add user defined field data to xml (using usr dtd)
  *	@param ilXmlWriter $xml_writer
  */
 function addToXML($xml_writer)
 {
     include_once './Services/User/classes/class.ilUserDefinedFields.php';
     $udf_obj =& ilUserDefinedFields::_getInstance();
     foreach ($udf_obj->getDefinitions() as $definition) {
         if ($definition["export"] != FALSE) {
             $xml_writer->xmlElement('UserDefinedField', array('Id' => $definition['il_id'], 'Name' => $definition['field_name']), (string) $this->user_data['f_' . (int) $definition['field_id']]);
         }
     }
 }
 /**
  * constructor
  * @param	string	xml version
  * @param	string	output encoding
  * @param	string	input encoding
  * @access	public
  */
 public function __construct(ilObjCategory $cat = null)
 {
     global $ilias;
     parent::__construct();
     $this->category = $cat;
 }
 /**
  * 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, TEXTSUBSET_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");
     $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, "correctanswers");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->object->getCorrectAnswers());
     $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->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
     for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
         $attrs = array("ident" => "TEXTSUBSET_" . sprintf("%02d", $counter), "rcardinality" => "Single");
         $a_xml_writer->xmlStartTag("response_str", $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" => "String", "columns" => $this->object->getMaxTextboxWidth());
         $a_xml_writer->xmlStartTag("render_fib", $attrs);
         $a_xml_writer->xmlEndTag("render_fib");
         $a_xml_writer->xmlEndTag("response_str");
     }
     $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");
     $attribs = array("varname" => "matches", "defaultval" => "0");
     $a_xml_writer->xmlElement("decvar", $attribs, NULL);
     $a_xml_writer->xmlEndTag("outcomes");
     // add response conditions
     for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
         $scoregroups =& $this->object->joinAnswers();
         foreach ($scoregroups as $points => $scoreanswers) {
             $attrs = array("continue" => "Yes");
             $a_xml_writer->xmlStartTag("respcondition", $attrs);
             // qti conditionvar
             $a_xml_writer->xmlStartTag("conditionvar");
             $attrs = array("respident" => "TEXTSUBSET_" . sprintf("%02d", $counter));
             $a_xml_writer->xmlElement("varsubset", $attrs, join(",", $scoreanswers));
             $a_xml_writer->xmlEndTag("conditionvar");
             // qti setvar
             $attrs = array("varname" => "matches", "action" => "Add");
             $a_xml_writer->xmlElement("setvar", $attrs, $points);
             // qti displayfeedback
             $attrs = array("feedbacktype" => "Response", "linkrefid" => "Matches_" . sprintf("%02d", $counter));
             $a_xml_writer->xmlElement("displayfeedback", $attrs);
             $a_xml_writer->xmlEndTag("respcondition");
         }
     }
     $feedback_allcorrect = $this->object->getFeedbackGeneric(1);
     $feedback_onenotcorrect = $this->object->getFeedbackGeneric(0);
     if (strlen($feedback_allcorrect . $feedback_onenotcorrect)) {
         if (strlen($feedback_allcorrect)) {
             $attrs = array("continue" => "Yes");
             $a_xml_writer->xmlStartTag("respcondition", $attrs);
             // qti conditionvar
             $a_xml_writer->xmlStartTag("conditionvar");
             $attrs = array("respident" => "points");
             $a_xml_writer->xmlElement("varsubset", $attrs, $this->object->getMaximumPoints());
             $a_xml_writer->xmlEndTag("conditionvar");
             // qti displayfeedback
             $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);
             // qti conditionvar
             $a_xml_writer->xmlStartTag("conditionvar");
             $a_xml_writer->xmlStartTag("not");
             $attrs = array("respident" => "points");
             $a_xml_writer->xmlElement("varsubset", $attrs, $this->object->getMaximumPoints());
             $a_xml_writer->xmlEndTag("not");
             $a_xml_writer->xmlEndTag("conditionvar");
             // qti displayfeedback
             $attrs = array("feedbacktype" => "Response", "linkrefid" => "response_onenotcorrect");
             $a_xml_writer->xmlElement("displayfeedback", $attrs);
             $a_xml_writer->xmlEndTag("respcondition");
         }
     }
     $a_xml_writer->xmlEndTag("resprocessing");
     // PART III: qti itemfeedback
     for ($counter = 1; $counter <= $this->object->getCorrectAnswers(); $counter++) {
         $attrs = array("ident" => "Matches_" . sprintf("%02d", $counter), "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, "?>");
         $xml = substr($xml, $pos + 2);
     }
     return $xml;
 }
 /**
  * Returns a QTI xml representation of the survey
  *
  * @return string The QTI xml representation of the survey
  * @access public
  */
 function toXML()
 {
     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" => $this->getSurveyId(), "title" => $this->getTitle());
     $a_xml_writer->xmlStartTag("survey", $attrs);
     $a_xml_writer->xmlElement("description", NULL, $this->getDescription());
     $a_xml_writer->xmlElement("author", NULL, $this->getAuthor());
     $a_xml_writer->xmlStartTag("objectives");
     $attrs = array("label" => "introduction");
     $this->addMaterialTag($a_xml_writer, $this->getIntroduction(), TRUE, TRUE, $attrs);
     $attrs = array("label" => "outro");
     $this->addMaterialTag($a_xml_writer, $this->getOutro(), TRUE, TRUE, $attrs);
     $a_xml_writer->xmlEndTag("objectives");
     if ($this->getAnonymize()) {
         $attribs = array("enabled" => "1");
     } else {
         $attribs = array("enabled" => "0");
     }
     $a_xml_writer->xmlElement("anonymisation", $attribs);
     $a_xml_writer->xmlStartTag("restrictions");
     if ($this->getAnonymize() == 2) {
         $attribs = array("type" => "free");
     } else {
         $attribs = array("type" => "restricted");
     }
     $a_xml_writer->xmlElement("access", $attribs);
     if ($this->getStartDate()) {
         $attrs = array("type" => "date");
         preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->getStartDate(), $matches);
         $a_xml_writer->xmlElement("startingtime", $attrs, sprintf("%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
     }
     if ($this->getEndDate()) {
         $attrs = array("type" => "date");
         preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->getEndDate(), $matches);
         $a_xml_writer->xmlElement("endingtime", $attrs, sprintf("%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
     }
     $a_xml_writer->xmlEndTag("restrictions");
     // constraints
     $pages =& $this->getSurveyPages();
     $hasconstraints = FALSE;
     foreach ($pages as $question_array) {
         foreach ($question_array as $question) {
             if (count($question["constraints"])) {
                 $hasconstraints = TRUE;
             }
         }
     }
     if ($hasconstraints) {
         $a_xml_writer->xmlStartTag("constraints");
         foreach ($pages as $question_array) {
             foreach ($question_array as $question) {
                 if (count($question["constraints"])) {
                     // found constraints
                     foreach ($question["constraints"] as $constraint) {
                         $attribs = array("sourceref" => $question["question_id"], "destref" => $constraint["question"], "relation" => $constraint["short"], "value" => $constraint["value"], "conjunction" => $constraint["conjunction"]);
                         $a_xml_writer->xmlElement("constraint", $attribs);
                     }
                 }
             }
         }
         $a_xml_writer->xmlEndTag("constraints");
     }
     // add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI
     $a_xml_writer->xmlStartTag("metadata");
     $a_xml_writer->xmlStartTag("metadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "evaluation_access");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getEvaluationAccess());
     $a_xml_writer->xmlEndTag("metadatafield");
     $a_xml_writer->xmlStartTag("metadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "status");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getStatus());
     $a_xml_writer->xmlEndTag("metadatafield");
     $a_xml_writer->xmlStartTag("metadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "display_question_titles");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getShowQuestionTitles());
     $a_xml_writer->xmlEndTag("metadatafield");
     $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("survey");
     $attribs = array("id" => $this->getId());
     $a_xml_writer->xmlStartTag("surveyquestions", $attribs);
     // add questionblock descriptions
     $obligatory_states =& $this->getObligatoryStates();
     foreach ($pages as $question_array) {
         if (count($question_array) > 1) {
             $attribs = array("id" => $question_array[0]["question_id"]);
             $attribs = array("showQuestiontext" => $question_array[0]["questionblock_show_questiontext"], "showBlocktitle" => $question_array[0]["questionblock_show_blocktitle"]);
             $a_xml_writer->xmlStartTag("questionblock", $attribs);
             if (strlen($question_array[0]["questionblock_title"])) {
                 $a_xml_writer->xmlElement("questionblocktitle", NULL, $question_array[0]["questionblock_title"]);
             }
         }
         foreach ($question_array as $question) {
             if (strlen($question["heading"])) {
                 $a_xml_writer->xmlElement("textblock", NULL, $question["heading"]);
             }
             $questionObject =& $this->_instanciateQuestion($question["question_id"]);
             if ($questionObject !== FALSE) {
                 $questionObject->insertXML($a_xml_writer, FALSE, $obligatory_states[$question["question_id"]]);
             }
         }
         if (count($question_array) > 1) {
             $a_xml_writer->xmlEndTag("questionblock");
         }
     }
     $a_xml_writer->xmlEndTag("surveyquestions");
     $a_xml_writer->xmlEndTag("surveyobject");
     $xml = $a_xml_writer->xmlDumpMem(FALSE);
     return $xml;
 }