The teacher "admitted to generating the child sexual assault material of prepubescent children and masturbating to them while at work at which he is a middle school science teacher," prosecutors said.