For registered_ex, auditing_ex and dropped_ex, you probably want to define these queries as scopes in student_exercises. Perhaps there is a better way, but I imagine the following:

```rb
scope :for_students, lambda { |students| joins(:student_assignment)
                                                                  .where(student_assignment: {student_id: students}) }
```