-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the LTI Consumer XBlock (#142)
- Loading branch information
1 parent
5b64b51
commit c4868e0
Showing
5 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
Module contains various XBlock services for the workbench. | ||
""" | ||
from __future__ import unicode_literals | ||
|
||
from django.conf import settings | ||
|
||
|
||
class SettingsService(object): | ||
""" | ||
Allows server-wide configuration of XBlocks on a per-type basis. | ||
The service is copied as-is from the Open edX platform: | ||
- `edx-platform/common/lib/xmodule/xmodule/services.py` | ||
""" | ||
xblock_settings_bucket_selector = 'block_settings_key' | ||
|
||
def get_settings_bucket(self, block, default=None): | ||
""" Gets xblock settings dictionary from settings. """ | ||
if not block: | ||
raise ValueError("Expected XBlock instance, got {block} of type {type}".format( | ||
block=block, | ||
type=type(block) | ||
)) | ||
|
||
actual_default = default if default is not None else {} | ||
xblock_settings_bucket = getattr(block, self.xblock_settings_bucket_selector, block.unmixed_class.__name__) | ||
xblock_settings = settings.XBLOCK_SETTINGS if hasattr(settings, "XBLOCK_SETTINGS") else {} | ||
return xblock_settings.get(xblock_settings_bucket, actual_default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters