3 y/o poops in undies at school

My daughter, 3 years 2 months has been pee-potty trained for 6+ months. Absolutely no pee accidents. At home, she poops on the potty UNLESS she is sleeping. However, she has never pooped on the potty at school. She either waits until she gets home or poops in her undies at school. I’m talking a 1-2x a week occurrence where she’s having accidents. When we talk to her and ask “if you need to go poop at school, what do you do?” And she always says “Stop playing, tell my teacher and go poop on the potty. No poop in undies.” So she knows what she’s supposed to do, I know she knows what it feels like to have to poop so WHY does she keep having these accidents at school? We’ve offered treats/rewards, we’ve sent a potty chart to school, I’ve let her put together a prize basket where she knows she’ll get something if she poops on the potty. They moved her to the preschool class last month because they think she’s intellectually ready, but I’m so worried they’re going to move her back down. She has been thriving in the new environment.

I would also like to add that in her old class, she refused to nap and got bit multiple times. Once in the line to go potty. Her new class, she napped immediately and has connected with the teachers so well.