4include_once 
"./Modules/TestQuestionPool/classes/export/qti12/class.assQuestionExport.php";
 
   26    public function toXML($a_include_header = 
true, $a_include_binary = 
true, $a_shuffle = 
false, $test_output = 
false, $force_image_references = 
false)
 
   29        $ilias = 
$DIC[
'ilias'];
 
   31        include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
 
   35        $a_xml_writer->xmlStartTag(
"questestinterop");
 
   37            "ident" => 
"il_" . IL_INST_ID . 
"_qst_" . $this->object->getId(),
 
   38            "title" => $this->object->getTitle(),
 
   39            "maxattempts" => $this->object->getNrOfTries()
 
   41        $a_xml_writer->xmlStartTag(
"item", $attrs);
 
   43        $a_xml_writer->xmlElement(
"qticomment", 
null, $this->object->getComment());
 
   45        $workingtime = $this->
object->getEstimatedWorkingTime();
 
   46        $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
 
   47        $a_xml_writer->xmlElement(
"duration", 
null, $duration);
 
   49        $a_xml_writer->xmlStartTag(
"itemmetadata");
 
   50        $a_xml_writer->xmlStartTag(
"qtimetadata");
 
   51        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   52        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"ILIAS_VERSION");
 
   53        $a_xml_writer->xmlElement(
"fieldentry", 
null, $ilias->getSetting(
"ilias_version"));
 
   54        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   55        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   56        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"QUESTIONTYPE");
 
   58        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   59        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   60        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"IS_MULTIPLE_CHOICE");
 
   61        $a_xml_writer->xmlElement(
"fieldentry", 
null, ($this->object->getIsMultipleChoice())? 
"1": 
"0");
 
   62        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   63        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   64        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"AUTHOR");
 
   65        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->object->getAuthor());
 
   66        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   72        $a_xml_writer->xmlEndTag(
"qtimetadata");
 
   73        $a_xml_writer->xmlEndTag(
"itemmetadata");
 
   77            "label" => $this->object->getTitle()
 
   79        $a_xml_writer->xmlStartTag(
"presentation", $attrs);
 
   81        $a_xml_writer->xmlStartTag(
"flow");
 
   83        $this->
object->addQTIMaterial($a_xml_writer, $this->object->getQuestion());
 
   87            "rcardinality" => 
"Single" 
   89        $a_xml_writer->xmlStartTag(
"response_xy", $attrs);
 
   90        $solution = $this->
