Backported core_grades_get_grades