A Chicago teacher and her young students were shocked last week when they reportedly saw an 18-year-old man molesting a 7-year-old girl as the class participated in an online learning session, according to reports.

The teacher alerted the school’s principal and the man -- who was identified as the child’s older cousin -- was soon arrested, Chicago’s FOX 32 reported.

Authorities said the suspect, Catrell Walls, a resident of the city’s South Side, faces a felony charge of predatory criminal sexual assault in connection with the Thursday incident, the station reported. A judge denied bail for Walls when he appeared in court Saturday, the report said.

“I don’t know why. I’m sorry, I’m sorry,” a tearful Walls told prosecutors after he was taken into custody.

The suspect, a high school senior, has trouble controlling his impulses because he suffers from attention deficit hyperactivity disorder (ADHD), his defense attorney said, according to FOX 32.

WISCONSIN SCHOOL WORKER IS JAILED FOR EXPOSING HERSELF TO STUDENT

The alleged sex crime reportedly happened in the home of the cousins’ grandmother, where the girl had been staying during the day for online classes. After the teacher alerted the school’s principal, the principal contacted the girl’s family, Chicago police and the Illinois Department of Children and Family Services.

During a visit to the child to get more information about what happened, the girl reportedly told the school principal that Walls had molested her other times as well, the report said. That alleged history factored into the judge’s no-bail decision regarding Walls.

Catrell Walls, 18, faces a felony charge of predatory criminal sexual assault, authorities say. (Chicago Police)

Catrell Walls, 18, faces a felony charge of predatory criminal sexual assault, authorities say. (Chicago Police)

“This ongoing history of assault, for approximately a year, according to the victim, leads me to believe this is not something that will just stop because I have ordered it to,” Judge Charles Beach said. “This history and his actions from this case lead me to believe that he is a threat to an individual and the community as a whole.”

CLICK HERE TO GET THE FOX NEWS APP

The child was taken to Comer Children’s Hospital, police said, according to the Chicago Tribune.

In recent years Chicago Public Schools has increased its support for students who are victims of sexual assault or other harm because teachers and counselors are often the first to spot a problem, schools CEO Janice Jackson told the Tribune.

Walls’ next court date is Nov. 21, according to FOX 32.