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: object

Abstract 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: User, usage_key: UsageKeyV2) bool#

Assuming a block with the specified ID (usage_key) exists, does the specified user have permission to edit it (make changes to the fields / 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: User, usage_key: UsageKeyV2) bool#

Assuming a block with the specified ID (usage_key) exists, does the specified user have permission to view it and interact with it (call handlers, save user state, etc.)? This is also sometimes called the “can_learn” permission.

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_for_editing(user: User, usage_key: UsageKeyV2) bool#

Assuming a block with the specified ID (usage_key) exists, does the specified user have permission to view its fields and OLX details (but not necessarily to make changes to it)?

definition_for_usage(usage_key, **kwargs)#

Given a usage key in this context, return the key indicating the actual XBlock definition.

Retuns None if the usage key doesn’t exist in this context.

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: PluginManager

Plugin 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.