Skip to content

Commit

Permalink
MBS-8820: Add adminsettings for background image height
Browse files Browse the repository at this point in the history
  • Loading branch information
PM84 committed Mar 15, 2024
1 parent 3073120 commit 9fb2e1b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
7 changes: 4 additions & 3 deletions classes/coversheet/create_coversheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<div style="' . join(' ', $styles) . '">' . $html . '</div>';
return $html;
}

Expand Down Expand Up @@ -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';
}
Expand Down
14 changes: 8 additions & 6 deletions lang/de/quiz_archiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,22 @@
$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';
$string['pdf_coversheet_backgroundimage_help'] = 'Das Hintergrundbild sollte das gewünschte Seitenformat haben.';
$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';
Expand Down
2 changes: 2 additions & 0 deletions lang/en/quiz_archiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
8 changes: 8 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 9fb2e1b

Please sign in to comment.