Set the code to a randomly generated one if we are previewing the custom certificate
This commit is contained in:
parent
e811303e84
commit
b0ad1ff25b
1 changed files with 10 additions and 5 deletions
|
@ -37,11 +37,16 @@ class customcert_element_code extends customcert_element_base {
|
||||||
public function render($pdf, $preview) {
|
public function render($pdf, $preview) {
|
||||||
global $DB, $USER;
|
global $DB, $USER;
|
||||||
|
|
||||||
|
if ($preview) {
|
||||||
|
$code = customcert_generate_code();
|
||||||
|
} else {
|
||||||
// Get the page.
|
// Get the page.
|
||||||
$page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST);
|
$page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST);
|
||||||
// Now we can get the issue for this user.
|
// Now we can get the issue for this user.
|
||||||
$issue = $DB->get_record('customcert_issues', array('userid' => $USER->id, 'customcertid' => $page->customcertid), '*', MUST_EXIST);
|
$issue = $DB->get_record('customcert_issues', array('userid' => $USER->id, 'customcertid' => $page->customcertid), '*', MUST_EXIST);
|
||||||
|
$code = $issue->code;
|
||||||
|
}
|
||||||
|
|
||||||
parent::render_content($pdf, $issue->code);
|
parent::render_content($pdf, $code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue