lms.djangoapps.lms_xblock package#

Submodules#

lms.djangoapps.lms_xblock.apps module#

lms_xblock Application Configuration

class lms.djangoapps.lms_xblock.apps.LMSXBlockConfig(app_name, app_module)#

Bases: AppConfig

Default configuration for the “lms.djangoapps.lms_xblock” Django application.

name = 'lms.djangoapps.lms_xblock'#
ready()#

Override this method in subclasses to run code when Django starts.

verbose_name = 'LMS XBlock'#

lms.djangoapps.lms_xblock.field_data module#

FieldData subclasses used by the LMS

class lms.djangoapps.lms_xblock.field_data.LmsFieldData(authored_data, student_data)#

Bases: SplitFieldData

A FieldData that reads all UserScope.ONE and UserScope.ALL fields from student_data and all UserScope.NONE fields from authored_data. It also prevents writing to authored_data.

lms.djangoapps.lms_xblock.mixin module#

Namespace that defines fields common to all blocks used in the LMS

class lms.djangoapps.lms_xblock.mixin.GroupAccessDict(help=None, default=fields.UNSET, scope=(UserScope.NONE, BlockScope.DEFINITION, 'content'), display_name=None, values=None, enforce_type=False, xml_node=False, force_export=False, **kwargs)#

Bases: Dict

Special Dict class for serializing the group_access field.

from_json(value)#

Return value as a native full featured python type (the inverse of to_json)

Called during field reads to convert the stored value into a full featured python object

to_json(value)#

Return value in the form of nested lists and dictionaries (suitable for passing to json.dumps).

This is called during field writes to convert the native python type to the value stored in the database

class lms.djangoapps.lms_xblock.mixin.LmsBlockMixin(scope_ids, field_data=None, *, runtime, **kwargs)#

Bases: XBlockMixin

Mixin that defines fields common to all blocks used in the LMS

chrome#

A field class for representing a string.

The value, as loaded or enforced, can either be None or a basestring instance.

default_tab#

A field class for representing a string.

The value, as loaded or enforced, can either be None or a basestring instance.

format#

A field class for representing a string.

The value, as loaded or enforced, can either be None or a basestring instance.

group_access#

Special Dict class for serializing the group_access field.

hide_from_toc#

A field class for representing a boolean.

The value, as loaded or enforced, can be either a Python bool, a string, or any value that will then be converted to a bool in the from_json method.

Examples:

True -> True
'true' -> True
'TRUE' -> True
'any other string' -> False
[] -> False
['123'] -> True
None - > False
merged_group_access()#

This computes access to a block’s group_access rules in the context of its position within the courseware structure, in the form of a lazily-computed attribute. Each block’s group_access rule is merged recursively with its parent’s, guaranteeing that any rule in a parent block will be enforced on descendants, even if a descendant also defined its own access rules. The return value is always a dict, with the same structure as that of the group_access field.

When merging access rules results in a case where all groups are denied access in a user partition (which effectively denies access to that block for all students), the special value False will be returned for that user partition key.

publish_completion(data, suffix='')#

Publish completion data from the front end.

source_file#

A field class for representing a string.

The value, as loaded or enforced, can either be None or a basestring instance.

user_partitions#

Special List class for listing UserPartitions

validate()#

Validates the state of this xblock instance.

visible_to_staff_only#

A field class for representing a boolean.

The value, as loaded or enforced, can be either a Python bool, a string, or any value that will then be converted to a bool in the from_json method.

Examples:

True -> True
'true' -> True
'TRUE' -> True
'any other string' -> False
[] -> False
['123'] -> True
None - > False

lms.djangoapps.lms_xblock.models module#

Models used by LMS XBlock infrastructure.

Includes:
XBlockAsidesConfig: A ConfigurationModel for managing how XBlockAsides are

rendered in the LMS.

class lms.djangoapps.lms_xblock.models.XBlockAsidesConfig(*args, **kwargs)#

Bases: ConfigurationModel

Configuration for XBlockAsides.

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

change_date#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

changed_by#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

changed_by_id#
disabled_blocks#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

enabled#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=True, **kwargs)#
get_previous_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=False, **kwargs)#
id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod possible_asides()#

Return a list of all asides that are enabled across all XBlocks.

lms.djangoapps.lms_xblock.runtime module#

Module implementing xblock.runtime.Runtime functionality for the LMS

class lms.djangoapps.lms_xblock.runtime.UserTagsService(user, course_id)#

Bases: object

A runtime class that provides an interface to the user service. It handles filling in the current course id and current user.

COURSE_SCOPE = 'course'#
get_tag(scope, key)#

Get a user tag for the current course and the current user for a given key

scope: the current scope of the runtime key: the key for the value we want

set_tag(scope, key, value)#

Set the user tag for the current course and the current user for a given key

scope: the current scope of the runtime key: the key that to the value to be set value: the value to set

lms.djangoapps.lms_xblock.runtime.handler_url(block, handler_name, suffix='', query='', thirdparty=False)#

This method matches the signature for xblock.runtime:Runtime.handler_url()

Parameters:
  • block – The block to generate the url for

  • handler_name – The handler on that block that the url should resolve to

  • suffix – Any path suffix that should be added to the handler url

  • query – Any query string that should be added to the handler url (which should not include an initial ? or &)

  • thirdparty – If true, return a fully-qualified URL instead of relative URL. This is useful for URLs to be used by third-party services.

lms.djangoapps.lms_xblock.runtime.lms_applicable_aside_types(block, applicable_aside_types=None)#

Return all of the asides which might be decorating this block.

Parameters:

block (XBlock) – The block to render retrieve asides for.

lms.djangoapps.lms_xblock.runtime.lms_wrappers_aside(block, aside, view, frag, context, request_token=None)#

Creates a div which identifies the aside, points to the original block, and writes out the json_init_args into a script tag.

The default implementation creates a frag to wraps frag w/ a div identifying the xblock. If you have javascript, you’ll need to override this impl

lms.djangoapps.lms_xblock.runtime.local_resource_url(block, uri)#

local_resource_url for Studio

Module contents#