I now that some cases when people get mad at the dogs, scream or even hit them, they will start to eat their poopoo to hide so their human won't get mad at them

Its sad but some people do act like that instead of showing the right way to do it...If an accidente happen in the wrong place, just clean up and ignore the dog, when they do in the right spot, praise him, play with him and grive treats..they can't resist. I think you should try staying with him untill he finishes doing his business..