'Returns the Group from the specified user partition to which the user
is assigned, via enrollment mode. If a user is in a Credit mode, the Verified or
Professional mode for the course is returned instead.
If a course is using the Verified Track Cohorting pilot feature, this method
returns None regardless of the user\'s enrollment mode.'

@classmethod
def get_group_for_user(cls, course_key, user, user_partition, **kwargs):

    if is_course_using_cohort_instead(course_key):
        return None
    if (get_course_masquerade(user, course_key) and (not is_masquerading_as_specific_student(user, course_key))):
        return get_masquerading_user_group(course_key, user, user_partition)
    (mode_slug, is_active) = CourseEnrollment.enrollment_mode_for_user(user, course_key)
    if (mode_slug and is_active):
        course_mode = CourseMode.mode_for_course(course_key, mode_slug, modes=CourseMode.modes_for_course(course_key, include_expired=True, only_selectable=False))
        if (course_mode and CourseMode.is_credit_mode(course_mode)):
            course_mode = CourseMode.verified_mode_for_course(course_key)
        if (not course_mode):
            course_mode = CourseMode.DEFAULT_MODE
        return Group(ENROLLMENT_GROUP_IDS[course_mode.slug], unicode(course_mode.name))
    else:
        return None
