'This method is to be used when the library that a LibraryContentModule
references has been updated. It will re-fetch all matching blocks from
the libraries, and copy them as children of dest_block. The children
will be given new block_ids, but the definition ID used should be the
exact same definition ID used in the library.
This method will update dest_block\'s \'source_library_version\' field to
store the version number of the libraries used, so we easily determine
if dest_block is up to date or not.'

def update_children(self, dest_block, user_id, user_perms=None, version=None):

    if (user_perms and (not user_perms.can_write(dest_block.location.course_key))):
        raise PermissionDenied()
    if (not dest_block.source_library_id):
        dest_block.source_library_version = ''
        return
    source_blocks = []
    library_key = dest_block.source_library_key
    if version:
        library_key = library_key.replace(branch=ModuleStoreEnum.BranchName.library, version_guid=version)
    library = self._get_library(library_key)
    if (library is None):
        raise ValueError('Requested    library    not    found.')
    if (user_perms and (not user_perms.can_read(library_key))):
        raise PermissionDenied()
    filter_children = (dest_block.capa_type != ANY_CAPA_TYPE_VALUE)
    if filter_children:
        source_blocks.extend(self._problem_type_filter(library, dest_block.capa_type))
    else:
        source_blocks.extend(library.children)
    with self.store.bulk_operations(dest_block.location.course_key):
        dest_block.source_library_version = unicode(library.location.library_key.version_guid)
        self.store.update_item(dest_block, user_id)
        head_validation = (not version)
        dest_block.children = self.store.copy_from_template(source_blocks, dest_block.location, user_id, head_validation=head_validation)
