Type: New Feature
Resolution: Not a bug
Affects Version/s: 1.9.4
Fix Version/s: None
Component/s: Module: Certificate
Environment:Windows Server 2003 R2, MSSQL 2005, IIS 6, PHP 5.2.6
When a student completes a quiz and then clicks the certificate link in the course the Certificate module generates the certificate by inserting a new record into the certificate_issues table. This record contains various details about the certificate, including the DATE that the certificate was issued (certdate) and the GRADE that the student obtained (reportgrade). Then, if the certification requirements have been met (required grade, etc.), the PDF library in Moodle creates the certificate and displays it to the student. So far everything is great.
Then the student goes and attempts the quiz again. When this second attempt is submitted the Certificate module adds another record to the grade_grades_history table with old values from the oldid, source, timemodified, itemid, rawgrade, rawgrademax and usermodified columns.
Then it UPDATES the 'grade' and 'timemodified' values of the record in the quiz_grades table.
Then it ADDS a new record to the quiz_attempts table containing the new attempt number, new grade, timestart, timefinish and timemodified values.
Then it UPDATES the questions, sum_grades and grade column values of the original quiz record in the quiz table (the original submission).
The next thing that the Certificate module SHOULD do is UPDATE the record for the original certificate (that was previously issued) on the certificate_issues table (which still contains the original reportgrade and certdate values). But the module DOES NOT do this last update and that is why the grade for the last attempt is not displayed! The module should be updating (or deleting???) the original certificate record on certificate_issues with the date and grade details of the most recent attempt that the student submitted.
Alternatively, the certification date and grade details shouldn't even be stored on this table. Instead, the Certificate module should retrieve the latest grade details from the grade_grades table whenever the user requests the certificate. I think that this is a better solution...
I haven't yet figured out what code needs to be updated to make sure that the above record update is performed, but this is, as far as I can see, the cause of the problem.
Would adding a call to update_record(certificate_issues, $???) somewhere in the \certificate\view.php page be a viable solution? If I read the Xref documentation for Update_record() correctly this would update the record in the certificate_issues table with the most recent grade and date. If so, what would the second parameter for update_record() be?
See discussion in http://moodle.org/mod/forum/discuss.php?d=108397 where other users have reported the same or similar problem.