Merge pull request #5833 from christianbeeznest/ofaj-22053

Internal: Fix PDF export formatting and encoding issues for exercise results - refs BT#22053
pull/5838/head
Nicolas Ducoulombier 11 months ago committed by GitHub
commit 328974d856
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      public/main/exercise/exercise_report.php
  2. 8
      public/main/inc/lib/pdf.lib.php

@ -699,7 +699,7 @@ if ($is_allowedToEdit || $is_tutor) {
['name' => 'duration', 'index' => 'exe_duration', 'width' => '150', 'align' => 'left', 'search' => 'true'], ['name' => 'duration', 'index' => 'exe_duration', 'width' => '150', 'align' => 'left', 'search' => 'true'],
['name' => 'start_date', 'index' => 'start_date', 'width' => '150', 'align' => 'left', 'search' => 'true'], ['name' => 'start_date', 'index' => 'start_date', 'width' => '150', 'align' => 'left', 'search' => 'true'],
['name' => 'exe_date', 'index' => 'exe_date', 'width' => '150', 'align' => 'left', 'search' => 'true'], ['name' => 'exe_date', 'index' => 'exe_date', 'width' => '150', 'align' => 'left', 'search' => 'true'],
['name' => 'score', 'index' => 'score', 'width' => '100', 'align' => 'center', 'search' => 'true'], ['name' => 'score', 'index' => 'score', 'width' => '120', 'align' => 'center', 'search' => 'true'],
['name' => 'ip', 'index' => 'user_ip', 'width' => '120', 'align' => 'center', 'search' => 'true'], ['name' => 'ip', 'index' => 'user_ip', 'width' => '120', 'align' => 'center', 'search' => 'true'],
[ [
'name' => 'status', 'name' => 'status',
@ -721,7 +721,7 @@ if ($is_allowedToEdit || $is_tutor) {
], ],
], ],
['name' => 'lp', 'index' => 'orig_lp_id', 'width' => '150', 'align' => 'left', 'search' => 'false'], ['name' => 'lp', 'index' => 'orig_lp_id', 'width' => '150', 'align' => 'left', 'search' => 'false'],
['name' => 'actions', 'index' => 'actions', 'width' => '120', 'align' => 'left', 'search' => 'false', 'sortable' => 'false'], ['name' => 'actions', 'index' => 'actions', 'width' => '180', 'align' => 'left', 'search' => 'false', 'sortable' => 'false'],
]; ];
if ('true' === $officialCodeInList) { if ('true' === $officialCodeInList) {

@ -137,6 +137,10 @@ class PDF
} }
} }
if (!empty($this->params['session_info']['title'])) {
$this->params['session_info']['title'] = preg_replace('/[\x{2600}-\x{26FF}]/u', '', $this->params['session_info']['title']);
}
$tpl->assign('pdf_course', $this->params['course_code']); $tpl->assign('pdf_course', $this->params['course_code']);
$tpl->assign('pdf_course_info', $this->params['course_info']); $tpl->assign('pdf_course_info', $this->params['course_info']);
$tpl->assign('pdf_session_info', $this->params['session_info']); $tpl->assign('pdf_session_info', $this->params['session_info']);
@ -413,7 +417,7 @@ class PDF
$basicStyles = []; $basicStyles = [];
$doc = new DOMDocument(); $doc = new DOMDocument();
@$doc->loadHTML($document_html); @$doc->loadHTML('<?xml encoding="UTF-8">' . $document_html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$linksToRemove = []; $linksToRemove = [];
@ -476,7 +480,7 @@ class PDF
$document_html $document_html
); );
$document_html = str_replace(api_get_path(WEB_ARCHIVE_PATH), api_get_path(SYS_ARCHIVE_PATH), $document_html); $document_html = str_replace(api_get_path(WEB_ARCHIVE_PATH), api_get_path(SYS_ARCHIVE_PATH), $document_html);
$document_html = str_replace('<?xml encoding="UTF-8">', '', $document_html);
// The library mPDF expects UTF-8 encoded input data. // The library mPDF expects UTF-8 encoded input data.
api_set_encoding_html($document_html, 'UTF-8'); api_set_encoding_html($document_html, 'UTF-8');
// At the moment the title is retrieved from the html document itself. // At the moment the title is retrieved from the html document itself.

Loading…
Cancel
Save