I've got an almost full-proof plan, if folks would pay for it.
1.) Reduce points of entry/exit...ensure the rest of the perimeter is a) hard to breach, and b) would trigger an alarm if breached
2.) At these points of entry/exit, specialized metal detectors built into the entryway, that will do specific actions if a degree of metal is detected: a) lock down the school (all classrooms, hallways, etc. electro-locked), b) sound a specialized alarm for a shooter incident, c) notify local police, SWAT, and the school resource officer
3.) ALWAYS have an armed school resource officer on the campus (with a biometric trigger (so kids can't get his gun and use it)).
4.) Ensure the students are well-versed in school policy about the detectors, consequences, etc.
5.) Ensure the students and staff know EXACTLY what to do in this scenario.
6.) Finally, ANY armed personnel other than police, in the school, should have a biometric trigger