Fixed exception loading template image that has no image selected (#369)
This commit is contained in:
parent
03d56eddae
commit
4765c11a46
1 changed files with 24 additions and 21 deletions
|
@ -420,6 +420,8 @@ class element extends \mod_customcert\element {
|
|||
|
||||
$fs = get_file_storage();
|
||||
|
||||
// Check that a file has been selected.
|
||||
if (isset($imagedata->filearea)) {
|
||||
// If the course file doesn't exist, copy the system file to the course context.
|
||||
if (!$coursefile = $fs->get_file(
|
||||
$coursecontext->id,
|
||||
|
@ -448,6 +450,7 @@ class element extends \mod_customcert\element {
|
|||
// Set the image to the copied file in the course.
|
||||
$imagedata->fileid = $coursefile->get_id();
|
||||
$DB->set_field('customcert_elements', 'data', $this->save_unique_data($imagedata), ['id' => $this->get_id()]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue