diff --git a/Modules/Test/classes/class.ilObjTestGUI.php b/Modules/Test/classes/class.ilObjTestGUI.php index 5697650e1cbd..5e7bd9ba73a7 100755 --- a/Modules/Test/classes/class.ilObjTestGUI.php +++ b/Modules/Test/classes/class.ilObjTestGUI.php @@ -3123,6 +3123,12 @@ function printobject() $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng); $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput()); + if($isPdfDeliveryRequest) + { + require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php'; + ilWACSignedPath::setTokenMaxLifetimeInSeconds(60); + } + foreach ($this->object->questions as $question) { $template->setCurrentBlock("question"); @@ -3157,7 +3163,6 @@ function printobject() if( $isPdfDeliveryRequest ) { - //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle()); require_once 'class.ilTestPDFGenerator.php'; ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle()); } @@ -3188,6 +3193,8 @@ function reviewobject() $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); + $isPdfDeliveryRequest = isset($_GET['pdf']) && $_GET['pdf']; + global $ilUser; $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y")); $max_points= 0; @@ -3196,6 +3203,12 @@ function reviewobject() require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php'; $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng); $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput()); + + if($isPdfDeliveryRequest) + { + require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php'; + ilWACSignedPath::setTokenMaxLifetimeInSeconds(60); + } foreach ($this->object->questions as $question) { @@ -3227,11 +3240,9 @@ function reviewobject() $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points"))); $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points)); - if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1)) + if($isPdfDeliveryRequest) { - //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle()); require_once 'class.ilTestPDFGenerator.php'; - $content = $template->get(); ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle()); } else diff --git a/Modules/Test/classes/class.ilTestPDFGenerator.php b/Modules/Test/classes/class.ilTestPDFGenerator.php index 42bb6d29939d..2089eb4dd5a5 100644 --- a/Modules/Test/classes/class.ilTestPDFGenerator.php +++ b/Modules/Test/classes/class.ilTestPDFGenerator.php @@ -69,7 +69,26 @@ private static function makeHtmlDocument($contentHtml, $styleHtml) } $dom->encoding = 'UTF-8'; + + $img_src_map = array(); + foreach($dom->getElementsByTagName('img') as $elm) + { + /** @var $elm DOMElement $uid */ + $uid = 'img_src_' . uniqid(); + $src = $elm->getAttribute('src'); + + $elm->setAttribute('src', $uid); + + $img_src_map[$uid] = $src; + } + $cleaned_html = $dom->saveHTML(); + + foreach($img_src_map as $uid => $src) + { + $cleaned_html = str_replace($uid, $src, $cleaned_html); + } + if(!$cleaned_html) { return $html;