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)
 
   30        include_once 
"./Services/Math/classes/class.EvalMath.php";
 
   32        $eval->suppress_errors = 
true;
 
   33        include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
 
   37        $a_xml_writer->xmlStartTag(
"questestinterop");
 
   39            "ident" => 
"il_" . IL_INST_ID . 
"_qst_" . $this->object->getId(),
 
   40            "title" => $this->object->getTitle(),
 
   41            "maxattempts" => $this->object->getNrOfTries()
 
   43        $a_xml_writer->xmlStartTag(
"item", $attrs);
 
   45        $a_xml_writer->xmlElement(
"qticomment", 
null, $this->object->getComment());
 
   47        $workingtime = $this->
object->getEstimatedWorkingTime();
 
   48        $duration = 
sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
 
   49        $a_xml_writer->xmlElement(
"duration", 
null, $duration);
 
   51        $a_xml_writer->xmlStartTag(
"itemmetadata");
 
   52        $a_xml_writer->xmlStartTag(
"qtimetadata");
 
   53        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   54        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"ILIAS_VERSION");
 
   55        $a_xml_writer->xmlElement(
"fieldentry", 
null, $ilias->getSetting(
"ilias_version"));
 
   56        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   57        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   58        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"QUESTIONTYPE");
 
   60        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   61        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   62        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"AUTHOR");
 
   63        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->object->getAuthor());
 
   64        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   70        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   71        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"textgaprating");
 
   72        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->object->getTextgapRating());
 
   73        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   75        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   76        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"fixedTextLength");
 
   77        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->object->getFixedTextLength());
 
   78        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   80        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   81        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"identicalScoring");
 
   82        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->object->getIdenticalScoring());
 
   83        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   85        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   86        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"combinations");
 
   87        $a_xml_writer->xmlElement(
"fieldentry", 
null, base64_encode(json_encode($this->object->getGapCombinations())));
 
   88        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   90        $a_xml_writer->xmlEndTag(
"qtimetadata");
 
   91        $a_xml_writer->xmlEndTag(
"itemmetadata");
 
   95            "label" => $this->object->getTitle()
 
   97        $a_xml_writer->xmlStartTag(
"presentation", $attrs);
 
   99        $a_xml_writer->xmlStartTag(
"flow");
 
  101        $questionText = $this->
object->getQuestion() ? $this->
object->getQuestion() : 
' ';
 
  102        $this->
