Many small children do not like asking to use the bathroom when they are at school, it could be she needs reminding, and has got into a habit of not going, it may be upsetting her, speak to the teacher and find out if they remind some children to use the bathroom. It could be having a knock on affect at home, I suggest more supervision at home so she isnt able to do it in corners in my opinion punishments do not work for this kind of thing it only creates an anxiety about going and feeds upon itself. Take a step back, lessen the emphasis about it ,be aware and around her .Good luck