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. 
   40         $ilias = $DIC[
'ilias'];
    44         $a_xml_writer->xmlHeader();
    45         $a_xml_writer->xmlStartTag(
"questestinterop");
    47             "ident" => 
"il_" . 
IL_INST_ID . 
"_qst_" . $this->
object->getId(),
    48             "title" => $this->
object->getTitle(),
    49             "maxattempts" => $this->
object->getNrOfTries()
    51         $a_xml_writer->xmlStartTag(
"item", $attrs);
    53         $a_xml_writer->xmlElement(
"qticomment", null, $this->
object->getComment());
    54         $a_xml_writer->xmlStartTag(
"itemmetadata");
    55         $a_xml_writer->xmlStartTag(
"qtimetadata");
    56         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
    57         $a_xml_writer->xmlElement(
"fieldlabel", null, 
"ILIAS_VERSION");
    58         $a_xml_writer->xmlElement(
"fieldentry", null, $ilias->getSetting(
"ilias_version"));
    59         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
    60         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
    61         $a_xml_writer->xmlElement(
"fieldlabel", null, 
"QUESTIONTYPE");
    62         $a_xml_writer->xmlElement(
"fieldentry", null, $this->
object->getQuestionType());
    63         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
    64         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
    65         $a_xml_writer->xmlElement(
"fieldlabel", null, 
"AUTHOR");
    66         $a_xml_writer->xmlElement(
"fieldentry", null, $this->
object->getAuthor());
    67         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
    73         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
    74         $a_xml_writer->xmlElement(
"fieldlabel", null, 
"shuffle");
    75         $a_xml_writer->xmlElement(
"fieldentry", null, $this->
object->getShuffle());
    76         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
    77         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
    78         $a_xml_writer->xmlElement(
"fieldlabel", null, 
"thumb_geometry");
    79         $a_xml_writer->xmlElement(
"fieldentry", null, $this->
object->getThumbGeometry());
    80         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
    81         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
    82         $a_xml_writer->xmlElement(
"fieldlabel", null, 
'matching_mode');
    83         $a_xml_writer->xmlElement(
"fieldentry", null, $this->
object->getMatchingMode());
    84         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
    85         $a_xml_writer->xmlEndTag(
"qtimetadata");
    86         $a_xml_writer->xmlEndTag(
"itemmetadata");
    90             "label" => $this->
object->getTitle()
    92         $a_xml_writer->xmlStartTag(
"presentation", $attrs);
    94         $a_xml_writer->xmlStartTag(
"flow");
   100             "rcardinality" => 
