34    public function toXML($a_include_header = 
true, $a_include_binary = 
true, $a_shuffle = 
false, $test_output = 
false, $force_image_references = 
false): string
 
   37        $ilias = 
$DIC[
'ilias'];
 
   39        include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
 
   42        $a_xml_writer->xmlHeader();
 
   43        $a_xml_writer->xmlStartTag(
"questestinterop");
 
   46            "title" => $this->object->getTitle(),
 
   47            "maxattempts" => $this->object->getNrOfTries()
 
   49        $a_xml_writer->xmlStartTag(
"item", $attrs);
 
   51        $a_xml_writer->xmlElement(
"qticomment", 
null, $this->
object->getComment());
 
   52        $a_xml_writer->xmlStartTag(
"itemmetadata");
 
   53        $a_xml_writer->xmlStartTag(
"qtimetadata");
 
   54        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   55        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"ILIAS_VERSION");
 
   56        $a_xml_writer->xmlElement(
"fieldentry", 
null, $ilias->getSetting(
"ilias_version"));
 
   57        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   58        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   59        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"QUESTIONTYPE");
 
   61        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   62        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   63        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"AUTHOR");
 
   64        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->
object->getAuthor());
 
   65        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   71        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   72        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"shuffle");
 
   73        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->
object->getShuffle());
 
   74        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   75        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   76        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"thumb_geometry");
 
   77        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->
object->getThumbGeometry());
 
   78        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   79        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   80        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
'matching_mode');
 
   81        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->
object->getMatchingMode());
 
   82        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   83        $a_xml_writer->xmlEndTag(
"qtimetadata");
 
   84        $a_xml_writer->xmlEndTag(
"itemmetadata");
 
   88            "label" => $this->
object->getTitle()
 
   90        $a_xml_writer->xmlStartTag(
"presentation", $attrs);
 
   92        $a_xml_writer->xmlStartTag(
"flow");
 
   94        $this->
object->addQTIMaterial($a_xml_writer, $this->
object->getQuestion());
 
   98            "rcardinality" => 
"Multiple" 
  100        $a_xml_writer->xmlStartTag(
"response_grp", $attrs);
 
  101        $solution = $this->
