A married maths teacher has been given a 14-month jail term, suspended for two years, after being caught hiding under a teenage girl's bed by her mum.
Andrew Welsh, 36, was also placed on the sex offenders' register for having sex with a 16-year-old girl.
Bolton Crown Court heard Welsh was discovered when the the girl's mother returned home unexpectedly one morning last July.
Geoff Whelan, prosecuting, told the jury the girl had ruffled hair and smudged lipstick.
When the mother went upstairs, she noticed a pair of men's boots at the side of the girl's bed, he added.
This 'understandably aroused suspicion' in the mother, who asked the girl: "What are you doing? Who is here?"
Mr Whelan continued: "However, as that was said, she looked down and saw movement in the drawer compartment within the girl's single divan bed and the valance sheet folded back.
"She saw movement of material which seemed to match the suit jacket her daughter was holding.
"The girl replied 'Mr Welsh'.
"Her mother ordered the defendant to get out from under the bed and recognised him from the school."
The shocked mother called her husband and the police and Welsh was arrested.
The court heard Welsh, from Atherton, near Wigan, had begun a relationship with the 'impressionable' girl last summer while she was taking her GCSEs.
He bombarded the girl with obscene texts, including: "Have you heard about my maths lesson? We're going to find out if 35 goes into 16."
Welsh, who is married to a local doctor, tried to have the charges dismissed after telling police the girl was 16, the sex was consensual and all sexual activity took place after she had left school.
However, the judge ruled at an earlier hearing charges against the father-of-one should stand as Welsh had been in a position of trust.
The defendant then pleaded guilty to six counts of sexual activity with a child while in a position of trust.
Passing sentence, Judge Knopf told Welsh: "You were nearly 20 years older than this girl.
"It is you who has to bear the responsibility for what happened. She was attracted to you, you should have exercised the judgment which you clearly lacked when you decided to embark on this relationship with her."
Welsh was ordered to sign the sex offenders' register for 10 years.