'Returns the current group if set, else the first group from the specified user partition.'

def get_group_for_user(self, course_id, user, user_partition, assign=True):

    if self.current_group:
        return self.current_group
    groups = user_partition.groups
    if ((not groups) or (len(groups) == 0)):
        return None
    return groups[0]
