openedx.core.djangoapps.xblock.learning_context package#
Submodules#
openedx.core.djangoapps.xblock.learning_context.learning_context module#
A “Learning Context” is a course, a library, a program, or some other collection of content where learning happens.
- class openedx.core.djangoapps.xblock.learning_context.learning_context.LearningContext(**kwargs)#
Bases:
objectAbstract base class for learning context implementations.
A “Learning Context” is a course, a library, a program, or some other collection of content where learning happens.
Additional learning contexts can be implemented as plugins, by subclassing this class and registering in the ‘openedx.learning_context’ entry point.
- can_edit_block(user, usage_key)#
Does the specified usage key exist in its context, and if so, does the specified user have permission to edit it (make changes to the authored data store)?
user: a Django User object (may be an AnonymousUser)
usage_key: the UsageKeyV2 subclass used for this learning context
Must return a boolean.
- can_view_block(user, usage_key)#
Does the specified usage key exist in its context, and if so, does the specified user have permission to view it and interact with it (call handlers, save user state, etc.)?
user: a Django User object (may be an AnonymousUser)
usage_key: the UsageKeyV2 subclass used for this learning context
Must return a boolean.
- definition_for_usage(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).
usage_key: the UsageKeyV2 subclass used for this learning context
kwargs: optional additional parameters unique to the learning context
Must return a BundleDefinitionLocator if the XBlock exists in this context, or None otherwise.
- usage_for_child_include(parent_usage, parent_definition, parsed_include)#
Method that the runtime uses when loading a block’s child, to get the ID of the child. Must return a usage key.
The child is always from an <xblock-include /> element.
parent_usage: the UsageKeyV2 subclass key of the parent
- parent_definition: the BundleDefinitionLocator key of the parent (same
as returned by definition_for_usage(parent_usage) but included here as an optimization since it’s already known.)
- parsed_include: the XBlockInclude tuple containing the data from the
parsed <xblock-include /> element. See xblock.runtime.olx_parsing.
Must return a UsageKeyV2 subclass
openedx.core.djangoapps.xblock.learning_context.manager module#
Helper methods for working with learning contexts
- class openedx.core.djangoapps.xblock.learning_context.manager.LearningContextPluginManager#
Bases:
PluginManagerPlugin manager that uses stevedore extension points (entry points) to allow learning contexts to register as plugins.
The key of the learning context must match the CANONICAL_NAMESPACE of its LearningContextKey
- NAMESPACE = 'openedx.learning_context'#
- openedx.core.djangoapps.xblock.learning_context.manager.get_learning_context_impl(key)#
Given an opaque key, get the implementation of its learning context.
Returns a subclass of LearningContext
Raises TypeError if the specified key isn’t a type that has a learning context. Raises PluginError if there is some misconfiguration causing the context implementation to not be installed.
Module contents#
A “Learning Context” is a course, a library, a program, or some other collection of content where learning happens.