Set a date and grade to display when previewing a customcert
This commit is contained in:
parent
801f367616
commit
ff1bdc42af
3 changed files with 37 additions and 25 deletions
|
@ -96,6 +96,10 @@ class customcert_element_date extends customcert_element_base {
|
|||
$dateitem = $dateinfo->dateitem;
|
||||
$dateformat = $dateinfo->dateformat;
|
||||
|
||||
// If we are previewing this certificate then just show a demonstration date.
|
||||
if ($preview) {
|
||||
$date = time();
|
||||
} else {
|
||||
// Get the page.
|
||||
$page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST);
|
||||
// Now we can get the issue for this user.
|
||||
|
@ -122,6 +126,7 @@ class customcert_element_date extends customcert_element_base {
|
|||
$date = $modinfo->dategraded;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that a date has been set.
|
||||
if (!empty($date)) {
|
||||
|
|
|
@ -33,3 +33,4 @@ $string['gradepercent'] = 'Percentage Grade';
|
|||
$string['gradepoints'] = 'Points Grade';
|
||||
$string['gradeletter'] = 'Letter Grade';
|
||||
$string['pluginname'] = 'Grade';
|
||||
$string['previewgrade'] = 'Preview grade';
|
||||
|
|
|
@ -94,8 +94,14 @@ class customcert_element_grade extends customcert_element_base {
|
|||
// Decode the information stored in the database.
|
||||
$gradeinfo = json_decode($this->element->data);
|
||||
|
||||
// If we are previewing this certificate then just show a demonstration grade.
|
||||
if ($preview) {
|
||||
$grade = get_string('previewgrade', 'customcertelement_grade') . ": 50%";
|
||||
} else {
|
||||
// Get the grade for the grade item.
|
||||
$grade = self::get_grade($gradeinfo, $USER->id);
|
||||
}
|
||||
|
||||
parent::render_content($pdf, $grade);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue