Showing grades for unenrolled users

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.

Moodle course reset options

Moodle course reset options

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:
https://docs.moodle.org/28/en/Enrolment_FAQ#What_is_the_difference_between_unenrolled_and_suspended.3F
and here:
https://docs.moodle.org/28/en/Unenrolment

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.

Raw data from the SQL query

Raw data from the SQL query

When viewing the results in the block, it looks as below.

Block in Moodle showing all the grades

Block in Moodle showing all the grades

0 thoughts on “Showing grades for unenrolled users

Leave a Reply

Your email address will not be published. Required fields are marked *