Let him go. Be cordial when you see him. Think about how his girlfriend must feel, or would feel if she found out about you. She’d probably think he was a pig (with good reason), but might take him back, but she would think that you are a slut (with good reason). I am not saying that you are a slut, but that is what his girlfriend and a lof of other people will think.
Find your own guy. Figure out now that there is really no such thing as “friends with benefits.” What that term really means is that some douchey dude gets to have sex with you (and not give one single damn about you) while at the same time maintaining a “real” relationship with some other woman who does matter to him (for what reason you will never know) and probably carry on a FWB relationship with a few other women at the same time.
Decide what you want in life, in a mate. If you want casual sex, then be very up front with people about that, but don’t get into situations where you or the dude have to cheat on someone else (an innocent third party) to get what you want. That’s really mean and disrespectful, no matter what you might think about the third party.
And don’t ever think that a guy who tells you that he wants FWB with you will ever, ever, ever change his mind about that. That is very naive wishful thinking, even if you hear of some anecdotes about the dude changing his mind and falling madly in love with you. That is so rare, that you’d be more likely to win the lottery.
And it doesn’t matter how hard it is for you to see him in a class. You should have thought of that before you got yourself into this mess. Sorry, that’s just the way it is. Just be cordial and move on.