One time in that class I decided to do my history homework
Why did you get in trouble for that?
I was doing my homework for another class.
Oh, I see, you were doing homework for a different class. I can see that your teacher wouldn't like that. It's good to concentrate on the class that you're attending while you're there.
I was just trying to have fun.
I understand that.  However, education is really important and it would benefit you to take it a bit more seriously.  I think that's what the teacher was trying to help you with.