All principals and teachers in the public schools shall have the right to exercise the same authority, as to conduct, and behavior, over pupils attending their schools during the time they are in attendance, including the time required in going to and from their homes, as parents, guardians or persons in parental relations to such pupils.