def _create(
        cls,
        target_class,
        parent_location,
        category="chapter",
        user_id="test_user",
        block_id=None,
        definition_locator=None,
        force=False,
        continue_version=False,
        **kwargs
    ):
        """
        passes *kwargs* as the new item's field values:

        :param parent_location: (required) the location of the course & possibly parent

        :param category: (defaults to 'chapter')

        :param definition_locator (optional): the DescriptorLocator for the definition this uses or branches
        """
        modulestore = kwargs.pop("modulestore")
        return modulestore.create_item(
            parent_location,
            category,
            user_id,
            definition_locator=definition_locator,
            block_id=block_id,
            force=force,
            continue_version=continue_version,
            fields=kwargs,
        )
예제 #2
0
    def _create(cls,
                target_class,
                parent_location,
                category='chapter',
                user_id='test_user',
                block_id=None,
                definition_locator=None,
                force=False,
                continue_version=False,
                **kwargs):
        """
        passes *kwargs* as the new item's field values:

        :param parent_location: (required) the location of the course & possibly parent

        :param category: (defaults to 'chapter')

        :param definition_locator (optional): the DescriptorLocator for the definition this uses or branches
        """
        modulestore = kwargs.pop('modulestore')
        return modulestore.create_item(parent_location,
                                       category,
                                       user_id,
                                       definition_locator=definition_locator,
                                       block_id=block_id,
                                       force=force,
                                       continue_version=continue_version,
                                       fields=kwargs)
    def _create(cls, target_class, parent_location, category='chapter',
                user_id=ModuleStoreEnum.UserID.test, definition_locator=None, force=False,
                continue_version=False, **kwargs):
        """
        passes *kwargs* as the new item's field values:

        :param parent_location: (required) the location of the course & possibly parent

        :param category: (defaults to 'chapter')

        :param definition_locator (optional): the DescriptorLocator for the definition this uses or branches
        """
        modulestore = kwargs.pop('modulestore')
        if isinstance(parent_location, UsageKey):
            return modulestore.create_child(
                user_id, parent_location, category, defintion_locator=definition_locator,
                force=force, continue_version=continue_version, **kwargs
            )
        else:
            return modulestore.create_item(
                user_id, parent_location, category, defintion_locator=definition_locator,
                force=force, continue_version=continue_version, **kwargs
            )
    def _create(cls, target_class, parent_location, category='chapter',
                user_id=ModuleStoreEnum.UserID.test, definition_locator=None, force=False,
                continue_version=False, **kwargs):
        """
        passes *kwargs* as the new item's field values:

        :param parent_location: (required) the location of the course & possibly parent

        :param category: (defaults to 'chapter')

        :param definition_locator (optional): the DescriptorLocator for the definition this uses or branches
        """
        modulestore = kwargs.pop('modulestore')
        if isinstance(parent_location, UsageKey):
            return modulestore.create_child(
                user_id, parent_location, category, defintion_locator=definition_locator,
                force=force, continue_version=continue_version, **kwargs
            )
        else:
            return modulestore.create_item(
                user_id, parent_location, category, defintion_locator=definition_locator,
                force=force, continue_version=continue_version, **kwargs
            )