Skip to content

Commit

Permalink
Add common placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
PM84 committed Mar 12, 2024
1 parent 73113ea commit 3073120
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
11 changes: 11 additions & 0 deletions classes/coversheet/create_coversheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,25 @@ public static function get_possible_placeholders(): array {
$placeholders = [];
$dir = $CFG->dirroot . "/mod/quiz/report/archiver/classes/coversheet/placeholder";
$basenames = self::get_all_files_in_directory($dir);
$i = 1;
foreach ($basenames as $basename) {
$active = '';
$show = '';
if($i == 1) {
$show = 'show';
$active = 'active';
}
$placeholders[] = [
'placeholders' => self::get_placeholders($basename, "\quiz_archiver\coversheet\placeholder\\$basename"),
'metadata' => [
'tabid' => 'qa_' . $basename . '_tab',
'tab' => get_string($basename, 'quiz_archiver'),
'active' => $active,
'show' => $show,
],
];

$i++;
}

return $placeholders;
Expand Down
49 changes: 49 additions & 0 deletions classes/coversheet/placeholder/common.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Handles everything that is needed for coversheet creation.
*
* @package quiz_archiver
* @copyright ISB Bayern, 2024
* @author Dr. Peter Mayer
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace quiz_archiver\coversheet\placeholder;

defined('MOODLE_INTERNAL') || die();

/**
* Handles everything that is needed for coversheet creation.
*
* @package quiz_archiver
* @copyright ISB Bayern, 2024
* @author Dr. Peter Mayer
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class common {

/**
* Get user date.
* @param object $params
* @return string
*/
public static function date(): string {
return date(get_string('dateformat', 'quiz_archiver'), time());
}

}
4 changes: 4 additions & 0 deletions lang/de/quiz_archiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
$string['pdf_coversheet_html_area_help'] = 'Platzhalter für dynamische Deckblattinhalte verwenden';
$string['pdfcoversheet_heading'] = 'PDF-Deckblatt';
$string['define_pdfcoversheet'] = 'Deckblatt definieren';
$string['profile'] = 'Profil';
$string['course'] = 'Kurs';
$string['common'] = 'Allgemein';
$string['dateformat'] = 'd.m.Y';

// 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 @@ -99,6 +99,8 @@
$string['exiting_placeholders_desc'] = 'You can use the placeholder by writing {{placeholder}} e.g. {{profile_userfullname}} to the template above.';
$string['profile'] = 'Profile';
$string['course'] = 'Course';
$string['common'] = 'Common';
$string['dateformat'] = 'd/m/Y';

// Job creation form: Filename pattern
$string['archive_filename_pattern'] = 'Archive name';
Expand Down
4 changes: 2 additions & 2 deletions templates/define_pdfcoversheet.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
<ul class="nav nav-tabs" id="myTab" role="tablist">
{{#placeholderdata}}
<li class="nav-item" role="presentation">
<button class="nav-link" data-toggle="tab" id='nav-{{metadata.tabid}}' data-target="#{{metadata.tabid}}"
<button class="nav-link {{metadata.active}}" data-toggle="tab" id='nav-{{metadata.tabid}}' data-target="#{{metadata.tabid}}"
type="button" role="tab" aria-controls="{{metadata.tabid}}">{{metadata.tab}}</button>
</li>
{{/placeholderdata}}
</ul>
<div class="tab-content" id="myTabContent">
{{#placeholderdata}}
<div class="tab-pane fade" id="{{metadata.tabid}}" role="tabpanel" aria-labelledby="nav-{{metadata.tabid}}">
<div class="tab-pane fade {{metadata.show}} {{metadata.active}}" id="{{metadata.tabid}}" role="tabpanel" aria-labelledby="nav-{{metadata.tabid}}">
<ul>
{{#placeholders}}
<li>{{.}}</li>
Expand Down

0 comments on commit 3073120

Please sign in to comment.