diff --git a/Modules/TestQuestionPool/classes/export/qti12/class.assClozeTestExport.php b/Modules/TestQuestionPool/classes/export/qti12/class.assClozeTestExport.php index 6504bfaf499d..30959de513aa 100644 --- a/Modules/TestQuestionPool/classes/export/qti12/class.assClozeTestExport.php +++ b/Modules/TestQuestionPool/classes/export/qti12/class.assClozeTestExport.php @@ -16,6 +16,8 @@ *********************************************************************/ use ILIAS\Refinery\Random\Group as RandomGroup; +use ILIAS\TA\Questions\assQuestionSuggestedSolution; +use ILIAS\TA\Questions\assSuggestedSolutionLink; /** * Class for cloze question exports @@ -169,15 +171,16 @@ public function toXML($a_include_header = true, $a_include_binary = true, $a_shu ]; $a_xml_writer->xmlStartTag("response_str", $attrs); $solution = $this->object->getSuggestedSolution($i); - if ($solution !== null && count($solution)) { - if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) { + if ($solution instanceof assSuggestedSolutionLink) { + $internalLink = $solution->getInternalLink(); + if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $internalLink, $matches)) { $attrs = [ "label" => "suggested_solution" ]; $a_xml_writer->xmlStartTag("material", $attrs); $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3]; - if (strcmp($matches[1], "") != 0) { - $intlink = $solution["internal_link"]; + if (strcmp($matches[1], "") !== 0) { + $intlink = $internalLink; } $a_xml_writer->xmlElement("mattext", null, $intlink); $a_xml_writer->xmlEndTag("material"); @@ -202,15 +205,16 @@ public function toXML($a_include_header = true, $a_include_binary = true, $a_shu ]; $a_xml_writer->xmlStartTag("response_num", $attrs); $solution = $this->object->getSuggestedSolution($i); - if ($solution !== null && count($solution)) { - if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches)) { + if ($solution instanceof assSuggestedSolutionLink) { + $internalLink = $solution->getInternalLink(); + if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $internalLink, $matches)) { $attrs = [ "label" => "suggested_solution" ]; $a_xml_writer->xmlStartTag("material", $attrs); $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3]; - if (strcmp($matches[1], "") != 0) { - $intlink = $solution["internal_link"]; + if (strcmp($matches[1], "") !== 0) { + $intlink = $internalLink; } $a_xml_writer->xmlElement("mattext", null, $intlink); $a_xml_writer->xmlEndTag("material");