If you set the roles of teacher/student specific to a class rather than for the whole site, and set the enrollment for each course so that users cannot self-enrol (or need an enrolment key to do so) then that should do what you need. The users are then simply authenticated users on the site, and have their student/teacher roles only for the classes they are in and cannot access the others.
Richard
Many thanks for your answer.
But this didn't fit exactly my need, because :
If two user of one school are enrolled in course 1.
And two other of another school are enrolled in same course.
Both will be visible from other since they are in same course ... true (nevermind which roles they have / how they are enrolled, if they need to see course's student) ?
OK - to clarify:
You have 2 schools with 2 classes in each and 10 users per class and you want the teachers to only be able to open their own class.
But you also want multiple teachers in the same course to only see their own students in their class and multiple classes are using the same course?
My apologies - I assumed you were using 'class' as an alternative term for 'course'.
I'm sorry I don't know of a solution to provide that level of granular control - you can of course group the students and let them only see the activities and resources for that group, but I'm not sure whether you can restrict the teacher access through groups in that way, as 'teachers' would normally be given full control of the course they are teaching on.
Perhaps if you create a new role - based on the student role and then go through and give that role the additional rights it would need: but then I'm not sure if that would cause it to be opened up and be able to see the other students then anyway.
The other solution is to duplicate the courses and have separate ones for each class/school so that you can use the solution I originally posted.
Richard
I agree that having separate "courses" seems like the easiest solution. If you want to have teachers only see their own students you can modify the teacher permissions or clone the teacher role and modify the following permission:
Access all groups
The gradebook view unfortunately still allows teachers to see all students (I think).
Thanks all for your fast answers !
Access all groups seem a good idea
Thanks