lms.lib package#

Subpackages#

Submodules#

lms.lib.utils module#

Helper methods for the LMS.

lms.lib.utils.get_parent_unit(xblock)#

Finds xblock’s parent unit if it exists.

To find an xblock’s parent unit, we traverse up the xblock’s family tree until we find an xblock whose parent is a sequential xblock, which guarantees that the xblock is a unit. The get_parent() call on both the xblock and the parent block ensure that we don’t accidentally return that a unit is its own parent unit.

Returns:

Returns the parent unit xblock if it exists. If no parent unit exists, returns None

Return type:

xblock

lms.lib.utils.is_unit(xblock)#

Checks whether the xblock is a unit.

Get_parent_unit() returns None if the current xblock either does not have a parent unit or is itself a unit. To make sure that get_parent_unit() isn’t returning None because the xblock is an orphan, we check that the xblock has a parent.

Returns:

True if the xblock is itself a unit, False otherwise.

Module contents#