Dear Mr Andreev,
We are encountering the same issue.
We do not want to prevent teachers from accessing groups all over the site. We want to set it only in the context of attendance module. In the permissions for attendance module, we do not find a way to override permission of teachers for accessallgroups.
How do we get around this issue?