This sounds like a complicated web of objects!
I already wrote a much more elegant response to this post, but the page expired and deleted my response before I could submit it :(
It sounds like you need a GroupMajors object which represents the relationship between Groups and Majors, since the Marks sound like they need to be associated with both at the same time. Since a GroupMajors instance would have one Group and one Major, and each Group has only one Class, you could define a relationship between GroupMajors and your new Marks class, and then you have that link between Marks and Classes, which I assume is the intended result. Then after creating those two classes, I'd probably spend some time creating those accessor functions that make it easier to traverse the complex relationships so you can call $student->classes() instead of needing to fetch groups in every call then fetch the Classes for those Groups... and also something like $student->getClass(~class_id~)->marks() would be much more logically cleaner than fetching the group for a student, fetching the classes for each of those groups, and then throwing majors into the mix...
Or would it be more appropriate to say that each Class has one or many Majors, and a Group could be a collection of those ClassMajors relationships? (i.e. a Group has one or many ClassMajors, and a ClassMajor belongs to one Class and a ClassMajor belongs to one Major) That way if an instructor wanted to analyze data pertaining to all "Marks for all Chemistry Majors in Course X" they could analyze that more cleanly and the Group object could be more of an abstract concept rather than a contingent one if that makes sense...
Not saying that by responding to your post that I completely understand what you're going for here... I hope I was close, or at least sparked some ideas!