'Returns a dictionary that stores the total enrollment count for a course, as well as the
enrollment count for each individual mode.'

def enrollment_counts(self, course_id):

    query = use_read_replica_if_available(super(CourseEnrollmentManager, self).get_queryset().filter(course_id=course_id, is_active=True).values('mode').order_by().annotate(Count('mode')))
    total = 0
    enroll_dict = defaultdict(int)
    for item in query:
        enroll_dict[item['mode']] = item['mode__count']
        total += item['mode__count']
    enroll_dict['total'] = total
    return enroll_dict
