There's a problem with the naturalness of the sentence in the first place. You don't usually speak of a "class of students" the way you do a "herd of elephants" or a "flock of seagulls." I would say either simply the "The class" or "The students in the class."
I have no problem with "The class attends... their schoolmates" even though it switches from a singular noun/verb to "their." However, I also know that Americans, more than others, use a singular verb for nouns like "company" or "staff."
I'm not sure this actually helped you, but I hope it didn't make things worse.
[a writer, not a teacher]