====== Grades ====== An overview of all relevant tables: {{:moodle:grades.png?|}} Please note: ''course_modules.instance = grade_items.iteminstance''. ====== Acquiring a grade by course_module.id ====== The id in the URL of a course module is the course_module.id. This can be used to acquire a grade for a specific user. The following query is an example. All you need is the course_module id and the student's user id. SELECT * FROM mdl_grade_grades WHERE userid = //copy the student id here// AND itemid IN ( SELECT id FROM mdl_grade_items WHERE iteminstance IN ( SELECT instance FROM mdl_course_modules WHERE id = //copy the course module's id here// ) ) In other words: the mdl_grade_items.iteminstance column does **not** refer to the mdl_course_modules.id column, but to the instance id instead.