If he is getting constipated, it's not from avoiding pooping at school. I have a 7 yr old son who has similar issues.
Part of his problem at school may be the time it takes for him to go, or it might be a problem with getting clean enough. Increasing his fiber intake will help with both of those issues. Lots of foods are high in fiber - whole grain reads and cereals, pears, lima beans, etc. You can find a comprehensive list online by searching for "high fiber foods". I also give my son a chewable fiber tablet (cant remember brand name, but will check when I get home in case you are interested). They have an orangy flavor and my son loves them - treats them practically like candy.
Fiber will make his bowel movements a little looser - so it wont take as long to go and there wont be an issue with sticky residue.
If his issue is the public bathroom, then you may want him to speak with the school counselor or take him privately to one. This can become a life-long issue and does affect adult life so changing his mindset while he is young is important.
I let my sons teachers know about my son's recluctance to go to the bathroom at school. We keep a few wipes in his backpack just in case and the teacher knows that he sometimes needs a few extra minutes in the bathroom after the other kids have left it. (They go as a class).
good luck with however you end up handling this issue.