コード例 #1
0
    def definition_for_usage(self, usage_key):
        """
        Given a usage key for an XBlock in this context, return the
        BundleDefinitionLocator which specifies the actual XBlock definition
        (as a path to an OLX in a specific blockstore bundle).

        Must return a BundleDefinitionLocator if the XBlock exists in this
        context, or None otherwise.
        """
        library_key = usage_key.context_key
        try:
            bundle_uuid = bundle_uuid_for_library_key(library_key)
        except ContentLibrary.DoesNotExist:
            return None
        bundle = LibraryBundle(library_key, bundle_uuid, self.use_draft)
        return bundle.definition_for_usage(usage_key)
コード例 #2
0
    def definition_for_usage(self, usage_key, **kwargs):
        """
        Given a usage key for an XBlock in this context, return the
        BundleDefinitionLocator which specifies the actual XBlock definition
        (as a path to an OLX in a specific blockstore bundle).

        Must return a BundleDefinitionLocator if the XBlock exists in this
        context, or None otherwise.
        """
        library_key = usage_key.context_key
        try:
            bundle_uuid = bundle_uuid_for_library_key(library_key)
        except ContentLibrary.DoesNotExist:
            return None
        if 'force_draft' in kwargs:  # lint-amnesty, pylint: disable=consider-using-get
            use_draft = kwargs['force_draft']
        else:
            use_draft = self.use_draft
        bundle = LibraryBundle(library_key, bundle_uuid, use_draft)
        return bundle.definition_for_usage(usage_key)