I have a few clients in the academic space using Moodle. At the end of each year they reset their courses in preparation for the new academic year. This reset includes removing all student data from the course using Moodle’s Reset course function.
The question I was asked, was how could they remove the students from the course, yet allow the students to see their grades.
If you unenrol a user from a course, they can no longer see their grades, and the teacher cannot pull a report containing these students and their grades.
I did a little digging and come across a few handy doc’s on the Moodle site. You can read the Moodle doc’s relating to this here:
Rather than reinvent the wheel, I looked around for something similar that would suit their needs, but did not find anything. So, to help my clients out, I build a small block that pulls in all the grades for a user – enrolled or otherwise.
I based the block on the simple HTML block already in Moodle and added in a query and a table to show the results. A small legend at the bottom of the block shows whether the student is still enrolled in the course or not.
The key to this block and the data it pulls lies in the mdl_grade_grades_history table. This table holds a record of all the grades, even if the user has been unenrolled from a course.
The image below shows the results of the query I wrote to pull data from both the grade_grades and grade_grades_history tables.
If the estatus (enrolled status) is a 0, the user is still enrolled in the course. The blank (NULL) value indicated that the user has been unenrolled from that particular course.
When viewing the results in the block, it looks as below.