If you take care of them, they will last a while. I have never tried to keep them more than about 3 weeks. But I have had very few ever die either. I use oats and bran, then add whatever veggie scraps to them. If you have nothing else, you can just put a few pieces of potato in there for moisture. It would also depend on the age you started with them. You can get them small, about the size of a mealworm. And let them grow. It is hard to find them for sale at that size in some places though. Most of the ones I have gotten are 2+ inches long, so they are close to pupation. Keeping them together in groups hinders the pupation, and I am actually not sure how long this stasis can go on for. So I normally try to feed them out.
Were the ones you have large when they got to the school?