object->getSuggestedSolution(0);
 
   91        if (count($solution)) {
 
   92            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
 
   93                $a_xml_writer->xmlStartTag(
"material");
 
   94                $intlink = 
"il_" . IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
   95                if (strcmp($matches[1], 
"") != 0) {
 
   96                    $intlink = $solution[
"internal_link"];
 
   99                    "label" => 
"suggested_solution" 
  101                $a_xml_writer->xmlElement(
"mattext", $attrs, $intlink);
 
  102                $a_xml_writer->xmlEndTag(
"material");
 
  105        $a_xml_writer->xmlStartTag(
"render_hotspot");
 
  106        $a_xml_writer->xmlStartTag(
"material");
 
  107        $imagetype = 
"image/jpeg";
 
  108        if (preg_match(
"/.*\.(png|gif)$/i", $this->object->getImageFilename(), $matches)) {
 
  109            $imagetype = 
"image/" . strtolower($matches[1]);
 
  112            "imagtype" => $imagetype,
 
  113            "label" => $this->object->getImageFilename()
 
  115        if ($a_include_binary) {
 
  116            if ($force_image_references) {
 
  117                $attrs[
"uri"] = $this->
object->getImagePathWeb() . $this->
object->getImageFilename();
 
  118                $a_xml_writer->xmlElement(
"matimage", $attrs);
 
  120                $attrs[
"embedded"] = 
"base64";
 
  121                $imagepath = $this->
object->getImagePath() . $this->
object->getImageFilename();
 
  122                $fh = fopen($imagepath, 
"rb");
 
  129                $imagefile = fread($fh, filesize($imagepath));
 
  131                $base64 = base64_encode($imagefile);
 
  132                $a_xml_writer->xmlElement(
"matimage", $attrs, $base64, 
false, 
false);
 
  135            $a_xml_writer->xmlElement(
"matimage", $attrs);
 
  137        $a_xml_writer->xmlEndTag(
"material");
 
  140        foreach ($this->object->getAnswers() as 
$index => $answer) {
 
  142            switch ($answer->getArea()) {
 
  144                    $rarea = 
"Rectangle";
 
  157            $a_xml_writer->xmlStartTag(
"response_label", $attrs);
 
  158            $a_xml_writer->xmlData($answer->getCoords());
 
  159            $a_xml_writer->xmlStartTag(
"material");
 
  160            $a_xml_writer->xmlElement(
"mattext", 
null, $answer->getAnswertext());
 
  161            $a_xml_writer->xmlEndTag(
"material");
 
  162            $a_xml_writer->xmlEndTag(
"response_label");
 
  164        $a_xml_writer->xmlEndTag(
"render_hotspot");
 
  165        $a_xml_writer->xmlEndTag(
"response_xy");
 
  166        $a_xml_writer->xmlEndTag(
"flow");
 
  167        $a_xml_writer->xmlEndTag(
"presentation");
 
  170        $a_xml_writer->xmlStartTag(
"resprocessing");
 
  171        $a_xml_writer->xmlStartTag(
"outcomes");
 
  172        $a_xml_writer->xmlStartTag(
"decvar");
 
  173        $a_xml_writer->xmlEndTag(
"decvar");
 
  174        $a_xml_writer->xmlEndTag(
"outcomes");
 
  176        foreach ($this->object->getAnswers() as 
$index => $answer) {
 
  180            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  182            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  183            if (!$answer->isStateSet()) {
 
  184                $a_xml_writer->xmlStartTag(
"not");
 
  187            switch ($answer->getArea()) {
 
  189                    $areatype = 
"Rectangle";
 
  192                    $areatype = 
"Ellipse";
 
  195                    $areatype = 
"Bounded";
 
  200                "areatype" => $areatype
 
  202            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getCoords());
 
  203            if (!$answer->isStateSet()) {
 
  204                $a_xml_writer->xmlEndTag(
"not");
 
  206            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  211            $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
 
  212            $linkrefid = 
"response_$index";
 
  214                "feedbacktype" => 
"Response",
 
  215                "linkrefid" => $linkrefid
 
  217            $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  218            $a_xml_writer->xmlEndTag(
"respcondition");
 
  222            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  224            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  228            $a_xml_writer->xmlStartTag(
"not");
 
  229            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getCoords());
 
  230            $a_xml_writer->xmlEndTag(
"not");
 
  231            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  236            $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPointsUnchecked());
 
  237            $a_xml_writer->xmlEndTag(
"respcondition");
 
  240        $answers = $this->
object->getAnswers();
 
  241        $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
 
  242            $this->object->getId(),
 
  245        if (strlen($feedback_allcorrect) && count($answers) > 0) {
 
  249            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  251            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  252            if (!$this->object->getIsMultipleChoice()) {
 
  255                foreach ($answers as 
$index => $answer) {
 
  256                    if ($answer->getPoints() > $maxpoints) {
 
  257                        $maxpoints = $answer->getPoints();
 
  263                $answer = $answers[$bestindex];
 
  264                switch ($answer->getArea()) {
 
  266                        $areatype = 
"Rectangle";
 
  269                        $areatype = 
"Ellipse";
 
  272                        $areatype = 
"Bounded";
 
  277                    "areatype" => $areatype
 
  279                $a_xml_writer->xmlElement(
"varinside", $attrs, $answer->getCoords());
 
  281                foreach ($answers as 
$index => $answer) {
 
  282                    if ($answer->getPoints() < $answer->getPointsUnchecked()) {
 
  283                        $a_xml_writer->xmlStartTag(
"not");
 
  285                    switch ($answer->getArea()) {
 
  287                            $areatype = 
"Rectangle";
 
  290                            $areatype = 
"Ellipse";
 
  293                            $areatype = 
"Bounded";
 
  298                        "areatype" => $areatype
 
  300                    $a_xml_writer->xmlElement(
"varequal", $attrs, 
$index);
 
  301                    if ($answer->getPoints() < $answer->getPointsUnchecked()) {
 
  302                        $a_xml_writer->xmlEndTag(
"not");
 
  307            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  310                "feedbacktype" => 
"Response",
 
  311                "linkrefid" => 
"response_allcorrect" 
  313            $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  314            $a_xml_writer->xmlEndTag(
"respcondition");
 
  317        $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
 
  318            $this->object->getId(),
 
  321        if (strlen($feedback_onenotcorrect) && count($answers) > 0) {
 
  325            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  327            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  328            if (!$this->object->getIsMultipleChoice()) {
 
  331                foreach ($answers as 
$index => $answer) {
 
  332                    if ($answer->getPoints() > $maxpoints) {
 
  333                        $maxpoints = $answer->getPoints();
 
  340                $a_xml_writer->xmlStartTag(
"not");
 
  343                $answer = $answers[$bestindex];
 
  344                switch ($answer->getArea()) {
 
  346                        $areatype = 
"Rectangle";
 
  349                        $areatype = 
"Ellipse";
 
  352                        $areatype = 
"Bounded";
 
  357                    "areatype" => $areatype
 
  359                $a_xml_writer->xmlElement(
"varinside", $attrs, $answer->getCoords());
 
  361                $a_xml_writer->xmlEndTag(
"not");
 
  363                foreach ($answers as 
$index => $answer) {
 
  365                        $a_xml_writer->xmlStartTag(
"or");
 
  367                    if ($answer->getPoints() >= $answer->getPointsUnchecked()) {
 
  368                        $a_xml_writer->xmlStartTag(
"not");
 
  370                    switch ($answer->getArea()) {
 
  372                            $areatype = 
"Rectangle";
 
  375                            $areatype = 
"Ellipse";
 
  378                            $areatype = 
"Bounded";
 
  383                        "areatype" => $areatype
 
  385                    $a_xml_writer->xmlElement(
"varequal", $attrs, 
$index);
 
  386                    if ($answer->getPoints() >= $answer->getPointsUnchecked()) {
 
  387                        $a_xml_writer->xmlEndTag(
"not");
 
  390                        $a_xml_writer->xmlEndTag(
"or");
 
  394            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  397                "feedbacktype" => 
"Response",
 
  398                "linkrefid" => 
"response_onenotcorrect" 
  400            $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  401            $a_xml_writer->xmlEndTag(
"respcondition");
 
  404        $a_xml_writer->xmlEndTag(
"resprocessing");
 
  407        foreach ($this->object->getAnswers() as 
$index => $answer) {
 
  409            $linkrefid = 
"response_$index";
 
  411                "ident" => $linkrefid,
 
  414            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  416            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  417            $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
 
  418                $this->object->getId(),
 
  422            $this->
object->addQTIMaterial($a_xml_writer, $fb);
 
  423            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  424            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  426        if (strlen($feedback_allcorrect)) {
 
  428                "ident" => 
"response_allcorrect",
 
  431            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  433            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  434            $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
 
  435            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  436            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  438        if (strlen($feedback_onenotcorrect)) {
 
  440                "ident" => 
"response_onenotcorrect",
 
  443            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  445            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  446            $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
 
  447            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  448            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  451        $a_xml_writer->xmlEndTag(
"item");
 
  452        $a_xml_writer->xmlEndTag(
"questestinterop");
 
  454        $xml = $a_xml_writer->xmlDumpMem(
false);
 
  455        if (!$a_include_header) {
 
  456            $pos = strpos(
$xml, 
"?>");
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
Class for imagemap question exports.
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.
Class for question exports.
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...
xmlHeader()
Writes xml header @access public.
const IMAGEMAP_QUESTION_IDENTIFIER