There are several roads to take; harden schools with real STEEL security doors, install security drop isolation doors in hallways to curtail further access (no different than fire doors), manned security video to have vigilance before an assault, this person would have have been seen prior to entry on video, armed RSO tied to functional security plan. Test the response plan with administration, teachers and students at least twice a year.
Reality is evil cannot be 100% defeated but it can be made more difficult.