Check course time using new logging API

This commit is contained in:
Mark Nelson 2015-03-11 00:29:18 -07:00
parent 7a2675e889
commit a61997b2aa
2 changed files with 51 additions and 13 deletions

View file

@ -45,6 +45,16 @@ $PAGE->set_cm($cm);
$PAGE->set_title(format_string($customcert->name));
$PAGE->set_heading(format_string($course->fullname));
// Check if the user can view the certificate based on time spent in course.
if ($customcert->requiredtime && !has_capability('mod/certificate:manage', $context)) {
if (customcert_get_course_time($course->id) < ($customcert->requiredtime * 60)) {
$a = new stdClass;
$a->requiredtime = $customcert->requiredtime;
notice(get_string('requiredtimenotmet', 'certificate', $a), "$CFG->wwwroot/course/view.php?id=$course->id");
die;
}
}
// Check that no action was passed, if so that means we are not outputting to PDF.
if (empty($action)) {
// Get the current groups mode.