I thought after benefiting MUCH from using the certificate module, I thought I would contribute to the forum with my little "hack".
I've noticed a few questions being asked on the forum "How can I change the date on the certificate to display the date the quiz was completed"....my thought was to try it myself, as I have a bit of coding experience.
To do this, I first "commented" the following line in my certificate.php:
cert_printtext(45, 460, 'C', 'Helvetica', '', 14, utf8_decode($certificatedate));
// cert_printtext(45, 460, 'C', 'Helvetica', '', 14, utf8_decode($certificatedate));
This is to stop the default date from appearing in the certificate
Directly underneath this line, I added the following 3 lines:
$sqlcmd = "SELECT FROM_UNIXTIME(mdl_quiz_attempts.timefinish + 86400, 'Module completed this %D day of %M, %Y ') AS quizfinish, mdl_quiz.course AS courseid FROM mdl_quiz_attempts INNER JOIN mdl_quiz ON mdl_quiz.id = mdl_quiz_attempts.quiz INNER JOIN mdl_certificate_issues ON mdl_certificate_issues.userid = mdl_quiz_attempts.userid INNER JOIN mdl_certificate ON mdl_certificate.id = mdl_certificate_issues.certificateid AND mdl_quiz.course = mdl_certificate.course WHERE mdl_certificate_issues.id = !!!CERTID!!!";
$sqlcmd = str_replace('!!!CERTID!!!', $certrecord->id, $sqlcmd);
$retval = get_record_sql($sqlcmd);
Let me explain.
1. The first line is a SQL call/command to the moodle database. You will notice I hardcoded our prefix into the statement (the "mdl_") part. Yours may be different, so you will need to use a $CFG->prefix in there. Also the other point to note out is the 86400 number near the start. Because all of the times in moodle are stored in unixtime (the number of seconds since 1/1/1970 GMT), I need to convert it to our timezone (Perth, Australia). You will need to work out your own timezone here, or else your dates will be one day off sometimes.
2. The second line replaces the key !!!CERTID!!! in the statement. I used a str_replace function because it is easier to read and debug, rather then tacking it on to the end of the SQL statement.
3. The final line gets the data from the database, and stores it in a variable called $retval.
finally we display the date using this function:
cert_printtext(170, 430, 'C', 'Times', '', 20, utf8_decode($retval->quizfinish));
ALSO one final note, if you want to change the format of the time stamp, edit this section of the code:
SELECT FROM_UNIXTIME(mdl_quiz_attempts.timefinish + 86400, 'Module completed this %D day of %M, %Y ')
The text in the quotes is the FORMAT STRING, you can learn how to manipulate it here:
Hope this helps and makes sense
If you have any further questions, post them here, and I will help the best I can