本文整理匯總了Python中xblock.fields.Scope.settings方法的典型用法代碼示例。如果您正苦於以下問題:Python Scope.settings方法的具體用法?Python Scope.settings怎麽用?Python Scope.settings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xblock.fields.Scope
的用法示例。
在下文中一共展示了Scope.settings方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: studio_view
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def studio_view(self, context):
"""
Render a form for editing this XBlock
"""
fragment = Fragment()
context = {'fields': []}
# Build a list of all the fields that can be edited:
for field_name in self.editable_fields:
field = self.fields[field_name]
assert field.scope in (Scope.content, Scope.settings), (
"Only Scope.content or Scope.settings fields can be used with "
"StudioEditableXBlockMixin. Other scopes are for user-specific data and are "
"not generally created/configured by content authors in Studio."
)
field_info = self._make_field_info(field_name, field)
if field_info is not None:
context["fields"].append(field_info)
fragment.content = loader.render_django_template('templates/studio_edit.html', context)
fragment.add_javascript(loader.load_unicode('public/studio_edit.js'))
fragment.initialize_js('StudioEditableXBlockMixin')
return fragment
示例2: studio_submit
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def studio_submit(self, submissions, suffix=''): # pylint: disable=unused-argument
"""
Change the settings for this XBlock given by the Studio user
"""
if not isinstance(submissions, dict):
LOG.error("submissions object from Studio is not a dict - %r", submissions)
return {
'result': 'error'
}
if 'display_name' in submissions:
self.display_name = submissions['display_name']
if 'embed_code' in submissions:
self.embed_code = submissions['embed_code']
if 'alt_text' in submissions:
self.alt_text = submissions['alt_text']
return {
'result': 'success',
}
# suffix argument is specified for xblocks, but we are not using herein
示例3: studio_submit
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def studio_submit(self, submissions, suffix=''): # pylint: disable=unused-argument
"""
Change the settings for this XBlock given by the Studio user
"""
if not isinstance(submissions, dict):
LOG.error("submissions object from Studio is not a dict - %r", submissions)
return {
'result': 'error'
}
if 'display_name' in submissions:
self.display_name = submissions['display_name']
if 'calendar_id' in submissions:
self.calendar_id = submissions['calendar_id']
if 'default_view' in submissions:
self.default_view = submissions['default_view']
return {
'result': 'success',
}
示例4: fetch
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def fetch(cls, descriptor):
"""
Fetch the key:value editable course details for the given course from
persistence and return a CourseMetadata model.
"""
result = {}
for field in descriptor.fields.values():
if field.scope != Scope.settings:
continue
if field.name in cls.filtered_list():
continue
result[field.name] = {
'value': field.read_json(descriptor),
'display_name': _(field.display_name),
'help': _(field.help),
'deprecated': field.runtime_options.get('deprecated', False)
}
return result
示例5: __init__
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def __init__(self, authored_data, student_data):
# Make sure that we don't repeatedly nest CmsFieldData instances
if isinstance(authored_data, CmsFieldData):
authored_data = authored_data._authored_data # pylint: disable=protected-access
self._authored_data = authored_data
self._student_data = student_data
super(CmsFieldData, self).__init__({
Scope.content: authored_data,
Scope.settings: authored_data,
Scope.parent: authored_data,
Scope.children: authored_data,
Scope.user_state_summary: student_data,
Scope.user_state: student_data,
Scope.user_info: student_data,
Scope.preferences: student_data,
})
示例6: get_attribute_or_default
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def get_attribute_or_default(self, attribute_name):
"""
If the given attribute is set on the instance, return it immediately.
Otherwise check if it has a default in the settings service.
If neither are available, return None
"""
try:
available_attr = getattr(self, attribute_name)
except AttributeError:
available_attr = None
if available_attr:
return available_attr
if getattr(self.runtime, 'service') and hasattr(self, 'service_declaration'):
settings_service = self.runtime.service(self, 'settings')
if settings_service:
setting_name = self.DEFAULT_ATTRIBUTE_SETTINGS[attribute_name]
return settings_service.get_settings_bucket(self).get(setting_name)
return available_attr # Ensures that the field's default type is preserved
示例7: student_view
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def student_view(self, context=None):
context_html = self.get_context_student()
template = self.render_template('static/html/scormxblock.html', context_html)
frag = Fragment(template)
frag.add_css(self.resource_string("static/css/scormxblock.css"))
frag.add_javascript(self.resource_string("static/js/src/scormxblock.js"))
settings = {
'version_scorm': self.version_scorm
}
frag.initialize_js('ScormXBlock', json_args=settings)
return frag
示例8: get_context_student
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def get_context_student(self):
scorm_file_path = ''
if self.scorm_file:
scheme = 'https' if settings.HTTPS == 'on' else 'http'
scorm_file_path = '{}://{}{}'.format(
scheme,
configuration_helpers.get_value('site_domain', settings.ENV_TOKENS.get('LMS_BASE')),
self.scorm_file
)
return {
'scorm_file_path': scorm_file_path,
'completion_status': self.get_completion_status(),
'scorm_xblock': self
}
示例9: filtered_list
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def filtered_list(cls):
"""
Filter fields based on feature flag, i.e. enabled, disabled.
"""
# Copy the filtered list to avoid permanently changing the class attribute.
filtered_list = list(cls.FILTERED_LIST)
# Do not show giturl if feature is not enabled.
if not settings.FEATURES.get('ENABLE_EXPORT_GIT'):
filtered_list.append('giturl')
return filtered_list
示例10: student_view_data
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def student_view_data(self, context=None):
"""
Returns a dict containing the settings for the student view.
Returns:
E.g.,
{
"player_token": "http://player.ooyala.com/sas/embed_token/53YWsyOszKOsfS1...",
"player_token_expires": 1501812713,
"partner_code: "53YWsyOszKOsfS1IvcQoKn8YhWYk",
"content_id": "5sMHA1YzE6KHI-dFSKgDz-pcMOx37_f9",
"player_type": "bcove",
"bcove_id": "6068615189001"
}
See player_token() for more information on the player_token_* fields.
"""
data = self.player_token()
data.update({
'partner_code': self.get_attribute_or_default('partner_code'),
'content_id': self.reference_id or self.content_id,
'player_type': VideoType.BRIGHTCOVE if self.is_brightcove_video else VideoType.OOYALA,
'bcove_id': self.content_id if self.is_brightcove_video else None,
'bcove_account_id': self.get_attribute_or_default('brightcove_account'),
'bcove_policy': self.get_attribute_or_default('brightcove_policy'),
})
return data
示例11: brightcove_policy
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def brightcove_policy(self):
xblock_settings = settings.XBLOCK_SETTINGS if hasattr(settings, "XBLOCK_SETTINGS") else {}
return xblock_settings.get('OoyalaPlayerBlock', {}).get('BCOVE_POLICY')
示例12: brightcove_account
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def brightcove_account(self):
xblock_settings = settings.XBLOCK_SETTINGS if hasattr(settings, "XBLOCK_SETTINGS") else {}
return xblock_settings.get('OoyalaPlayerBlock', {}).get('BCOVE_ACCOUNT_ID')
示例13: local_resource_url
# 需要導入模塊: from xblock.fields import Scope [as 別名]
# 或者: from xblock.fields.Scope import settings [as 別名]
def local_resource_url(self, block, uri):
"""
local_resource_url for xblocks, with lightchild support.
"""
path = reverse('xblock_resource_url', kwargs={
'block_type': block.lightchild_block_type or block.scope_ids.block_type,
'uri': uri,
})
return '//{}{}'.format(settings.SITE_NAME, path)