diff --git a/lang/en/certificate.php b/lang/en/certificate.php index 88e9d34..d90abf9 100644 --- a/lang/en/certificate.php +++ b/lang/en/certificate.php @@ -201,4 +201,6 @@ $string['verifycertificate'] = 'Verify Certificate'; $string['viewcertificateviews'] = 'View {$a} issued certificates'; $string['viewed'] = 'You received this certificate on:'; $string['viewtranscript'] = 'View Certificates'; -$string['watermark'] = 'Watermark'; \ No newline at end of file +$string['watermark'] = 'Watermark'; +$string['completionrequired'] = "

You have not completed the course.


+

While the criteria for course completion are not met, the certificate can not be issued.

"; diff --git a/view.php b/view.php index e251af1..283d71c 100644 --- a/view.php +++ b/view.php @@ -84,6 +84,12 @@ if ($certificate->requiredtime && !has_capability('mod/certificate:manage', $con } } +// Check if the user has completed the course +if (!$completion->is_course_complete($USER->id) && !has_capability('mod/certificate:manage', $context)) { + notice(get_string('completionrequired','certificate'), "$CFG->wwwroot/course/view.php?id=$course->id"); + die; +} + // Create new certificate record, or return existing record $certrecord = certificate_get_issue($course, $USER, $certificate, $cm);