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/Math/classes/class.EvalMath.php";
 
   33        $eval->suppress_errors = 
true;
 
   34        include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
 
   38        $a_xml_writer->xmlStartTag(
"questestinterop");
 
   40            "ident" => 
"il_" . IL_INST_ID . 
"_qst_" . $this->object->getId(),
 
   41            "title" => $this->object->getTitle(),
 
   42            "maxattempts" => $this->object->getNrOfTries()
 
   44        $a_xml_writer->xmlStartTag(
"item", $attrs);
 
   46        $a_xml_writer->xmlElement(
"qticomment", 
null, $this->object->getComment());
 
   48        $workingtime = $this->
object->getEstimatedWorkingTime();
 
   49        $duration = sprintf(
"P0Y0M0DT%dH%dM%dS", $workingtime[
"h"], $workingtime[
"m"], $workingtime[
"s"]);
 
   50        $a_xml_writer->xmlElement(
"duration", 
null, $duration);
 
   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, 
"textgaprating");
 
   73        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->object->getTextgapRating());
 
   74        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   76        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   77        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"fixedTextLength");
 
   78        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->object->getFixedTextLength());
 
   79        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   81        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   82        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"identicalScoring");
 
   83        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->object->getIdenticalScoring());
 
   84        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   86        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   87        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"feedback_mode");
 
   88        $a_xml_writer->xmlElement(
"fieldentry", 
null, $this->object->getFeedbackMode());
 
   89        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   91        $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
   92        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"combinations");
 
   93        $a_xml_writer->xmlElement(
"fieldentry", 
null, base64_encode(json_encode($this->object->getGapCombinations())));
 
   94        $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
   96        $a_xml_writer->xmlEndTag(
"qtimetadata");
 
   97        $a_xml_writer->xmlEndTag(
"itemmetadata");
 
  101            "label" => $this->object->getTitle()
 
  103        $a_xml_writer->xmlStartTag(
"presentation", $attrs);
 
  105        $a_xml_writer->xmlStartTag(
"flow");
 
  107        $questionText = $this->
object->getQuestion() ? $this->
object->getQuestion() : 
' ';
 
  108        $this->
