From 9fb2e1b34003d04f69494545749d9e4705ce11cb Mon Sep 17 00:00:00 2001 From: Peter Mayer Date: Thu, 14 Mar 2024 23:42:37 +0100 Subject: [PATCH] MBS-8820: Add adminsettings for background image height --- classes/coversheet/create_coversheet.php | 7 ++++--- lang/de/quiz_archiver.php | 14 ++++++++------ lang/en/quiz_archiver.php | 2 ++ settings.php | 8 ++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/classes/coversheet/create_coversheet.php b/classes/coversheet/create_coversheet.php index 4c4f02f..3e8c22d 100644 --- a/classes/coversheet/create_coversheet.php +++ b/classes/coversheet/create_coversheet.php @@ -83,10 +83,11 @@ public static function get_coversheet(int $attemptid): string { $templatecontext['backgroundimage64'] = 'data:image/png;base64,' . $imgdata64; } $templatecontext['html'] = $html; - $templatecontext['styles'] = 'page-break-after: always; width: 100%; height: 100vh;'; + $height = (empty(get_config('backgroundimage_height', 'quiz_archiver'))) ? '1000px' + : get_config('backgroundimage_height', 'quiz_archiver'); + $templatecontext['styles'] = 'page-break-after: always; height: ' . $height . ';'; $html = $OUTPUT->render_from_template('quiz_archiver/pdfcoversheet_html_sceleton', $templatecontext); - // $html = '
' . $html . '
'; return $html; } @@ -158,7 +159,7 @@ public static function get_possible_placeholders(): array { foreach ($basenames as $basename) { $active = ''; $show = ''; - if($i == 1) { + if ($i == 1) { $show = 'show'; $active = 'active'; } diff --git a/lang/de/quiz_archiver.php b/lang/de/quiz_archiver.php index 8ecc18f..f70be12 100644 --- a/lang/de/quiz_archiver.php +++ b/lang/de/quiz_archiver.php @@ -85,8 +85,10 @@ $string['num_attempts'] = 'Anzahl Testversuche'; // Language strings for pdf cover sheet. -$string['pdfcoversheet_settings'] = 'PDF-Deckblatt'; -$string['pdfcoversheet_settings_desc'] = 'Ein Standard-Deckblatt festlegen'; +$string['common'] = 'Allgemein'; +$string['course'] = 'Kurs'; +$string['dateformat'] = 'd.m.Y'; +$string['define_pdfcoversheet'] = 'Deckblatt definieren'; $string['enable_pdf_coversheet'] = 'PDF-Deckblatt anzeigen'; $string['enable_pdf_coversheet_help'] = 'Ein Deckblatt zu den PDF-Versuchen hinzufügen'; $string['pdf_coversheet_backgroundimage'] = 'Deckblatt-Hintergrundbild'; @@ -94,11 +96,11 @@ $string['pdf_coversheet_html_area'] = 'Dynamischer Inhalt des Deckblatts'; $string['pdf_coversheet_html_area_help'] = 'Platzhalter für dynamische Deckblattinhalte verwenden'; $string['pdfcoversheet_heading'] = 'PDF-Deckblatt'; -$string['define_pdfcoversheet'] = 'Deckblatt definieren'; +$string['pdfcoversheet_settings'] = 'PDF-Deckblatt'; +$string['pdfcoversheet_settings_desc'] = 'Ein Standard-Deckblatt festlegen'; $string['profile'] = 'Profil'; -$string['course'] = 'Kurs'; -$string['common'] = 'Allgemein'; -$string['dateformat'] = 'd.m.Y'; +$string['setting_backgroundimage_height'] = 'Höhe des Hintergrundbildes'; +$string['setting_backgroundimage_height_desc'] = 'Die Höhe des Hintergrundbildes. Wenn diese Einstellung zu groß ist, kann das Deckblatt auf zwei Seiten aufgeteilt werden.'; // Job creation form: Filename pattern $string['archive_filename_pattern'] = 'Archivname'; diff --git a/lang/en/quiz_archiver.php b/lang/en/quiz_archiver.php index 3583ce7..cc1d7e4 100644 --- a/lang/en/quiz_archiver.php +++ b/lang/en/quiz_archiver.php @@ -101,6 +101,8 @@ $string['course'] = 'Course'; $string['common'] = 'Common'; $string['dateformat'] = 'd/m/Y'; +$string['setting_backgroundimage_height'] = 'Backgroundimage Height'; +$string['setting_backgroundimage_height_desc'] = 'The height of the backgroundimage. If this setting is to big, the coversheet may be split up into two pages.'; // Job creation form: Filename pattern $string['archive_filename_pattern'] = 'Archive name'; diff --git a/settings.php b/settings.php index 203361a..9468a7e 100644 --- a/settings.php +++ b/settings.php @@ -219,6 +219,14 @@ ['maxfiles' => 1, 'accepted_types' => ['.png', '.jpg']] )); + $settings->add(new admin_setting_configtext( + 'quiz_archiver/backgroundimage_height', + get_string('setting_backgroundimage_height', 'quiz_archiver'), + get_string('setting_backgroundimage_height_desc', 'quiz_archiver'), + '1000px', + PARAM_ALPHANUM + )); + $settings->add( new setting_button( 'quiz_archiver/pdfcoversheet_settings',