lms.djangoapps.course_blocks package#

Subpackages#

Submodules#

lms.djangoapps.course_blocks.api module#

API entry point to the course_blocks app with top-level get_course_blocks function.

lms.djangoapps.course_blocks.api.get_course_block_access_transformers(user)#

Default list of transformers for manipulating course block structures based on the user’s access to the course blocks.

Parameters:

user (django.contrib.auth.models.User) – which the block structure is to be transformed.

lms.djangoapps.course_blocks.api.get_course_blocks(user, starting_block_usage_key, transformers=None, collected_block_structure=None, allow_start_dates_in_future=False, include_completion=False, include_has_scheduled_content=False)#

A higher order function implemented on top of the block_structure.get_blocks function returning a transformed block structure for the given user starting at starting_block_usage_key.

Parameters:
  • user (django.contrib.auth.models.User) – which the block structure is to be transformed.

  • starting_block_usage_key (UsageKey) – of the block structure that is to be transformed.

  • transformers (BlockStructureTransformers) – transformers whose transform methods are to be called. If None, get_course_block_access_transformers() is used.

  • collected_block_structure (BlockStructureBlockData) – block structure retrieved from a prior call to BlockStructureManager.get_collected. Can be optionally provided if already available, for optimization.

Returns:

BlockStructureBlockData - A transformed block structure,

starting at starting_block_usage_key, that has undergone the transform methods for the given user and the course associated with the block structure. If using the default transformers, the transformed block structure will be exactly equivalent to the blocks that the given user has access.

lms.djangoapps.course_blocks.api.has_individual_student_override_provider()#

check if FIELD_OVERRIDE_PROVIDERS has class lms.djangoapps.courseware.student_field_overrides.IndividualStudentOverrideProvider

lms.djangoapps.course_blocks.usage_info module#

Declares CourseUsageInfo class to be used by the transform method in Transformers.

class lms.djangoapps.course_blocks.usage_info.CourseUsageInfo(course_key, user, allow_start_dates_in_future=False, include_has_scheduled_content=False)#

Bases: object

A class object that encapsulates the course and user context to be used as currency across block structure transformers, by passing an instance of it in calls to BlockStructureTransformer.transform methods.

property has_staff_access#

Returns whether the user has staff access to the course associated with this CourseUsageInfo instance.

For performance reasons (minimizing multiple SQL calls), the value is cached within this instance.

lms.djangoapps.course_blocks.utils module#

Common utilities for use along with the course blocks.

lms.djangoapps.course_blocks.utils.get_student_module_as_dict(user, course_key, block_key)#

Get the student module as a dict for the given user for the given block.

Parameters:
  • user (User)

  • course_key (CourseLocator)

  • block_key (BlockUsageLocator)

Returns:

StudentModule as a (possibly empty) dict.

Module contents#

The Course Blocks app, built upon the Block Cache framework in openedx.core.djangoapps.content.block_structure, is a higher layer django app in LMS that provides additional context of Courses and Users (via usage_info.py) with implementations for Block Structure Transformers that are related to block structure course access.

As described in the Block Cache framework’s __init__ module, this framework provides faster access to course blocks for performance sensitive features, by caching all transformer-required data so no modulestore access is necessary during block access.

It is expected that only Block Access related transformers reside in this django app, as they are cross-cutting authorization transformers required across other features. Other higher-level and feature-specific transformers should be implemented in their own separate apps.

Note: Currently, some of the implementation is redundant with the has_access code in courseware/access.py. However, we do have short-term plans for refactoring the current has_access code to use Course Blocks instead (https://openedx.atlassian.net/browse/MA-1019). We have introduced this redundancy in the short-term as an incremental implementation approach, reducing risk with initial release of this app.