You need to go into the course settings, and under Groups > Group Mode, select Separate Groups.
This setting has 3 options:
- No groups - There are no sub groups, everyone is part of one big community
- Separate groups - Each group member can only see their own group, others are invisible
- Visible groups - Each group member works in their own group, but can also see other groups
The group mode defined at course level is the default mode for all activities within the course. Each activity that supports groups can also define its own group mode, though if the group mode is forced at course level, the group mode setting for each activity is ignored.---
Then in Site Administration > Users > Permissions > Define roles, you can tweak your Teacher persmissions (I searched for "all" to make sure teachers didn't see all grades for instance)
Hope this helps!