I don't see anything illegal about what the teacher did. It does not seem like they were doing so with an impermissible purpose based on the facts provided.
This is not legal advice nor does it create an attorney-client relationship. This is for education and informational purposes only. It is always recommended that you contact an attorney with any concerns as each individual case is unique.