apps.utils.groups_groupedby_relatedstudent_and_assignment: Optimize queries.