diff --git a/cms/djangoapps/xblock_config/apps.py b/cms/djangoapps/xblock_config/apps.py index 92271608f684..ae04e3f54793 100644 --- a/cms/djangoapps/xblock_config/apps.py +++ b/cms/djangoapps/xblock_config/apps.py @@ -19,9 +19,9 @@ class XBlockConfig(AppConfig): def ready(self): from openedx.core.lib.xblock_utils import xblock_local_resource_url - # In order to allow descriptors to use a handler url, we need to + # In order to allow blocks to use a handler url, we need to # monkey-patch the x_module library. # TODO: Remove this code when Runtimes are no longer created by modulestores # https://openedx.atlassian.net/wiki/display/PLAT/Convert+from+Storage-centric+runtimes+to+Application-centric+runtimes - xmodule.x_module.descriptor_global_handler_url = cms.lib.xblock.runtime.handler_url - xmodule.x_module.descriptor_global_local_resource_url = xblock_local_resource_url + xmodule.x_module.block_global_handler_url = cms.lib.xblock.runtime.handler_url + xmodule.x_module.block_global_local_resource_url = xblock_local_resource_url diff --git a/lms/djangoapps/lms_xblock/apps.py b/lms/djangoapps/lms_xblock/apps.py index 54cee08cefb2..768be3ab7e8c 100644 --- a/lms/djangoapps/lms_xblock/apps.py +++ b/lms/djangoapps/lms_xblock/apps.py @@ -22,5 +22,5 @@ def ready(self): # monkey-patch the x_module library. # TODO: Remove this code when Runtimes are no longer created by modulestores # https://openedx.atlassian.net/wiki/display/PLAT/Convert+from+Storage-centric+runtimes+to+Application-centric+runtimes - xmodule.x_module.descriptor_global_handler_url = handler_url - xmodule.x_module.descriptor_global_local_resource_url = local_resource_url + xmodule.x_module.block_global_handler_url = handler_url + xmodule.x_module.block_global_local_resource_url = local_resource_url diff --git a/xmodule/block_metadata_utils.py b/xmodule/block_metadata_utils.py index b9627568002f..329c53f8c536 100644 --- a/xmodule/block_metadata_utils.py +++ b/xmodule/block_metadata_utils.py @@ -34,7 +34,7 @@ def display_name_with_default(block): a name based on the URL. Unlike the rest of this module's functions, this function takes an entire - course descriptor/overview as a parameter. This is because a few test cases + course block/overview as a parameter. This is because a few test cases (specifically, {Text|Image|Video}AnnotationModuleTestCase.test_student_view) create scenarios where course.display_name is not None but course.location is None, which causes calling course.url_name to fail. So, although we'd diff --git a/xmodule/conditional_block.py b/xmodule/conditional_block.py index 5264db255e53..91e7af2c156e 100644 --- a/xmodule/conditional_block.py +++ b/xmodule/conditional_block.py @@ -213,8 +213,8 @@ def is_condition_satisfied(self): # lint-amnesty, pylint: disable=missing-funct for block in self.get_required_blocks: if not hasattr(block, attr_name): # We don't throw an exception here because it is possible for - # the descriptor of a required block to have a property but - # for the resulting module to be a (flavor of) ErrorBlock. + # the required block to have a property but + # for the resulting block to be a (flavor of) ErrorBlock. # So just log and return false. if block is not None: # We do not want to log when block is None, and it is when requester @@ -244,7 +244,7 @@ def student_view(self, _context): return fragment def get_html(self): - required_html_ids = [descriptor.location.html_id() for descriptor in self.get_required_blocks] + required_html_ids = [block.location.html_id() for block in self.get_required_blocks] return self.runtime.service(self, 'mako').render_template('conditional_ajax.html', { 'element_id': self.location.html_id(), 'ajax_url': self.ajax_url, @@ -298,7 +298,7 @@ def get_icon_class(self): class_priority = ['video', 'problem'] child_classes = [ - child_descriptor.get_icon_class() for child_descriptor in self.get_children() + child_block.get_icon_class() for child_block in self.get_children() ] for c in class_priority: if c in child_classes: @@ -318,24 +318,24 @@ def get_required_blocks(self): Returns a list of bound XBlocks instances upon which XBlock depends. """ return [ - self.runtime.get_block_for_descriptor(descriptor) for descriptor in self.get_required_block_descriptors() + self.runtime.get_block_for_descriptor(block) for block in self.get_required_block_descriptors() ] def get_required_block_descriptors(self): """ Returns a list of unbound XBlocks instances upon which this XBlock depends. """ - descriptors = [] + blocks = [] for location in self.sources_list: try: - descriptor = self.runtime.get_block(location) - descriptors.append(descriptor) + block = self.runtime.get_block(location) + blocks.append(block) except ItemNotFoundError: msg = "Invalid module by location." log.exception(msg) self.runtime.error_tracker(msg) - return descriptors + return blocks @classmethod def definition_from_xml(cls, xml_object, system): @@ -357,8 +357,8 @@ def definition_from_xml(cls, xml_object, system): show_tag_list.append(location) else: try: - descriptor = system.process_xml(etree.tostring(child, encoding='unicode')) - children.append(descriptor.scope_ids.usage_id) + block = system.process_xml(etree.tostring(child, encoding='unicode')) + children.append(block.scope_ids.usage_id) except: # lint-amnesty, pylint: disable=bare-except msg = "Unable to load child when parsing Conditional." log.exception(msg) diff --git a/xmodule/error_block.py b/xmodule/error_block.py index 10a9300bddab..fcebf8f744ff 100644 --- a/xmodule/error_block.py +++ b/xmodule/error_block.py @@ -97,8 +97,8 @@ def _construct(cls, system, contents, error_msg, location, for_parent=None): if location.block_type == 'error': location = location.replace( # Pick a unique url_name -- the sha1 hash of the contents. - # NOTE: We could try to pull out the url_name of the errored descriptor, - # but url_names aren't guaranteed to be unique between descriptor types, + # NOTE: We could try to pull out the url_name of the errored block, + # but url_names aren't guaranteed to be unique between block types, # and ErrorBlock can wrap any type. When the wrapped block is fixed, # it will be written out with the original url_name. name=hashlib.sha1(contents.encode('utf8')).hexdigest() @@ -141,19 +141,19 @@ def from_json(cls, json_data, system, location, error_msg='Error not available') ) @classmethod - def from_descriptor(cls, descriptor, error_msg=None): + def from_block(cls, block, error_msg=None): return cls._construct( - descriptor.runtime, - str(descriptor), + block.runtime, + str(block), error_msg, - location=descriptor.location, - for_parent=descriptor.get_parent() if descriptor.has_cached_parent else None + location=block.location, + for_parent=block.get_parent() if block.has_cached_parent else None ) @classmethod def from_xml(cls, xml_data, system, id_generator, # pylint: disable=arguments-differ error_msg=None): - '''Create an instance of this descriptor from the supplied data. + '''Create an instance of this block from the supplied data. Does not require that xml_data be parseable--just stores it and exports as-is if not. diff --git a/xmodule/library_content_block.py b/xmodule/library_content_block.py index e3e38c857017..04abe5de6eb3 100644 --- a/xmodule/library_content_block.py +++ b/xmodule/library_content_block.py @@ -468,7 +468,7 @@ def studio_view(self, _context): shim_xmodule_js(fragment, self.studio_js_module_name) return fragment - def get_child_descriptors(self): + def get_child_blocks(self): """ Return only the subset of our children relevant to the current student. """ @@ -701,7 +701,7 @@ def editor_saved(self, user, old_metadata, old_content): # lint-amnesty, pylint def has_dynamic_children(self): """ Inform the runtime that our children vary per-user. - See get_child_descriptors() above + See get_child_blocks() above """ return True @@ -714,7 +714,7 @@ def get_content_titles(self): This overwrites the get_content_titles method included in x_module by default. """ titles = [] - for child in self.get_child_descriptors(): + for child in self.get_child_blocks(): titles.extend(child.get_content_titles()) return titles diff --git a/xmodule/library_tools.py b/xmodule/library_tools.py index 5b59cc210d11..58cd8212416f 100644 --- a/xmodule/library_tools.py +++ b/xmodule/library_tools.py @@ -125,9 +125,9 @@ def _filter_child(self, usage_key, capa_type): if usage_key.block_type != "problem": return False - descriptor = self.store.get_item(usage_key, depth=0) - assert isinstance(descriptor, ProblemBlock) - return capa_type in descriptor.problem_types + block = self.store.get_item(usage_key, depth=0) + assert isinstance(block, ProblemBlock) + return capa_type in block.problem_types def can_use_library_content(self, block): """ diff --git a/xmodule/randomize_block.py b/xmodule/randomize_block.py index 6c17804b11bc..c5e1f2c4747f 100644 --- a/xmodule/randomize_block.py +++ b/xmodule/randomize_block.py @@ -85,7 +85,7 @@ def child(self): return child - def get_child_descriptors(self): + def get_child_blocks(self): """ For grading--return just the chosen child. """ @@ -99,7 +99,7 @@ def student_view(self, context): The student view. """ if self.child is None: - # raise error instead? In fact, could complain on descriptor load... + # raise error instead? In fact, could complain on block load... return Fragment(content="
Nothing to randomize between
") return self.child.render(STUDENT_VIEW, context) @@ -120,6 +120,6 @@ def definition_to_xml(self, resource_fs): def has_dynamic_children(self): """ Grading needs to know that only one of the children is actually "real". This - makes it use block.get_child_descriptors(). + makes it use block.get_child_blocks(). """ return True diff --git a/xmodule/services.py b/xmodule/services.py index c4d00a73906e..595c8082fb5a 100644 --- a/xmodule/services.py +++ b/xmodule/services.py @@ -190,7 +190,7 @@ def rebind_noauth_module_to_user(self, block, real_user): log.error(err_msg) raise RebindUserServiceError(err_msg) - field_data_cache_real_user = FieldDataCache.cache_for_descriptor_descendents( + field_data_cache_real_user = FieldDataCache.cache_for_block_descendents( self.course_id, real_user, block, diff --git a/xmodule/split_test_block.py b/xmodule/split_test_block.py index c60d72c863ed..c45848800fb3 100644 --- a/xmodule/split_test_block.py +++ b/xmodule/split_test_block.py @@ -177,13 +177,13 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method } @cached_property - def child_descriptor(self): + def child_block(self): """ Return the child block for the partition or None. """ - child_descriptors = self.get_child_descriptors() - if len(child_descriptors) >= 1: - return child_descriptors[0] + child_blocks = self.get_child_blocks() + if len(child_blocks) >= 1: + return child_blocks[0] return None @cached_property @@ -191,15 +191,15 @@ def child(self): """ Return the user bound child block for the partition or None. """ - if self.child_descriptor is not None: - return self.runtime.get_block_for_descriptor(self.child_descriptor) + if self.child_block is not None: + return self.runtime.get_block_for_descriptor(self.child_block) else: return None - def get_child_descriptor_by_location(self, location): + def get_child_block_by_location(self, location): """ Look through the children and look for one with the given location. - Returns the descriptor. + Returns the block. If none match, return None """ for child in self.get_children(): @@ -227,7 +227,7 @@ def get_content_titles(self): """ return self.child.get_content_titles() - def get_child_descriptors(self): + def get_child_blocks(self): """ For grading--return just the chosen child. """ @@ -239,19 +239,19 @@ def get_child_descriptors(self): str_group_id = str(group_id) if str_group_id in self.group_id_to_child: child_location = self.group_id_to_child[str_group_id] - child_descriptor = self.get_child_descriptor_by_location(child_location) + child_block = self.get_child_block_by_location(child_location) else: # Oops. Config error. log.debug("configuration error in split test block: invalid group_id %r (not one of %r). Showing error", str_group_id, list(self.group_id_to_child.keys())) # lint-amnesty, pylint: disable=line-too-long - if child_descriptor is None: - # Peak confusion is great. Now that we set child_descriptor, + if child_block is None: + # Peak confusion is great. Now that we set child_block, # get_children() should return a list with one element--the # xmodule for the child log.debug("configuration error in split test block: no such child") return [] - return [child_descriptor] + return [child_block] def get_group_id(self): """ @@ -271,8 +271,8 @@ def _staff_view(self, context): inactive_contents = [] for child_location in self.children: # pylint: disable=no-member - child_descriptor = self.get_child_descriptor_by_location(child_location) - child = self.runtime.get_block_for_descriptor(child_descriptor) + child_block = self.get_child_block_by_location(child_location) + child = self.runtime.get_block_for_descriptor(child_block) rendered_child = child.render(STUDENT_VIEW, context) fragment.add_fragment_resources(rendered_child) group_name, updated_group_id = self.get_data_for_vertical(child) @@ -346,8 +346,8 @@ def studio_render_children(self, fragment, children, context): dependencies are added to the specified fragment. """ html = "" - for active_child_descriptor in children: - active_child = self.runtime.get_block_for_descriptor(active_child_descriptor) + for active_child_block in children: + active_child = self.runtime.get_block_for_descriptor(active_child_block) rendered_child = active_child.render(StudioEditableBlock.get_preview_view_name(active_child), context) if active_child.category == 'vertical': group_name, group_id = self.get_data_for_vertical(active_child) @@ -378,7 +378,7 @@ def student_view(self, context): conditions for staff. """ if self.child is None: - # raise error instead? In fact, could complain on descriptor load... + # raise error instead? In fact, could complain on block load... return Fragment(content="
Nothing here. Move along.
") if self.runtime.user_is_staff: @@ -464,8 +464,8 @@ def definition_from_xml(cls, xml_object, system): for child in xml_object: try: - descriptor = system.process_xml(etree.tostring(child)) - children.append(descriptor.scope_ids.usage_id) + block = system.process_xml(etree.tostring(child)) + children.append(block.scope_ids.usage_id) except Exception: # lint-amnesty, pylint: disable=broad-except msg = "Unable to load child when parsing split_test block." log.exception(msg) @@ -486,7 +486,7 @@ def get_context(self): def has_dynamic_children(self): """ Grading needs to know that only one of the children is actually "real". This - makes it use block.get_child_descriptors(). + makes it use block.get_child_blocks(). """ return True @@ -561,9 +561,9 @@ def active_and_inactive_children(self): if not user_partition: return [], children - def get_child_descriptor(location): + def get_child_block(location): """ - Returns the child descriptor which matches the specified location, or None if one is not found. + Returns the child block which matches the specified location, or None if one is not found. """ for child in children: if child.location == location: @@ -575,7 +575,7 @@ def get_child_descriptor(location): for group in user_partition.groups: group_id = str(group.id) child_location = self.group_id_to_child.get(group_id, None) - child = get_child_descriptor(child_location) + child = get_child_block(child_location) if child: active_children.append(child) diff --git a/xmodule/studio_editable.py b/xmodule/studio_editable.py index 2795bf31bca8..844f0f446c37 100644 --- a/xmodule/studio_editable.py +++ b/xmodule/studio_editable.py @@ -51,8 +51,8 @@ def get_preview_view_name(block): return AUTHOR_VIEW if has_author_view(block) else STUDENT_VIEW -def has_author_view(descriptor): +def has_author_view(block): """ - Returns True if the xmodule linked to the descriptor supports "author_view". + Returns True if the xmodule linked to the block supports "author_view". """ - return getattr(descriptor, 'has_author_view', False) + return getattr(block, 'has_author_view', False) diff --git a/xmodule/templates.py b/xmodule/templates.py index f019d5ee409e..550d84ae4391 100644 --- a/xmodule/templates.py +++ b/xmodule/templates.py @@ -21,13 +21,13 @@ def all_templates(): """ - Returns all templates for enabled modules, grouped by descriptor type + Returns all templates for enabled modules, grouped by block type """ # TODO use memcache to memoize w/ expiration templates = defaultdict(list) - for category, descriptor in XBlock.load_classes(): - if not hasattr(descriptor, 'templates'): + for category, block in XBlock.load_classes(): + if not hasattr(block, 'templates'): continue - templates[category] = descriptor.templates() + templates[category] = block.templates() return templates diff --git a/xmodule/video_block/transcripts_utils.py b/xmodule/video_block/transcripts_utils.py index 0cbc79945b8d..39f18ca741ca 100644 --- a/xmodule/video_block/transcripts_utils.py +++ b/xmodule/video_block/transcripts_utils.py @@ -241,13 +241,13 @@ def get_transcripts_from_youtube(youtube_id, settings, i18n, youtube_transcript_ return {'start': sub_starts, 'end': sub_ends, 'text': sub_texts} -def download_youtube_subs(youtube_id, video_descriptor, settings): # lint-amnesty, pylint: disable=redefined-outer-name +def download_youtube_subs(youtube_id, video_block, settings): # lint-amnesty, pylint: disable=redefined-outer-name """ Download transcripts from Youtube. Args: youtube_id: str, actual youtube_id of the video. - video_descriptor: video descriptor instance. + video_block: video block instance. We save transcripts for 1.0 speed, as for other speed conversion is done on front-end. @@ -257,7 +257,7 @@ def download_youtube_subs(youtube_id, video_descriptor, settings): # lint-amnes Raises: GetTranscriptsFromYouTubeException, if fails. """ - i18n = video_descriptor.runtime.service(video_descriptor, "i18n") + i18n = video_block.runtime.service(video_block, "i18n") _ = i18n.ugettext subs = get_transcripts_from_youtube(youtube_id, settings, i18n) @@ -961,7 +961,7 @@ def get_transcript_from_contentstore(video, language, output_format, transcripts Get video transcript from content store. Arguments: - video (Video Descriptor): Video descriptor + video (Video block): Video block language (unicode): transcript language output_format (unicode): transcript output format transcripts_info (dict): transcript info for a video @@ -1089,7 +1089,7 @@ def get_transcript(video, lang=None, output_format=Transcript.SRT, youtube_id=No Get video transcript from edx-val or content store. Arguments: - video (Video Descriptor): Video Descriptor + video (Video block): Video block lang (unicode): transcript language output_format (unicode): transcript output format youtube_id (unicode): youtube video id diff --git a/xmodule/x_module.py b/xmodule/x_module.py index 031a895b0faa..3434a80b3955 100644 --- a/xmodule/x_module.py +++ b/xmodule/x_module.py @@ -286,7 +286,7 @@ class XModuleMixin(XModuleFields, XBlock): Adding this Mixin to an :class:`XBlock` allows it to cooperate with old-style :class:`XModules` """ - # Attributes for inspection of the descriptor + # Attributes for inspection of the block # This indicates whether the xmodule is a problem-type. # It should respond to max_score() and grade(). It can be graded or ungraded @@ -299,7 +299,7 @@ class XModuleMixin(XModuleFields, XBlock): # Class level variable - # True if this descriptor always requires recalculation of grades, for + # True if this block always requires recalculation of grades, for # example if the score can change via an extrnal service, not just when the # student interacts with the module on the page. A specific example is # FoldIt, which posts grade-changing updates through a separate API. @@ -563,10 +563,10 @@ def get_icon_class(self): def has_dynamic_children(self): """ - Returns True if this descriptor has dynamic children for a given + Returns True if this block has dynamic children for a given student when the module is created. - Returns False if the children of this descriptor are the same + Returns False if the children of this block are the same children that the module will return for any student. """ return False @@ -1002,7 +1002,7 @@ def wrap_aside(self, block, aside, view, frag, context): # pylint: disable=un # Runtime.handler_url interface. # # The monkey-patching happens in cms/djangoapps/xblock_config/apps.py and lms/djangoapps/lms_xblock/apps.py -def descriptor_global_handler_url(block, handler_name, suffix='', query='', thirdparty=False): +def block_global_handler_url(block, handler_name, suffix='', query='', thirdparty=False): """ See :meth:`xblock.runtime.Runtime.handler_url`. """ @@ -1014,7 +1014,7 @@ def descriptor_global_handler_url(block, handler_name, suffix='', query='', thir # the Runtime part of its interface. This function matches the Runtime.local_resource_url interface # # The monkey-patching happens in cms/djangoapps/xblock_config/apps.py and lms/djangoapps/lms_xblock/apps.py -def descriptor_global_local_resource_url(block, uri): +def block_global_local_resource_url(block, uri): """ See :meth:`xblock.runtime.Runtime.local_resource_url`. """ @@ -1529,7 +1529,7 @@ def handler_url(self, block, handler_name, suffix='', query='', thirdparty=False # defined for LMS/CMS through the handler_url_override property. if getattr(self, 'handler_url_override', None): return self.handler_url_override(block, handler_name, suffix, query, thirdparty) - return descriptor_global_handler_url(block, handler_name, suffix, query, thirdparty) + return block_global_handler_url(block, handler_name, suffix, query, thirdparty) def local_resource_url(self, block, uri): """ @@ -1539,7 +1539,7 @@ def local_resource_url(self, block, uri): # This means that LMS/CMS don't have a way to define a subclass of DescriptorSystem # that implements the correct local_resource_url. So, for now, instead, we will reference a # global function that the application can override. - return descriptor_global_local_resource_url(block, uri) + return block_global_local_resource_url(block, uri) def applicable_aside_types(self, block): """ diff --git a/xmodule/xml_block.py b/xmodule/xml_block.py index e67e23604635..cb7c096ce942 100644 --- a/xmodule/xml_block.py +++ b/xmodule/xml_block.py @@ -152,7 +152,7 @@ def _get_metadata_from_xml(xml_object, remove=True): @classmethod def definition_from_xml(cls, xml_object, system): """ - Return the definition to be passed to the newly created descriptor + Return the definition to be passed to the newly created block during from_xml xml_object: An etree Element @@ -199,7 +199,7 @@ def load_file(cls, filepath, fs, def_id): # pylint: disable=invalid-name @classmethod def load_definition(cls, xml_object, system, def_id, id_generator): """ - Load a descriptor definition from the specified xml_object. + Load a block from the specified xml_object. Subclasses should not need to override this except in special cases (e.g. html block) @@ -365,7 +365,7 @@ def parse_xml(cls, node, runtime, _keys, id_generator): xblock = runtime.construct_xblock_from_class( cls, - # We're loading a descriptor, so student_id is meaningless + # We're loading a block, so student_id is meaningless ScopeIds(None, node.tag, def_id, usage_id), field_data, ) @@ -405,7 +405,7 @@ def _format_filepath(cls, category, name): return f'{category}/{name}.{cls.filename_extension}' def export_to_file(self): - """If this returns True, write the definition of this descriptor to a separate + """If this returns True, write the definition of this block to a separate file. NOTE: Do not override this without a good reason. It is here