Fixed issue where elements for the customcert page with the id 1 were being displayed (if it existed) for newly created customcerts
This commit is contained in:
parent
d6428b89d1
commit
08c4f03ee7
2 changed files with 25 additions and 22 deletions
|
@ -238,6 +238,8 @@ class mod_customcert_edit_form extends moodleform {
|
||||||
$mform->addElement('html', html_writer::end_tag('div'));
|
$mform->addElement('html', html_writer::end_tag('div'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that this page is not a newly created one with no data in the database.
|
||||||
|
if (!is_null($page)) {
|
||||||
// Check if there are elements to add.
|
// Check if there are elements to add.
|
||||||
if ($elements = $DB->get_records('customcert_elements', array('pageid' => $pageid), 'id ASC')) {
|
if ($elements = $DB->get_records('customcert_elements', array('pageid' => $pageid), 'id ASC')) {
|
||||||
// Loop through and add the ones present.
|
// Loop through and add the ones present.
|
||||||
|
@ -263,4 +265,5 @@ class mod_customcert_edit_form extends moodleform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
2
lib.php
2
lib.php
|
@ -442,7 +442,7 @@ function customcert_save_page_data($data) {
|
||||||
// Get the total number of pages that exist for this customcert.
|
// Get the total number of pages that exist for this customcert.
|
||||||
$totalpages = $DB->count_records('customcert_pages', array('customcertid' => $data->id));
|
$totalpages = $DB->count_records('customcert_pages', array('customcertid' => $data->id));
|
||||||
|
|
||||||
// Check if this file has any pages yet, if not we are inserting.
|
// Check if this customcert has any pages yet, if not we are inserting.
|
||||||
if ($totalpages == 0) {
|
if ($totalpages == 0) {
|
||||||
// Create the page to insert.
|
// Create the page to insert.
|
||||||
$page = new stdClass();
|
$page = new stdClass();
|
||||||
|
|
Loading…
Reference in a new issue