My guess as to how this movie was written
Someone had been misunderstood in a ridiculous situation that got ridiculously blown up and misunderstood, he is sentenced to anger management, even though he doesn't have anger problems, but he gets angry while actually taking the course, because he gets fed all kind of *beep* gets his privacy invaded by his anger management guy, gets grouped in with actual insanely aggressive douchebags, and everything he does is interpreted out of context, etc.
Then he makes a movie script out of it, and how ridiculous it is. The script is a little exaggerated, but still close to his (and probably many others') actual experience. The production company says "This is pretty funny, we'll use most of it, but we need to have a happy ending, where he finds out that everything had a purpose" or something. :p