An 18-year-old student at Richard Montgomery High School in Rockville was charged with a fourth-degree sex offense after he and a 14-year-old student allegedly had consensual sex in a school hallway in late February.

The girl told police that she and the other student had exchanged messages via Facebook, making plans to skip class and meet in a school hallway near a vending machine, according to police records. The girl described the sex as consensual and said it continued over a period of about 30 minutes. Court documents say the encounter ended when the 18-year-old heard other students in the hallway.

Montgomery County schools spokesman Dana Tofig said staff did not witness the students having sex in the hallway. The school has surveillance cameras in hallways, he said, but “they don’t cover every square inch.”

In response to the incident, Tofig said, “we’ve made improvements that will allow for better surveillance by staff and security.” Among the changes, he said, was installation of a mirror in a first-floor stairwell area.

Tofig would not comment on either student involved. The Washington Post generally does not identify victims of sex assault crimes and is not identifying the older teenager to protect the girl’s identity.

Police charged the 18-year-old with a misdemeanor, as Maryland law prohibits 18-year-olds from having sex with anyone four years younger than they are, even if it is consensual.