'Return a queryset of User for every user enrolled in the course.  If
`include_inactive` is True, returns both active and inactive enrollees
for the course. Otherwise returns actively enrolled users only.'

def users_enrolled_in(self, course_id, include_inactive=False):

    filter_kwargs = {'courseenrollment__course_id': course_id}
    if (not include_inactive):
        filter_kwargs['courseenrollment__is_active'] = True
    return User.objects.filter(**filter_kwargs)
