Have you tried allowing the capability moodle/user:viewdetails for the role of teacher and not setting it for the student role?
Currently it is set to allow for teachers and prohibit for students - maybe that is the problem? If some teachers are in other courses as students, is the student prohibit overriding the teacher allowsitewide? I don't want to change it to anything else until you can assure me the students won't be able to see each others' profiles. Thankyou for your help.
Well I tried it out late at night while nobody was around, and non set for students and keeping allow for teachers did the trick, so thankyou Helen.