They were outside the class as there was a fire alarm going off. Which we now know was a diversion Cruz used to get the students out so he could begin shooting. The fact is we may never know if the teacher was a coward or a hero.
Could he have let more students in? Possibly. Could he have opened the door to Cruz himself? Also possibly.