Warning: I'm sympathizing with your situation, and especially with your sons. The words that came to me may be a little blunt, but I mean only the best for you.
To me, the answer is really simple: You TWO, as parents, need to get your boys into therapy to deal with their emotional issues. Grades are symptoms, not problems. Sometimes the opposite happens: Children will get perfect grades when they are emotionally unhealthy. A "deal" where you have to keep the boys' grades up is totally unreasonable. I can't ever imagine a judge's order being so ignorant and superficial. If the ex made this provision as a condition for his own agreement, I wish he would wake up and read some books, at the very least. But I wouldn't expect much more of a man who's willing to get into a "physical altercation" with a child. If I had to guess, it's the discord between their parents that is causing the majority of the stress on the boys. And their father seems to act like a child and carry anger that he apparently expresses through them. That's too much burden for any child to carry.
edit: Also, after rereading your post, I too read that your "condition" for the boys to live with you is for them to get good grades. Could it be, also, that they are testing the conditions of your love? "Good grades" is usually for the parents, for their own "proof" that everything's o.k. It's no benchmark for emotional/physical health - which should be the top priority. It sounds like neither parent wants to own these boys' problems; they get passed off when they're "naughty." A child will provoke us to show them the TRUTH, whether it hurts or not. This living arrangement could be interpreted in a child's mind: "Pretend that everything is o.k., or I'll abandon you." I would really reevaluate how important grades and "control" are, in the scheme of things. "Controlling (instead of helping)" kids is a recipe for rebellion and their own self-defeat. No judgment from me; it's always easier to see when you're on the outside looking in.
Great links:
http://www.awareparenting.com/drugfreekids.htm
http://www.amazon.com/Parent-Effectiveness-Training-Respo...