'Create and return a new sample course. See CourseFactory for customization kwargs.'

@classmethod
def _create(cls, target_class, **kwargs):

    block_info_tree = kwargs.pop('block_info_tree', default_block_info_tree)
    store = kwargs.get('modulestore')
    user_id = kwargs.get('user_id', ModuleStoreEnum.UserID.test)
    with store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, None):
        course = super(SampleCourseFactory, cls)._create(target_class, **kwargs)
        def create_sub_tree(parent_loc, block_info):
            'Recursively    creates    a    sub_tree    on    this    parent_loc    with    this    block.'
            block = store.create_child(user_id, parent_loc, block_info.category, block_id=block_info.block_id, fields=block_info.fields)
            for tree in block_info.sub_tree:
                create_sub_tree(block.location, tree)
        for tree in block_info_tree:
            create_sub_tree(course.location, tree)
        store.publish(course.location, user_id)
    return course
