I am using customcert 3.6.3 (2018120303).
I recently upgraded to Moodle 3.6.5+ (Build: 20190718) and, at the
same time, I am phasing out the old certificate plugin in favor of customcert. So, I've been checking Scheduled tasks once a day, just to make sure things are running smoothly.
I noticed today that \mod_customcert\task\email_certificate_task
was failing. Long story short, I found that one person appears to have duplicate certificates (userid and customcertid the same for 2 records; timecreated is also the same; code is unique). That is causing the Scheduled task to fail, and preventing
me/the user from downloading the certificate.
Running it manually, I got an error message like this:Scheduled task failed: Handles emailing certificates. (mod_customcert\task\email_certificate_task),Multiple records found, only one
record expected.
Debug info:
SELECT * FROM {customcert_issues} WHERE userid = ? AND customcertid = ?
[array (
0 => '12345',
1 => '5',
)]
(note: userid number has been changed.)
Indeed, in customcert_issues,
I see two records for that user, with the exact same timestamp. There are no other records with duplicate userid and customcertid values.
When I download the CSV from the plugin, I only see one record for the person with the matching email
address. I cannot tell which "issue" record it thinks it is reporting, since it does not reference the code or issue id number. When I try to download the certificate for that person, I get the same kind of error as above.
When I hover my
mouse over the delete button, it does mention an actual customcert_issues id number - the one with the higher id number.
There do not appear to be an abnormal number of grade_grades, grade_history, or quiz_attempts records for this person.
Do
you think this is just some odd hiccup from my server or something? Or a bug, which I could possibly help more with identifying?
And to resolve it, do you have any suggestions? In the plugin interface, I do see there is a "delete" button. For the sake of diagnosing the problem, I am tempted to leave it alone. But, it is also causing any other new issues (for other users) to fail emailing the certificate.
To put it another way: I understand what is causing the Scheduled task and so on to fail (there are duplicate records). I do not understand how the duplicate records were created in the first place. I think I can solve the immediate problem (delete the bad certificate using the plugin), but I am always curious to figure out why things happen.
Anyway, thanks for this great plugin! I'll update with any other information or actions I take.
- Ray