Need to restore deleted quiz grades

Need to restore deleted quiz grades

by Charlie Drolshagen -
Number of replies: 0

So in troubleshooting another problem (and trying to be quick in order to allow the user to accomplish what they needed) and without fully considering the ramifications, I deleted all attempts for two quizzes.  Being somewhat familiar with MySQL, I dove into the database to find the old attempts after reading this post.

With a little bit of orientation, I found the mdl_grade_grades and mdl_grade_grades_history tables, as well as the id from mdl_grade_items that corresponded to the quizzes that contained the attempts I had deleted.  Using these and my userid I was able to run the following query to find the old quiz results:

select * from mdl_grade_grades_history ggh where ggh.itemid='2849' and ggh.loggeduser='1833' ;

From there I ran an UPDATE query to restore the results in the mdl_grade_grades_history table to the mdl_grade_grades table:

UPDATE mdl_grade_grades gg, mdl_grade_grades_history ggh
SET gg.rawgrade=ggh.rawgrade, gg.finalgrade=ggh.finalgrade, gg.timecreated=ggh.timemodified, gg.timemodified=ggh.timemodified WHERE gg.id=ggh.oldid AND ggh.itemid='2849' AND ggh.action='1';

I added the ggh.action='1' as that was the only entry in the history table that contained actual grade results.  This was successful and I got all of the entries back into the mdl_grade_grades table, but the restored entries don't appear on the website when I go to the quiz results page and get a report.

Is there a step I'm missing here?

Running Moodle 2.3.3 on CentOS 5.7 with Apache 2.0, MySQL 5.1.63, and PHP 5.3.15.


Thanks!