It would be as easy to restore the course from backup if you have one.
Unfortunately when you delete a course, all data including grades, is deleted too. However, as Emma mentions, if you have a course or site backup from before the course was deleted, you can obtain the grades from it.
Hmm. I thought the data was still in the database, but marked as deleted?
Grade history is kept but it requires the course related records to exist in order to retrieve the grades for a report, otherwise you'd need to build your own report that works without requiring course data. Restoring the course would make grade retrieval possible in Moodle again, But yes, you are correct, the grade history is kept. The details of how this works can be found in the unit /lib/gradelib.php. Look for the function remove_course_grades($courseid, $showfeedback). This function is called from the function remove_course_contents($courseid, $showfeedback = true, array $options = null) found in the unit /lib/moodlelib.php and that function is called from the function delete_course($courseorid, $showfeedback = true) also found in the same unit /lib/moodlelib.php.
Unfortunately, we don't save student data when we archive courses. Not my decision, but that's the policy.
I guess you could try restoring and reenrolling students and see if grades show up. I, like you, actually thought they were still in the database somewhere...It always seems to me that Moodle never really deletes anything...expect plugins maybe! I will defer however to Helen as the expert!
You can retrieve grades yes, but in the instance of a quiz with multiple attempts you will find all attempts in the history and no correlating record summarizing the scores into one final score. That record is gone when you delete the course. The best way to get this grade information again in a manner you can retrieve would be to restore the original course. That will restore the final grade assessments in the cases of multiple scores per item.
My recommendation:
- Make sure you have the site setting for restoring grades for re-enrollments set to yes (default is no, beats me)
- Restore the course without students
- Physically change the course id in the course table back to the original
- re-enroll the students
My recommendation:
- Make sure you have the site setting for restoring grades for re-enrollments set to yes (default is no, beats me)
- Restore the course without students
- Physically change the course id in the course table back to the original
- re-enroll the students
If you have an SQL guru around, you may be able to get the information you want.
The table mdl_grades_items_history has the list of all historical grade items - if you know the old course id you can get a report on what grade items are stored in history. (One for overall and one for each module)
You then take that information and look in the mdl_grades_grades_history table - this will have the student grades for each of the grade items.
You may be able to get this put into a nice report with student name, item, grade etc if the SQL skills are up to scratch.
Cheers
Peter