The boy, who cannot be named for legal reasons, locked the teacher into a computer room, before putting his hands up her skirt.
Colleagues were alerted by the teacher’s screams, and managed to break the door down and pull her to safely, whilst the boy- now 15- merely laughed.
Speaking in Mold Crown Court, Prosecutor Karl Scholz said:
‘The teacher and the boy were in the classroom when he closed the door and snapped the latch shut.
'He told her he had things on his mind and took hold of her and hugged her.
'She managed to get away and wanted to leave the room but realised the door was locked.
'The schoolboy then put his hand up the teacher’s skirt and carried out a serious sexual assault on her.'
Sholz described how staff outside could hear the teacher’s screams and the boy laughing, and when they managed to free her she emerged with a ‘terrified’ expression.
She has not returned to the school in North Wales since.
The schoolboy already had two previous convictions for sexual assault, and has now been placed on the sex offender’s register for life.
Defence attorney Stephen Edwards said the teenager had suffered a difficult childhood and been the victim of sexual abuse himself.
Sentencing him to four years in youth detention, judge Greg Bull QC said:
'You attacked one of your teachers, barricaded her into the computer room and forced yourself on her.
'It was a terrifying experience for a woman who was only there to try and help you.'