object->addQTIMaterial($a_xml_writer, $questionText);
 
  110        $text_parts = preg_split(
"/\[gap.*?\[\/gap\]/", $this->object->getClozeText());
 
  113        for (
$i = 0; 
$i <= $this->
object->getGapCount(); 
$i++) {
 
  114            $this->
object->addQTIMaterial($a_xml_writer, $text_parts[
$i]);
 
  116            if ($i < $this->object->getGapCount()) {
 
  118                $gap = $this->
object->getGap($i);
 
  119                switch ($gap->getType()) {
 
  124                            "rcardinality" => 
"Single" 
  126                        $a_xml_writer->xmlStartTag(
"response_str", $attrs);
 
  127                        $solution = $this->
object->getSuggestedSolution($i);
 
  128                        if (count($solution)) {
 
  129                            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
 
  131                                    "label" => 
"suggested_solution" 
  133                                $a_xml_writer->xmlStartTag(
"material", $attrs);
 
  134                                $intlink = 
"il_" . IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
  135                                if (strcmp($matches[1], 
"") != 0) {
 
  136                                    $intlink = $solution[
"internal_link"];
 
  138                                $a_xml_writer->xmlElement(
"mattext", 
null, $intlink);
 
  139                                $a_xml_writer->xmlEndTag(
"material");
 
  143                        $attrs = array(
"shuffle" => ($gap->getShuffle() ? 
"Yes" : 
"No"));
 
  144                        $a_xml_writer->xmlStartTag(
"render_choice", $attrs);
 
  149                                "ident" => $answeritem->getOrder()
 
  151                            $a_xml_writer->xmlStartTag(
"response_label", $attrs);
 
  152                            $a_xml_writer->xmlStartTag(
"material");
 
  153                            $a_xml_writer->xmlElement(
"mattext", 
null, $answeritem->getAnswertext());
 
  154                            $a_xml_writer->xmlEndTag(
"material");
 
  155                            $a_xml_writer->xmlEndTag(
"response_label");
 
  157                        $a_xml_writer->xmlEndTag(
"render_choice");
 
  158                        $a_xml_writer->xmlEndTag(
"response_str");
 
  164                            "rcardinality" => 
"Single" 
  166                        $a_xml_writer->xmlStartTag(
"response_str", $attrs);
 
  167                        $solution = $this->
object->getSuggestedSolution($i);
 
  168                        if (count($solution)) {
 
  169                            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
 
  171                                    "label" => 
"suggested_solution" 
  173                                $a_xml_writer->xmlStartTag(
"material", $attrs);
 
  174                                $intlink = 
"il_" . IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
  175                                if (strcmp($matches[1], 
"") != 0) {
 
  176                                    $intlink = $solution[
"internal_link"];
 
  178                                $a_xml_writer->xmlElement(
"mattext", 
null, $intlink);
 
  179                                $a_xml_writer->xmlEndTag(
"material");
 
  183                            "fibtype" => 
"String",
 
  185                            "columns" => $gap->getMaxWidth(),
 
  186                            "maxchars" => $gap->getGapSize()
 
  188                        $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
 
  189                        $a_xml_writer->xmlEndTag(
"render_fib");
 
  190                        $a_xml_writer->xmlEndTag(
"response_str");
 
  196                            "numtype" => 
"Decimal",
 
  197                            "rcardinality" => 
"Single" 
  199                        $a_xml_writer->xmlStartTag(
"response_num", $attrs);
 
  200                        $solution = $this->
object->getSuggestedSolution($i);
 
  201                        if (count($solution)) {
 
  202                            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches)) {
 
  204                                    "label" => 
"suggested_solution" 
  206                                $a_xml_writer->xmlStartTag(
"material", $attrs);
 
  207                                $intlink = 
"il_" . IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
  208                                if (strcmp($matches[1], 
"") != 0) {
 
  209                                    $intlink = $solution[
"internal_link"];
 
  211                                $a_xml_writer->xmlElement(
"mattext", 
null, $intlink);
 
  212                                $a_xml_writer->xmlEndTag(
"material");
 
  215                        $answeritem = $gap->getItem(0);
 
  217                            "fibtype" => 
"Decimal",
 
  219                            "columns" => $gap->getMaxWidth(),
 
  220                            "maxchars" => $gap->getGapSize()
 
  222                        if (is_object($answeritem)) {
 
  223                            if ($eval->e($answeritem->getLowerBound()) !== 
false) {
 
  224                                $attrs[
"minnumber"] = $answeritem->getLowerBound();
 
  226                            if ($eval->e($answeritem->getUpperBound()) !== 
false) {
 
  227                                $attrs[
"maxnumber"] = $answeritem->getUpperBound();
 
  230                        $a_xml_writer->xmlStartTag(
"render_fib", $attrs);
 
  231                        $a_xml_writer->xmlEndTag(
"render_fib");
 
  232                        $a_xml_writer->xmlEndTag(
"response_num");
 
  237        $a_xml_writer->xmlEndTag(
"flow");
 
  238        $a_xml_writer->xmlEndTag(
"presentation");
 
  241        $a_xml_writer->xmlStartTag(
"resprocessing");
 
  242        $a_xml_writer->xmlStartTag(
"outcomes");
 
  243        $a_xml_writer->xmlStartTag(
"decvar");
 
  244        $a_xml_writer->xmlEndTag(
"decvar");
 
  245        $a_xml_writer->xmlEndTag(
"outcomes");
 
  248        for (
$i = 0; 
$i < $this->
object->getGapCount(); 
$i++) {
 
  249            $gap = $this->
object->getGap(
$i);
 
  250            switch ($gap->getType()) {
 
  256                        $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  258                        $a_xml_writer->xmlStartTag(
"conditionvar");
 
  261                            "respident" => 
"gap_$i" 
  263                        $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  264                        $a_xml_writer->xmlEndTag(
"conditionvar");
 
  269                        $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
 
  272                        $linkrefid = 
"$i" . 
"_Response_" . $answer->getOrder();
 
  274                            "feedbacktype" => 
"Response",
 
  275                            "linkrefid" => $linkrefid
 
  277                        $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  278                        $a_xml_writer->xmlEndTag(
"respcondition");
 
  286                        $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  288                        $a_xml_writer->xmlStartTag(
"conditionvar");
 
  290                            "respident" => 
"gap_$i" 
  292                        $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  293                        $a_xml_writer->xmlEndTag(
"conditionvar");
 
  298                        $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
 
  300                        $linkrefid = 
"$i" . 
"_Response_" . $answer->getOrder();
 
  302                            "feedbacktype" => 
"Response",
 
  303                            "linkrefid" => $linkrefid
 
  305                        $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  306                        $a_xml_writer->xmlEndTag(
"respcondition");
 
  314                        $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  316                        $a_xml_writer->xmlStartTag(
"conditionvar");
 
  318                            "respident" => 
"gap_$i" 
  320                        $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  321                        $a_xml_writer->xmlEndTag(
"conditionvar");
 
  326                        $a_xml_writer->xmlElement(
"setvar", $attrs, $answer->getPoints());
 
  328                        $linkrefid = 
"$i" . 
"_Response_" . $answer->getOrder();
 
  330                            "feedbacktype" => 
"Response",
 
  331                            "linkrefid" => $linkrefid
 
  333                        $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  334                        $a_xml_writer->xmlEndTag(
"respcondition");
 
  340        $feedback_allcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
 
  341            $this->object->getId(),
 
  344        if (strlen($feedback_allcorrect)) {
 
  348            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  350            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  352            for (
$i = 0; 
$i < $this->
object->getGapCount(); 
$i++) {
 
  353                $gap = $this->
object->getGap(
$i);
 
  354                $indexes = $gap->getBestSolutionIndexes();
 
  356                    $a_xml_writer->xmlStartTag(
"and");
 
  358                switch ($gap->getType()) {
 
  361                        foreach ($indexes as 
$key) {
 
  363                                $a_xml_writer->xmlStartTag(
"or");
 
  366                                "respident" => 
"gap_$i" 
  368                            $answer = $gap->getItem(
$key);
 
  369                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  371                                $a_xml_writer->xmlEndTag(
"or");
 
  378                        foreach ($indexes as 
$key) {
 
  380                                $a_xml_writer->xmlStartTag(
"or");
 
  383                                "respident" => 
"gap_$i" 
  385                            $answer = $gap->getItem(
$key);
 
  386                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  388                                $a_xml_writer->xmlEndTag(
"or");
 
  395                        foreach ($indexes as 
$key) {
 
  397                                $a_xml_writer->xmlStartTag(
"or");
 
  400                                "respident" => 
"gap_$i" 
  402                            $answer = $gap->getItem(
$key);
 
  403                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  405                                $a_xml_writer->xmlEndTag(
"or");
 
  412                    $a_xml_writer->xmlEndTag(
"and");
 
  415            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  418                "feedbacktype" => 
"Response",
 
  419                "linkrefid" => 
"response_allcorrect" 
  421            $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  422            $a_xml_writer->xmlEndTag(
"respcondition");
 
  424        $feedback_onenotcorrect = $this->
object->feedbackOBJ->getGenericFeedbackExportPresentation(
 
  425            $this->object->getId(),
 
  428        if (strlen($feedback_onenotcorrect)) {
 
  432            $a_xml_writer->xmlStartTag(
"respcondition", $attrs);
 
  434            $a_xml_writer->xmlStartTag(
"conditionvar");
 
  436            $a_xml_writer->xmlStartTag(
"not");
 
  437            for (
$i = 0; 
$i < $this->
object->getGapCount(); 
$i++) {
 
  438                $gap = $this->
object->getGap(
$i);
 
  439                $indexes = $gap->getBestSolutionIndexes();
 
  441                    $a_xml_writer->xmlStartTag(
"and");
 
  443                switch ($gap->getType()) {
 
  446                        foreach ($indexes as 
$key) {
 
  448                                $a_xml_writer->xmlStartTag(
"or");
 
  451                                "respident" => 
"gap_$i" 
  453                            $answer = $gap->getItem(
$key);
 
  454                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  456                                $a_xml_writer->xmlEndTag(
"or");
 
  463                        foreach ($indexes as 
$key) {
 
  465                                $a_xml_writer->xmlStartTag(
"or");
 
  468                                "respident" => 
"gap_$i" 
  470                            $answer = $gap->getItem(
$key);
 
  471                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  473                                $a_xml_writer->xmlEndTag(
"or");
 
  480                        foreach ($indexes as 
$key) {
 
  482                                $a_xml_writer->xmlStartTag(
"or");
 
  485                                "respident" => 
"gap_$i" 
  487                            $answer = $gap->getItem(
$key);
 
  488                            $a_xml_writer->xmlElement(
"varequal", $attrs, $answer->getAnswertext());
 
  490                                $a_xml_writer->xmlEndTag(
"or");
 
  497                    $a_xml_writer->xmlEndTag(
"and");
 
  500            $a_xml_writer->xmlEndTag(
"not");
 
  501            $a_xml_writer->xmlEndTag(
"conditionvar");
 
  504                "feedbacktype" => 
"Response",
 
  505                "linkrefid" => 
"response_onenotcorrect" 
  507            $a_xml_writer->xmlElement(
"displayfeedback", $attrs);
 
  508            $a_xml_writer->xmlEndTag(
"respcondition");
 
  511        $a_xml_writer->xmlEndTag(
"resprocessing");
 
  514        for (
$i = 0; 
$i < $this->
object->getGapCount(); 
$i++) {
 
  515            $gap = $this->
object->getGap(
$i);
 
  516            switch ($gap->getType()) {
 
  565        if (strlen($feedback_allcorrect)) {
 
  567                "ident" => 
"response_allcorrect",
 
  570            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  572            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  573            $this->
object->addQTIMaterial($a_xml_writer, $feedback_allcorrect);
 
  574            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  575            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  577        if (strlen($feedback_onenotcorrect)) {
 
  579                "ident" => 
"response_onenotcorrect",
 
  582            $a_xml_writer->xmlStartTag(
"itemfeedback", $attrs);
 
  584            $a_xml_writer->xmlStartTag(
"flow_mat");
 
  585            $this->
object->addQTIMaterial($a_xml_writer, $feedback_onenotcorrect);
 
  586            $a_xml_writer->xmlEndTag(
"flow_mat");
 
  587            $a_xml_writer->xmlEndTag(
"itemfeedback");
 
  590        $a_xml_writer->xmlEndTag(
"item");
 
  591        $a_xml_writer->xmlEndTag(
"questestinterop");
 
  593        $xml = $a_xml_writer->xmlDumpMem(
false);
 
  594        if (!$a_include_header) {
 
  595            $pos = strpos(
$xml, 
"?>");
 
  606        require_once 
'Modules/TestQuestionPool/classes/feedback/class.ilAssSpecificFeedbackIdentifierList.php';
 
  608        $feedbackIdentifierList->load($this->object->getId());
 
  610        foreach ($feedbackIdentifierList as $fbIdentifier) {
 
  611            $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation(
 
  612                $this->object->getId(),
 
  613                $fbIdentifier->getQuestionIndex(),
 
  614                $fbIdentifier->getAnswerIndex()
 
  622            $this->
object->addQTIMaterial($xmlWriter, $feedback);
 
  635        return "{$fbIdentifier->getQuestionIndex()}_{$fbIdentifier->getAnswerIndex()}";
 
An exception for terminatinating execution or to throw for unit testing.
Class for cloze question exports.
exportAnswerSpecificFeedbacks(ilXmlWriter $xmlWriter)
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.
buildQtiExportIdent(ilAssSpecificFeedbackIdentifier $fbIdentifier)
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...
xmlEndTag($tag)
Writes an endtag.
xmlHeader()
Writes xml header @access public.
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
const CLOZE_TEST_IDENTIFIER
Question identifier constants.
const CLOZE_TEXT
Cloze question constants.