Hello,
Normally a teacher can see and change the grades for users in all groups. To prevent this, you need to edit the teacher role and unset the capability to access all groups. Alternatively, you could assign your teacher the role of non-editing teacher, where the capability is not set.