Ex-teacher sentenced to prison for sexual relationship with student