"Multiple"   102         $a_xml_writer->xmlStartTag(
"response_grp", $attrs);
   106         if ($this->
object->getShuffle()) {
   115         $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
   117         $matchingtext_orders = [];
   118         foreach ($this->
object->getMatchingPairs() as $index => $matchingpair) {
   119             array_push($matchingtext_orders, $matchingpair->getTerm()->getIdentifier());
   123         foreach ($this->
object->getTerms() as $term) {
   124             array_push($termids, $term->getidentifier());
   127         foreach ($this->
object->getDefinitions() as $definition) {
   129                 "ident" => $definition->getIdentifier(),
   131                 "match_group" => join(
",", $termids)
   133             $a_xml_writer->xmlStartTag(
"response_label", $attrs);
   134             $a_xml_writer->xmlStartTag(
"material");
   135             if (strlen($definition->getPicture())) {
   136                 if ($force_image_references) {
   138                         "imagtype" => 
"image/jpeg",
   139                         "label" => $definition->getPicture(),
   140                         "uri" => $this->
object->getImagePathWeb() . $definition->getPicture()
   142                     $a_xml_writer->xmlElement(
"matimage", $attrs);
   144                     $imagepath = $this->
object->getImagePath() . $definition->getPicture();
   145                     $fh = @fopen($imagepath, 
"rb");
   147                         $imagefile = fread($fh, filesize($imagepath));
   149                         $base64 = base64_encode($imagefile);
   151                             "imagtype" => 
"image/jpeg",
   152                             "label" => $definition->getPicture(),
   153                             "embedded" => 
"base64"   155                         $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, 
false, 
false);
   159             if (strlen($definition->getText())) {
   161                     "texttype" => 
"text/plain"   164                     $attrs[
"texttype"] = 
"text/xhtml";
   166                 $a_xml_writer->xmlElement(
"mattext", $attrs, $definition->getText());
   168             $a_xml_writer->xmlEndTag(
"material");
   169             $a_xml_writer->xmlEndTag(
"response_label");
   172         foreach ($this->
object->getTerms() as $term) {
   174                 "ident" => $term->getIdentifier()
   176             $a_xml_writer->xmlStartTag(
"response_label", $attrs);
   177             $a_xml_writer->xmlStartTag(
"material");
   178             if (strlen($term->getPicture())) {
   179                 if ($force_image_references) {
   181                         "imagtype" => 
"image/jpeg",
   182                         "label" => $term->getPicture(),
   183                         "uri" => $this->
object->getImagePathWeb() . $term->getPicture()
   185                     $a_xml_writer->xmlElement(
"matimage", $attrs);
   187                     $imagepath = $this->
object->getImagePath() . $term->getPicture();
   188                     $fh = @fopen($imagepath, 
"rb");
   190                         $imagefile = fread($fh, filesize($imagepath));
   192                         $base64 = base64_encode($imagefile);
   194                             "imagtype" => 
"image/jpeg",
   195                             "label" => $term->getPicture(),
   196                             "embedded" => 
"base64"   198                         $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, 
false, 
false);
   202             if (strlen($term->getText())) {
   204                     "texttype" => 
"text/plain"   206                 if (method_exists($this->
object, 
'isHTML') && $this->
object->isHTML($term->text)) {
   207                     $attrs[
"texttype"] = 
"text/xhtml";
   209                 $a_xml_writer->xmlElement(
"mattext", $attrs, $term->getText());
   211             $a_xml_writer->xmlEndTag(
"material");
   212             $a_xml_writer->xmlEndTag(
"response_label");
   214         $a_xml_writer->xmlEndTag(
"render_choice");
   215         $a_xml_writer->xmlEndTag(
"response_grp");
   216         $a_xml_writer->xmlEndTag(
"flow");
   217         $a_xml_writer->xmlEndTag(
"presentation");
   220         $a_xml_writer->xmlStartTag(
"resprocessing");
   221         $a_xml_writer->xmlStartTag(
"outcomes");
   222         $a_xml_writer->xmlStartTag(
"decvar");
   223         $a_xml_writer->xmlEndTag(
"decvar");
   224         $a_xml_writer->xmlEndTag(
"outcomes");
   226         foreach ($this->
object->getMatchingPairs() as $matchingpair) {
   230             $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
   232             $a_xml_writer->xmlStartTag(
"conditionvar");
   236             $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->getTerm()->getIdentifier() . 
"," . $matchingpair->getDefinition()->getidentifier());
   237             $a_xml_writer->xmlEndTag(
"conditionvar");
   243             $a_xml_writer->xmlElement(
"setvar", $attrs, $matchingpair->getPoints());
   246                 "feedbacktype" => 
"Response",
   247                 "linkrefid" => 
"correct_" . $matchingpair->getTerm()->getIdentifier() . 
"_" . $matchingpair->getDefinition()->getIdentifier()
   249             $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
   250             $a_xml_writer->xmlEndTag(
"respcondition");
   253         $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
   257         if (strlen($feedback_allcorrect)) {
   261             $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
   263             $a_xml_writer->xmlStartTag(
"conditionvar");
   265             foreach ($this->
object->getMatchingPairs() as $matchingpair) {
   269                 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->getTerm()->getIdentifier() . 
"," . $matchingpair->getDefinition()->getIdentifier());
   271             $a_xml_writer->xmlEndTag(
"conditionvar");
   274                 "feedbacktype" => 
"Response",
   275                 "linkrefid" => 
"response_allcorrect"   277             $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
   278             $a_xml_writer->xmlEndTag(
"respcondition");
   280         $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
   284         if (strlen($feedback_onenotcorrect)) {
   288             $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
   290             $a_xml_writer->xmlStartTag(
"conditionvar");
   291             $a_xml_writer->xmlStartTag(
"not");
   292             foreach ($this->
object->getMatchingPairs() as $matchingpair) {
   296                 $a_xml_writer->xmlElement(
"varsubset", $attrs, $matchingpair->getTerm()->getIdentifier() . 
"," . $matchingpair->getDefinition()->getIdentifier());
   298             $a_xml_writer->xmlEndTag(
"not");
   299             $a_xml_writer->xmlEndTag(
"conditionvar");
   302                 "feedbacktype" => 
"Response",
   303                 "linkrefid" => 
"response_onenotcorrect"   305             $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
   306             $a_xml_writer->xmlEndTag(
"respcondition");
   309         $a_xml_writer->xmlEndTag(
"resprocessing");
   312         foreach ($this->
object->getMatchingPairs() as $index => $matchingpair) {
   314                 "ident" => 
"correct_" . $matchingpair->getTerm()->getIdentifier() . 
"_" . $matchingpair->getDefinition()->getIdentifier(),
   317             $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
   319             $a_xml_writer->xmlStartTag(
"flow_mat");
   320             $a_xml_writer->xmlStartTag(
"material");
   321             $a_xml_writer->xmlElement(
"mattext", null, $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
   322                 $this->object->getId(),
   326             $a_xml_writer->xmlEndTag(
"material");
   327             $a_xml_writer->xmlEndTag(
"flow_mat");
   328             $a_xml_writer->xmlEndTag(
"itemfeedback");
   331         if (strlen($feedback_allcorrect)) {
   333                 "ident" => 
"response_allcorrect",
   336             $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
   338             $a_xml_writer->xmlStartTag(
"flow_mat");
   340             $a_xml_writer->xmlEndTag(
"flow_mat");
   341             $a_xml_writer->xmlEndTag(
"itemfeedback");
   343         if (strlen($feedback_onenotcorrect)) {
   345                 "ident" => 
"response_onenotcorrect",
   348             $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
   350             $a_xml_writer->xmlStartTag(
"flow_mat");
   352             $a_xml_writer->xmlEndTag(
"flow_mat");
   353             $a_xml_writer->xmlEndTag(
"itemfeedback");
   358         $a_xml_writer->xmlEndTag(
"item");
   359         $a_xml_writer->xmlEndTag(
"questestinterop");
   361         $xml = $a_xml_writer->xmlDumpMem(
false);
   362         if (!$a_include_header) {
   363             $pos = strpos($xml, 
"?>");
   364             $xml = substr($xml, $pos + 2);
 
static isHTML(string $a_text)
Checks if a given string contains HTML or not. 
 
addQTIMaterial(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
 
addGeneralMetadata(ilXmlWriter $xmlwriter)
 
addAdditionalContentEditingModeInformation(ilXmlWriter $a_xml_writer)
adds a qti meta data field for ilias specific information of "additional content editing mode" (xml w...
 
addSuggestedSolution(ilXmlWriter $writer)
 
addSolutionHints(ilXmlWriter $writer)