Fixed issue when no grade items present
This commit is contained in:
parent
0abc6a0f5c
commit
53cb267836
1 changed files with 14 additions and 7 deletions
|
@ -49,9 +49,13 @@ class customcert_element_gradeitemname extends customcert_element_base {
|
|||
* @return string the text
|
||||
*/
|
||||
public function save_unique_data($data) {
|
||||
if (!empty($data->gradeitem)) {
|
||||
return $data->gradeitem;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
|
@ -61,6 +65,8 @@ class customcert_element_gradeitemname extends customcert_element_base {
|
|||
public function render($pdf, $preview) {
|
||||
global $DB;
|
||||
|
||||
// Check that the grade item is not empty.
|
||||
if (!empty($this->element->data)) {
|
||||
// Get the course module information.
|
||||
$cm = $DB->get_record('course_modules', array('id' => $this->element->data), '*', MUST_EXIST);
|
||||
$module = $DB->get_record('modules', array('id' => $cm->module), '*', MUST_EXIST);
|
||||
|
@ -70,6 +76,7 @@ class customcert_element_gradeitemname extends customcert_element_base {
|
|||
|
||||
parent::render_content($pdf, $itemname);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data on the form when editing an element.
|
||||
|
|
Loading…
Reference in a new issue