Good Day!
I have a problem, when i lock the grades in gradebook, teachers can unlock them, despite that there is no capability for them in define roles.
Earlier in Moodle 1.9, i had the same problem, and to solved it, i opened site/grade/edit/tree/action.php
if (!has_capability('moodle/grade:unlock', $context))
changed
if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:unlock', $context))
In moodle 2 and above, the changes of case 'unlock':
Has blocked moodle/grade:manage , so after that teachers can not make changes of calculation of grades.