Maybe like this?
A user who wants a teacher role chooses this option (a block for this?). The teacher is not yet assigned to any group, so she/he does not see any students (limited by role settings) .Then the user opens a block and sees a list of self registration courses and selects all the courses for which the teacher wants a teacher role and own group. The teacher then creates the group and adds the students, while selecting all the courses to which the group shall be assigned.
MJ