MDL-46527 grades: grade_get_grades external function rewritten