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 {
|
} 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);
|
||||||
|
// 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.
|
// 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;
|
$code = $issue->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ define('CUSTOMCERT_DATE_ISSUE', '1');
|
||||||
*/
|
*/
|
||||||
define('CUSTOMCERT_DATE_COMPLETION', '2');
|
define('CUSTOMCERT_DATE_COMPLETION', '2');
|
||||||
|
|
||||||
|
require_once($CFG->dirroot . '/lib/grade/constants.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The customcert element date's core interaction API.
|
* The customcert element date's core interaction API.
|
||||||
*
|
*
|
||||||
|
@ -101,8 +103,10 @@ class element extends \mod_customcert\element {
|
||||||
} else {
|
} 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);
|
||||||
|
// 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.
|
// 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) {
|
if ($dateitem == CUSTOMCERT_DATE_ISSUE) {
|
||||||
$date = $issue->timecreated;
|
$date = $issue->timecreated;
|
||||||
|
@ -122,7 +126,9 @@ class element extends \mod_customcert\element {
|
||||||
$gradeitem->gradeitem = $dateitem;
|
$gradeitem->gradeitem = $dateitem;
|
||||||
$gradeitem->gradeformat = GRADE_DISPLAY_TYPE_PERCENTAGE;
|
$gradeitem->gradeformat = GRADE_DISPLAY_TYPE_PERCENTAGE;
|
||||||
if ($modinfo = \customcertelement_grade\element::get_grade($gradeitem, $issue->userid)) {
|
if ($modinfo = \customcertelement_grade\element::get_grade($gradeitem, $issue->userid)) {
|
||||||
$date = $modinfo->dategraded;
|
if (!empty($modinfo->dategraded)) {
|
||||||
|
$date = $modinfo->dategraded;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue