Fixed errors in the 'code' and 'date' elements
This commit is contained in:
parent
05e83ee638
commit
728c4da5e3
2 changed files with 11 additions and 3 deletions
|
@ -41,8 +41,10 @@ class element extends \mod_customcert\element {
|
|||
} else {
|
||||
// Get the page.
|
||||
$page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST);
|
||||
// Get the customcert this page belongs to.
|
||||
$customcert = $DB->get_record('customcert', array('templateid' => $page->templateid), '*', MUST_EXIST);
|
||||
// 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' => $customcert->id), '*', MUST_EXIST);
|
||||
$code = $issue->code;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ define('CUSTOMCERT_DATE_ISSUE', '1');
|
|||
*/
|
||||
define('CUSTOMCERT_DATE_COMPLETION', '2');
|
||||
|
||||
require_once($CFG->dirroot . '/lib/grade/constants.php');
|
||||
|
||||
/**
|
||||
* The customcert element date's core interaction API.
|
||||
*
|
||||
|
@ -101,8 +103,10 @@ class element extends \mod_customcert\element {
|
|||
} else {
|
||||
// Get the page.
|
||||
$page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST);
|
||||
// Get the customcert this page belongs to.
|
||||
$customcert = $DB->get_record('customcert', array('templateid' => $page->templateid), '*', MUST_EXIST);
|
||||
// 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' => $customcert->id), '*', MUST_EXIST);
|
||||
|
||||
if ($dateitem == CUSTOMCERT_DATE_ISSUE) {
|
||||
$date = $issue->timecreated;
|
||||
|
@ -122,10 +126,12 @@ class element extends \mod_customcert\element {
|
|||
$gradeitem->gradeitem = $dateitem;
|
||||
$gradeitem->gradeformat = GRADE_DISPLAY_TYPE_PERCENTAGE;
|
||||
if ($modinfo = \customcertelement_grade\element::get_grade($gradeitem, $issue->userid)) {
|
||||
if (!empty($modinfo->dategraded)) {
|
||||
$date = $modinfo->dategraded;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that a date has been set.
|
||||
if (!empty($date)) {
|
||||
|
|
Loading…
Reference in a new issue