Teacher caught doing sex and punished