That said, I wanted to make the error messages on the certificate/view.php page more descriptive, so that the user would know how many minutes were required to be spent in the course as well as how many minutes they had spent already.
I'll post what I did to accomplish this below, but if there is a better way to distribute this, please let me know. I have never used CVS or anything of that sort (my coding has all been on smaller, individual projects) but I am willing to learn.
In the file certificate/lib.php
Changed function certificate_grade_condition() at line 1367 to:
/************************************************************************
* Grade/Lock functions-functions for conditionally locking certificate.*
* Mike Churchward *
************************************************************************/
function certificate_grade_condition() {
global $certificate, $course;
$restrict_errors = '';
if ($linked_acts = certificate_get_linked_activities($certificate->id)) {
$time = certificate_is_available_get_time($linked_acts, $course->id);
$a->current = $time[0];
$a->needed = $time[1];
if ($a->current < $a->needed) {
$restrict_errors[] = get_string('errorlocktime', 'certificate',$a);
}
if (!certificate_is_available_mod($linked_acts, $course->id)) {
$restrict_errors[] = get_string('errorlockmod', 'certificate');
}
}
if ($certificate->lockgrade == 1) {
$coursegrade = certificate_print_course_grade($course);
if ($certificate->requiredgrade > $coursegrade->points) {
$a->current = $coursegrade->points;
$a->needed = $certificate->requiredgrade;
$restrict_errors[] = get_string('errorlockgradecourse', 'certificate', $a);
}
}
return $restrict_errors;
}
Added function certificate_is_available_get_time() at line 1611:
function certificate_is_available_get_time($linked_acts, $courseid, $userid=0) {
global $USER;
if (!$userid) {
$userid = $USER->id;
}
$time = array();
require_once('timinglib.php');
$tlcoursetime = tl_get_course_time($courseid, $userid);
foreach ($linked_acts as $key => $activity) {
if ($activity->linkid == CERTCOURSETIMEID) {
if (($activity->linkgrade != 0) &&
(($tlcoursetime/60) < $activity->linkgrade)) {
$time[0] = intval($tlcoursetime/60);
$time[1] = $activity->linkgrade;
} else {
$time[0] = -1;
$time[1] = -1;
}
}
}
return $time;
}
In the file certificate/lang/[en_utf8]/certificate.php
Changed line 102:
$string['errorlocktime'] = 'Your current time in the course ($a->current minutes) is less than the time required ($a->needed minutes) to receive your certificate.';