Skip to content

Commit 1d74bcb

Browse files
gbarat87mdjnelson
authored andcommitted
Add setting to add a button to return to course (#655)
1 parent ac2fdda commit 1d74bcb

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

lang/en/customcert.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@
203203
$string['refpoint_help'] = 'The reference point is the location of an element from which its x and y coordinates are determined. It is indicated by the \'+\' that appears in the centre or corners of the element.';
204204
$string['replacetemplate'] = 'Replace';
205205
$string['requiredtimenotmet'] = 'You must spend at least a minimum of {$a->requiredtime} minutes in the course before you can access this certificate.';
206+
$string['returncourse'] = 'Return to course button';
207+
$string['returncourse_desc'] = 'Display a "return to course" button';
208+
$string['returncourselabel'] = 'Return to course menu';
206209
$string['rightmargin'] = 'Right margin';
207210
$string['rightmargin_help'] = 'This is the right margin of the certificate PDF in mm.';
208211
$string['save'] = 'Save';

settings.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@
7878
get_string('certificateexecutionperiod', 'customcert'),
7979
get_string('certificateexecutionperiod_desc', 'customcert'), 365 * DAYSECS));
8080

81+
$settings->add(new admin_setting_configcheckbox('customcert/returncourse',
82+
get_string('returncourse', 'customcert'),
83+
get_string('returncourse_desc', 'customcert'),
84+
0));
85+
8186
$settings->add(new admin_setting_heading('defaults',
8287
get_string('modeditdefaults', 'admin'), get_string('condifmodeditdefaults', 'admin')));
8388

view.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,19 @@
157157

158158
// Create the button to download the customcert.
159159
$downloadbutton = '';
160+
$renderbuttoncourse = '';
161+
$displayreturnbutton = get_config('customcert', 'returncourse');
160162
if ($canreceive) {
161163
$linkname = get_string('getcustomcert', 'customcert');
162164
$link = new moodle_url('/mod/customcert/view.php', ['id' => $cm->id, 'downloadown' => true]);
163165
$downloadbutton = new single_button($link, $linkname, 'get', single_button::BUTTON_PRIMARY);
164166
$downloadbutton->class .= ' m-b-1'; // Seems a bit hackish, ahem.
165167
$downloadbutton = $OUTPUT->render($downloadbutton);
168+
if ($displayreturnbutton) {
169+
$url = new moodle_url('/course/view.php', ['id' => $course->id]);
170+
$buttonreturntocourse = new single_button($url, get_string('returncourselabel', 'customcert'), 'get', true);
171+
$renderbuttoncourse = $OUTPUT->render($buttonreturntocourse);
172+
}
166173
}
167174

168175
$numissues = \mod_customcert\certificate::get_number_of_issues($customcert->id, $cm, $groupmode);
@@ -187,6 +194,9 @@
187194
echo $issuehtml;
188195
echo $downloadbutton;
189196
echo $downloadallbutton;
197+
if ($displayreturnbutton) {
198+
echo $renderbuttoncourse;
199+
}
190200
if (isset($reporttable)) {
191201
echo $OUTPUT->heading(get_string('listofissues', 'customcert', $numissues), 3);
192202
groups_print_activity_menu($cm, $pageurl);

0 commit comments

Comments
 (0)