object->addQTIMaterial($a_xml_writer, $questionText);
 
  104        $text_parts = preg_split(
"/\[gap.*?\[\/gap\]/", $this->object->getClozeText());
 
  107        for (
$i = 0; 
$i <= $this->
object->getGapCount(); 
$i++) {
 
  108            $this->
object->addQTIMaterial($a_xml_writer, $text_parts[
$i]);
 
  110            if ($i < $this->object->getGapCount()) {
 
  112                $gap = $this->
object->getGap($i);
 
  113                switch ($gap->getType()) {
 
  118                            "rcardinality" => 
"Single" 
  120                        $a_xml_writer->xmlStartTag(
"response_str", $attrs);
 
  121                        $solution = $this->
object->getSuggestedSolution($i);
 
  122                        if (count($solution)) {
 
  123                            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
 
  125                                    "label" => 
"suggested_solution" 
  127                                $a_xml_writer->xmlStartTag(
"material", $attrs);
 
  128                                $intlink = 
"il_" . IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
  129                                if (strcmp($matches[1], 
"") != 0) {
 
  130                                    $intlink = $solution[
"internal_link"];
 
  132                                $a_xml_writer->xmlElement(
"mattext", 
null, $intlink);
 
  133                                $a_xml_writer->xmlEndTag(
"material");
 
  137                        $attrs = array(
"shuffle" => ($gap->getShuffle() ? 
"Yes" : 
"No"));
 
  138                        $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
 
  143                                "ident" => $answeritem->getOrder()
 
  145                            $a_xml_writer->xmlStartTag(
"response_label", $attrs);
 
  146                            $a_xml_writer->xmlStartTag(
"material");
 
  147                            $a_xml_writer->xmlElement(
"mattext", 
null, $answeritem->getAnswertext());
 
  148                            $a_xml_writer->xmlEndTag(
"material");
 
  149                            $a_xml_writer->xmlEndTag(
"response_label");
 
  151                        $a_xml_writer->xmlEndTag(
"render_choice");
 
  152                        $a_xml_writer->xmlEndTag(
"response_str");
 
  158                            "rcardinality" => 
"Single" 
  160                        $a_xml_writer->xmlStartTag(
"response_str", $attrs);
 
  161                        $solution = $this->
object->getSuggestedSolution($i);
 
  162                        if (count($solution)) {
 
  163                            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
 
  165                                    "label" => 
"suggested_solution" 
  167                                $a_xml_writer->xmlStartTag(
"material", $attrs);
 
  168                                $intlink = 
"il_" . IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
  169                                if (strcmp($matches[1], 
"") != 0) {
 
  170                                    $intlink = $solution[
"internal_link"];
 
  172                                $a_xml_writer->xmlElement(
"mattext", 
null, $intlink);
 
  173                                $a_xml_writer->xmlEndTag(
"material");
 
  177                            "fibtype" => 
"String",
 
  179                            "columns" => $gap->getMaxWidth(),
 
  180                            "maxchars" => $gap->getGapSize()
 
  182                        $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
 
  183                        $a_xml_writer->xmlEndTag(
"render_fib");
 
  184                        $a_xml_writer->xmlEndTag(
"response_str");
 
  190                            "numtype" => 
"Decimal",
 
  191                            "rcardinality" => 
"Single" 
  193                        $a_xml_writer->xmlStartTag(
"response_num", $attrs);
 
  194                        $solution = $this->
object->getSuggestedSolution($i);
 
  195                        if (count($solution)) {
 
  196                            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
 
  198                                    "label" => 
"suggested_solution" 
  200                                $a_xml_writer->xmlStartTag(
"material", $attrs);
 
  201                                $intlink = 
"il_" . IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
  202                                if (strcmp($matches[1], 
"") != 0) {
 
  203                                    $intlink = $solution[
"internal_link"];
 
  205                                $a_xml_writer->xmlElement(
"mattext", 
null, $intlink);
 
  206                                $a_xml_writer->xmlEndTag(
"material");
 
  209                        $answeritem = $gap->getItem(0);
 
  211                            "fibtype" => 
"Decimal",
 
  213                            "columns" => $gap->getMaxWidth(),
 
  214                            "maxchars" => $gap->getGapSize()
 
  216                        if (is_object($answeritem)) {
 
  217                            if ($eval->e($answeritem->getLowerBound()) !== 
false) {
 
  218                                $attrs[
"minnumber"] = $answeritem->getLowerBound();
 
  220                            if ($eval->e($answeritem->getUpperBound()) !== 
false) {
 
  221                                $attrs[
"maxnumber"] = $answeritem->getUpperBound();
 
  224                        $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
 
  225                        $a_xml_writer->xmlEndTag(
"render_fib");
 
  226                        $a_xml_writer->xmlEndTag(
"response_num");
 
  231        $a_xml_writer->xmlEndTag(
"flow");
 
  232        $a_xml_writer->xmlEndTag(
"presentation");
 
  235        $a_xml_writer->xmlStartTag(
"resprocessing");
 
  236        $a_xml_writer->xmlStartTag(
"outcomes");
 
  237        $a_xml_writer->xmlStartTag(
"decvar");
 
  238        $a_xml_writer->xmlEndTag(
"decvar");
 
  239        $a_xml_writer->xmlEndTag(
"outcomes");
 
  242        for (
$i = 0; 
$i < $this->
object->getGapCount(); 
$i++) {
 
  243            $gap = $this->
object->getGap(
$i);
 
  244            switch ($gap->getType()) {
 
  250                        $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  252                        $a_xml_writer->xmlStartTag(
"conditionvar");
 
  255                            "respident" => 
"gap_$i" 
  257                        $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  258                        $a_xml_writer->xmlEndTag(
"conditionvar");
 
  263                        $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
 
  266                        $linkrefid = 
"$i" . 
"_Response_" . $answer->getOrder();
 
  268                            "feedbacktype" => 
"Response",
 
  269                            "linkrefid" => $linkrefid
 
  271                        $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  272                        $a_xml_writer->xmlEndTag(
"respcondition");
 
  280                        $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  282                        $a_xml_writer->xmlStartTag(
"conditionvar");
 
  284                            "respident" => 
"gap_$i" 
  286                        $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  287                        $a_xml_writer->xmlEndTag(
"conditionvar");
 
  292                        $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
 
  294                        $linkrefid = 
"$i" . 
"_Response_" . $answer->getOrder();
 
  296                            "feedbacktype" => 
"Response",
 
  297                            "linkrefid" => $linkrefid
 
  299                        $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  300                        $a_xml_writer->xmlEndTag(
"respcondition");
 
  308                        $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  310                        $a_xml_writer->xmlStartTag(
"conditionvar");
 
  312                            "respident" => 
"gap_$i" 
  314                        $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  315                        $a_xml_writer->xmlEndTag(
"conditionvar");
 
  320                        $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
 
  322                        $linkrefid = 
"$i" . 
"_Response_" . $answer->getOrder();
 
  324                            "feedbacktype" => 
"Response",
 
  325                            "linkrefid" => $linkrefid
 
  327                        $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  328                        $a_xml_writer->xmlEndTag(
"respcondition");
 
  334        $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
 
  335            $this->object->getId(),
 
  338        if (strlen($feedback_allcorrect)) {
 
  342            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  344            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  346            for (
$i = 0; 
$i < $this->
object->getGapCount(); 
$i++) {
 
  347                $gap = $this->
object->getGap(
$i);
 
  348                $indexes = $gap->getBestSolutionIndexes();
 
  350                    $a_xml_writer->xmlStartTag(
"and");
 
  352                switch ($gap->getType()) {
 
  355                        foreach ($indexes as 
$key) {
 
  357                                $a_xml_writer->xmlStartTag(
"or");
 
  360                                "respident" => 
"gap_$i" 
  362                            $answer = $gap->getItem(
$key);
 
  363                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  365                                $a_xml_writer->xmlEndTag(
"or");
 
  372                        foreach ($indexes as 
$key) {
 
  374                                $a_xml_writer->xmlStartTag(
"or");
 
  377                                "respident" => 
"gap_$i" 
  379                            $answer = $gap->getItem(
$key);
 
  380                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  382                                $a_xml_writer->xmlEndTag(
"or");
 
  389                        foreach ($indexes as 
$key) {
 
  391                                $a_xml_writer->xmlStartTag(
"or");
 
  394                                "respident" => 
"gap_$i" 
  396                            $answer = $gap->getItem(
$key);
 
  397                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  399                                $a_xml_writer->xmlEndTag(
"or");
 
  406                    $a_xml_writer->xmlEndTag(
"and");
 
  409            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  412                "feedbacktype" => 
"Response",
 
  413                "linkrefid" => 
"response_allcorrect" 
  415            $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  416            $a_xml_writer->xmlEndTag(
"respcondition");
 
  418        $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
 
  419            $this->object->getId(),
 
  422        if (strlen($feedback_onenotcorrect)) {
 
  426            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  428            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  430            $a_xml_writer->xmlStartTag(
"not");
 
  431            for (
$i = 0; 
$i < $this->
object->getGapCount(); 
$i++) {
 
  432                $gap = $this->
object->getGap(
$i);
 
  433                $indexes = $gap->getBestSolutionIndexes();
 
  435                    $a_xml_writer->xmlStartTag(
"and");
 
  437                switch ($gap->getType()) {
 
  440                        foreach ($indexes as 
$key) {
 
  442                                $a_xml_writer->xmlStartTag(
"or");
 
  445                                "respident" => 
"gap_$i" 
  447                            $answer = $gap->getItem(
$key);
 
  448                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  450                                $a_xml_writer->xmlEndTag(
"or");
 
  457                        foreach ($indexes as 
$key) {
 
  459                                $a_xml_writer->xmlStartTag(
"or");
 
  462                                "respident" => 
"gap_$i" 
  464                            $answer = $gap->getItem(
$key);
 
  465                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  467                                $a_xml_writer->xmlEndTag(
"or");
 
  474                        foreach ($indexes as 
$key) {
 
  476                                $a_xml_writer->xmlStartTag(
"or");
 
  479                                "respident" => 
"gap_$i" 
  481                            $answer = $gap->getItem(
$key);
 
  482                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  484                                $a_xml_writer->xmlEndTag(
"or");
 
  491                    $a_xml_writer->xmlEndTag(
"and");
 
  494            $a_xml_writer->xmlEndTag(
"not");
 
  495            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  498                "feedbacktype" => 
"Response",
 
  499                "linkrefid" => 
"response_onenotcorrect" 
  501            $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  502            $a_xml_writer->xmlEndTag(
"respcondition");
 
  505        $a_xml_writer->xmlEndTag(
"resprocessing");
 
  508        for (
$i = 0; 
$i < $this->
object->getGapCount(); 
$i++) {
 
  509            $gap = $this->
object->getGap(
$i);
 
  510            switch ($gap->getType()) {
 
  543            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  545            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  549            $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
 
  550                $this->object->getId(),
 
  553            $this->
object->addQTIMaterial($a_xml_writer, $fb);
 
  554            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  555            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  558        if (strlen($feedback_allcorrect)) {
 
  560                "ident" => 
"response_allcorrect",
 
  563            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  565            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  566            $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
 
  567            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  568            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  570        if (strlen($feedback_onenotcorrect)) {
 
  572                "ident" => 
"response_onenotcorrect",
 
  575            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  577            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  578            $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
 
  579            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  580            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  583        $a_xml_writer->xmlEndTag(
"item");
 
  584        $a_xml_writer->xmlEndTag(
"questestinterop");
 
  586        $xml = $a_xml_writer->xmlDumpMem(
false);
 
  587        if (!$a_include_header) {
 
  588            $pos = strpos(
$xml, 
"?>");
 
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Class for cloze 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 CLOZE_TEST_IDENTIFIER
Question identifier constants.
const CLOZE_TEXT
Cloze question constants.