object->getSuggestedSolution(0);
 
  102        if ($solution !== 
null && count($solution)) {
 
  103            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
 
  104                $a_xml_writer->xmlStartTag(
"material");
 
  105                $intlink = 
"il_" . 
IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
  106                if (strcmp($matches[1], 
"") != 0) {
 
  107                    $intlink = $solution[
"internal_link"];
 
  110                    "label" => 
"suggested_solution" 
  112                $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
 
  113                $a_xml_writer->xmlEndTag(
"material");
 
  118        if ($this->
object->getShuffle()) {
 
  127        $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
 
  129        $matchingtext_orders = array();
 
  130        foreach ($this->
object->getMatchingPairs() as 
$index => $matchingpair) {
 
  131            array_push($matchingtext_orders, $matchingpair->getTerm()->getIdentifier());
 
  135        foreach ($this->
object->getTerms() as $term) {
 
  136            array_push($termids, $term->getidentifier());
 
  139        foreach ($this->
object->getDefinitions() as $definition) {
 
  141                "ident" => $definition->getIdentifier(),
 
  143                "match_group" => join(
",", $termids)
 
  145            $a_xml_writer->xmlStartTag(
"response_label", $attrs);
 
  146            $a_xml_writer->xmlStartTag(
"material");
 
  147            if (strlen($definition->getPicture())) {
 
  148                if ($force_image_references) {
 
  150                        "imagtype" => 
"image/jpeg",
 
  151                        "label" => $definition->getPicture(),
 
  152                        "uri" => $this->object->getImagePathWeb() . $definition->getPicture()
 
  154                    $a_xml_writer->xmlElement(
"matimage", $attrs);
 
  156                    $imagepath = $this->
object->getImagePath() . $definition->getPicture();
 
  157                    $fh = @fopen($imagepath, 
"rb");
 
  159                        $imagefile = fread($fh, filesize($imagepath));
 
  161                        $base64 = base64_encode($imagefile);
 
  163                            "imagtype" => 
"image/jpeg",
 
  164                            "label" => $definition->getPicture(),
 
  165                            "embedded" => 
"base64" 
  167                        $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, 
false, 
false);
 
  171            if (strlen($definition->getText())) {
 
  173                    "texttype" => 
"text/plain" 
  175                if ($this->
object->isHTML($definition->getText())) {
 
  176                    $attrs[
"texttype"] = 
"text/xhtml";
 
  178                $a_xml_writer->xmlElement(
"mattext", $attrs, $definition->getText());
 
  180            $a_xml_writer->xmlEndTag(
"material");
 
  181            $a_xml_writer->xmlEndTag(
"response_label");
 
  184        foreach ($this->
object->getTerms() as $term) {
 
  186                "ident" => $term->getIdentifier()
 
  188            $a_xml_writer->xmlStartTag(
"response_label", $attrs);
 
  189            $a_xml_writer->xmlStartTag(
"material");
 
  190            if (strlen($term->getPicture())) {
 
  191                if ($force_image_references) {
 
  193                        "imagtype" => 
"image/jpeg",
 
  194                        "label" => $term->getPicture(),
 
  195                        "uri" => $this->object->getImagePathWeb() . $term->getPicture()
 
  197                    $a_xml_writer->xmlElement(
"matimage", $attrs);
 
  199                    $imagepath = $this->
object->getImagePath() . $term->getPicture();
 
  200                    $fh = @fopen($imagepath, 
"rb");
 
  202                        $imagefile = fread($fh, filesize($imagepath));
 
  204                        $base64 = base64_encode($imagefile);
 
  206                            "imagtype" => 
"image/jpeg",
 
  207                            "label" => $term->getPicture(),
 
  208                            "embedded" => 
"base64" 
  210                        $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, 
false, 
false);
 
  214            if (strlen($term->getText())) {
 
  216                    "texttype" => 
"text/plain" 
  218                if ($this->
object->isHTML($term->getText())) {
 
  219                    $attrs[
"texttype"] = 
"text/xhtml";
 
  221                $a_xml_writer->xmlElement(
"mattext", $attrs, $term->getText());
 
  223            $a_xml_writer->xmlEndTag(
"material");
 
  224            $a_xml_writer->xmlEndTag(
"response_label");
 
  226        $a_xml_writer->xmlEndTag(
"render_choice");
 
  227        $a_xml_writer->xmlEndTag(
"response_grp");
 
  228        $a_xml_writer->xmlEndTag(
"flow");
 
  229        $a_xml_writer->xmlEndTag(
"presentation");
 
  232        $a_xml_writer->xmlStartTag(
"resprocessing");
 
  233        $a_xml_writer->xmlStartTag(
"outcomes");
 
  234        $a_xml_writer->xmlStartTag(
"decvar");
 
  235        $a_xml_writer->xmlEndTag(
"decvar");
 
  236        $a_xml_writer->xmlEndTag(
"outcomes");
 
  238        foreach ($this->
object->getMatchingPairs() as $matchingpair) {
 
  242            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  244            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  248            $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->getTerm()->getIdentifier() . 
"," . $matchingpair->getDefinition()->getidentifier());
 
  249            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  255            $a_xml_writer->xmlElement(
"setvar", $attrs, $matchingpair->getPoints());
 
  258                "feedbacktype" => 
"Response",
 
  259                "linkrefid" => 
"correct_" . $matchingpair->getTerm()->getIdentifier() . 
"_" . $matchingpair->getDefinition()->getIdentifier()
 
  261            $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  262            $a_xml_writer->xmlEndTag(
"respcondition");
 
  265        $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
 
  269        if (strlen($feedback_allcorrect)) {
 
  273            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  275            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  277            foreach ($this->
object->getMatchingPairs() as $matchingpair) {
 
  281                $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->getTerm()->getIdentifier() . 
"," . $matchingpair->getDefinition()->getIdentifier());
 
  283            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  286                "feedbacktype" => 
"Response",
 
  287                "linkrefid" => 
"response_allcorrect" 
  289            $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  290            $a_xml_writer->xmlEndTag(
"respcondition");
 
  292        $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
 
  296        if (strlen($feedback_onenotcorrect)) {
 
  300            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  302            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  303            $a_xml_writer->xmlStartTag(
"not");
 
  304            foreach ($this->
object->getMatchingPairs() as $matchingpair) {
 
  308                $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->getTerm()->getIdentifier() . 
"," . $matchingpair->getDefinition()->getIdentifier());
 
  310            $a_xml_writer->xmlEndTag(
"not");
 
  311            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  314                "feedbacktype" => 
"Response",
 
  315                "linkrefid" => 
"response_onenotcorrect" 
  317            $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  318            $a_xml_writer->xmlEndTag(
"respcondition");
 
  321        $a_xml_writer->xmlEndTag(
"resprocessing");
 
  324        foreach ($this->
object->getMatchingPairs() as 
$index => $matchingpair) {
 
  326                "ident" => 
"correct_" . $matchingpair->getTerm()->getIdentifier() . 
"_" . $matchingpair->getDefinition()->getIdentifier(),
 
  329            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  331            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  332            $a_xml_writer->xmlStartTag(
"material");
 
  333            $a_xml_writer->xmlElement(
"mattext", 
null, $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
 
  334                $this->object->getId(),
 
  338            $a_xml_writer->xmlEndTag(
"material");
 
  339            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  340            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  343        if (strlen($feedback_allcorrect)) {
 
  345                "ident" => 
"response_allcorrect",
 
  348            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  350            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  351            $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
 
  352            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  353            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  355        if (strlen($feedback_onenotcorrect)) {
 
  357                "ident" => 
"response_onenotcorrect",
 
  360            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  362            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  363            $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
 
  364            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  365            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  370        $a_xml_writer->xmlEndTag(
"item");
 
  371        $a_xml_writer->xmlEndTag(
"questestinterop");
 
  373        $xml = $a_xml_writer->xmlDumpMem(
false);
 
  374        if (!$a_include_header) {
 
  375            $pos = strpos(
$xml, 
"?>");
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
toXML($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
Returns a QTI xml representation of the question Returns a QTI xml representation of the question and...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
addGeneralMetadata(ilXmlWriter $xmlwriter)
 
addSolutionHints(ilXmlWriter $writer)
 
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
const MATCHING_QUESTION_IDENTIFIER