M.C.
Sorry for responding late but I just signed up and I'm reading through all inquiries.
When my brother was in elementary (don't remember exact age) he would poop on himself at school. My mom took him to the dr. The dr. asked they speak alone together. After he met with my brother he told my mom that he needs more attention from my dad (who was working too much). My dad starting taking him fishing and do more with him and the pooping stopped.
So, in most cases kids do this for more attention. Especially if they feel their dad is leaving.
My nephew also pooped on himself while at school. He was an only child and his parents were going through a divorce. The dr. told the parents since their son feels he has no control over their divore, the only thing he can control is his pooping.
I hope it has all worked out.