WATSONVILLE >> Tuesday morning on the Pajaro Valley High School public address system, students milling outside during a break heard a surprise announcement.

“This is a code red drill. There is an intruder in the quad,” the voice said.

Instructions followed to go indoors.

Dozens of the school’s 1,400 students were on the quad and talking to each other outside classrooms. They filed into classrooms, the gym and other rooms as teachers and staff locked doors behind them.

In silence outside, about 10 uniformed police from Watsonville and Santa Cruz patrolled the halls as they would during a real shooting. Five minutes later, a voice announced, “All clear.” Classes resumed.

Watsonville police school resource officer Charles Johnson, who had the idea for the drill about a year ago, said he was impressed with the calm way students reacted. He said the drill was prompted by other school shootings around the nation.

Since 26 people were killed in an attack at Sandy Hook Elementary School in Newtown, Connecticut, in 2012, there have been at least 111 shootings at schools and universities in the United States, according to the group Everytown For Gun Safety.

“We figured, we’re not prepared for it. Let’s do our best to get prepared for it,” said Johnson.

He said he wanted to do the drill during a break, while students were all over campus.

Teachers and staff knew the drill was coming, but most students did not. Students in a leadership class also were clued in beforehand, Johnson said, and they helped shepherd students into classrooms.

Christian Fernandez, a 16-year-old junior at the school, said, “It was a good way to practice.”

He was a bit skeptical about whether his classmates would act so orderly if a real shooter were on campus.

“People would be freaking out,” he said.

Alison Niizawa, principal of Pajaro Valley High School, said she was pleased with the way teachers and students handled it.

Keeping an eye out for troubled students is also part of the answer to keeping students, staff and faculty safe, she said.

“It’s too bad that we don’t have enough resources to put into identifying people that are in distress or feeling like this is the only answer,” Niizawa said.

“But you can never be too prepared or plan enough for what would you do.”