Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cms/djangoapps/contentstore/core/course_optimizer_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def _update_node_tree_and_dictionary(block, link, link_state, node_tree, diction
xblock_id,
{
'display_name': xblock.display_name,
'category': getattr(xblock, 'category', ''),
'category': getattr(getattr(xblock, 'scope_ids', None), 'block_type', ''),
}
)
# Sets new current node and creates the node if it doesn't exist
Expand All @@ -258,7 +258,7 @@ def _update_node_tree_and_dictionary(block, link, link_state, node_tree, diction
# Add block-level details for the last xblock in the path (URL and broken/locked links)
updated_dictionary[xblock_id].setdefault(
'url',
f'/course/{block.course_id}/editor/{block.category}/{block.location}'
f'/course/{block.course_id}/editor/{block.scope_ids.block_type}/{block.location}'
)

# The link_state == True condition is maintained for backward compatibility.
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/courseware_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def prepare_item_index(item, skip_index=False, groups_usage_info=None):

item_content_groups = None

if item.category == "split_test": # lint-amnesty, pylint: disable=too-many-nested-blocks
if item.scope_ids.block_type == "split_test": # lint-amnesty, pylint: disable=too-many-nested-blocks
split_partition = item.get_selected_partition()
for split_test_child in item.get_children():
if split_partition:
Expand Down
18 changes: 9 additions & 9 deletions cms/djangoapps/contentstore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def is_unit(xblock, parent_xblock=None):
Returns true if the specified xblock is a vertical that is treated as a unit.
A unit is a vertical that is a direct child of a sequential (aka a subsection).
"""
if xblock.category == 'vertical':
if xblock.scope_ids.block_type == 'vertical':
if parent_xblock is None:
parent_xblock = get_parent_xblock(xblock)
parent_category = parent_xblock.category if parent_xblock else None
parent_category = parent_xblock.scope_ids.block_type if parent_xblock else None
return parent_category == 'sequential'
return False

Expand All @@ -94,15 +94,15 @@ def is_library_content(xblock):
"""
Returns true if the specified xblock is library content.
"""
return xblock.category == 'library_content'
return xblock.scope_ids.block_type == 'library_content'


def get_parent_if_split_test(xblock):
"""
Returns the parent of the specified xblock if it is a split test, otherwise returns None.
"""
parent_xblock = get_parent_xblock(xblock)
if parent_xblock and parent_xblock.category == 'split_test':
if parent_xblock and parent_xblock.scope_ids.block_type == 'split_test':
return parent_xblock


Expand All @@ -117,7 +117,7 @@ def xblock_has_own_studio_page(xblock, parent_xblock=None):
- a direct child of a unit
3. XBlocks that support children
"""
category = xblock.category
category = xblock.scope_ids.block_type

if is_unit(xblock, parent_xblock):
return True
Expand Down Expand Up @@ -151,7 +151,7 @@ def xblock_studio_url(xblock, parent_xblock=None, find_parent=False):
return None
else:
return None
category = xblock.category
category = xblock.scope_ids.block_type
if category == 'course':
return reverse_course_url('course_handler', xblock.location.course_key)
elif category in ('chapter', 'sequential'):
Expand Down Expand Up @@ -204,8 +204,8 @@ def xblock_type_display_name(xblock, default_display_name=None):
:return:
"""

if hasattr(xblock, 'category'):
category = xblock.category
if hasattr(xblock, 'scope_ids'):
category = xblock.scope_ids.block_type
if category == 'vertical' and not is_unit(xblock):
return _('Vertical')
else:
Expand Down Expand Up @@ -238,7 +238,7 @@ def xblock_primary_child_category(xblock):
"""
Returns the primary child category for the specified xblock, or None if there is not a primary category.
"""
category = xblock.category
category = xblock.scope_ids.block_type
if category == 'course':
return 'chapter'
elif category == 'chapter':
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ def _scan_course_for_links(course_key):
for block in blocks:
# Excluding 'drag-and-drop-v2' as it contains data of object type instead of string, causing errors,
# and it doesn't contain user-facing links to scan.
if block.category == 'drag-and-drop-v2':
if block.scope_ids.block_type == 'drag-and-drop-v2':
continue
block_id = str(block.location)
block_info = get_block_info(block)
Expand Down
8 changes: 4 additions & 4 deletions cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def find_release_date_source(xblock):
"""

# Stop searching at the section level
if xblock.category == 'chapter':
if xblock.scope_ids.block_type == 'chapter':
return xblock

parent_location = modulestore().get_parent_location(xblock.location,
Expand All @@ -661,7 +661,7 @@ def find_staff_lock_source(xblock):
return xblock

# Stop searching at the section level
if xblock.category == 'chapter':
if xblock.scope_ids.block_type == 'chapter':
return None

parent_location = modulestore().get_parent_location(xblock.location,
Expand Down Expand Up @@ -1276,13 +1276,13 @@ def gather_block_attributes(source_item, display_name=None, is_child=False):
duplicate_metadata[field.name] = field.read_from(source_item)

if is_child:
display_name = display_name or source_item.display_name or source_item.category
display_name = display_name or source_item.display_name or source_item.scope_ids.block_type

if display_name is not None:
duplicate_metadata['display_name'] = display_name
else:
if source_item.display_name is None:
duplicate_metadata['display_name'] = _("Duplicate of {0}").format(source_item.category)
duplicate_metadata['display_name'] = _("Duplicate of {0}").format(source_item.scope_ids.block_type)
else:
duplicate_metadata['display_name'] = _("Duplicate of '{0}'").format(source_item.display_name)

Expand Down
3 changes: 1 addition & 2 deletions cms/djangoapps/contentstore/views/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ def xblock_outline_handler(request, usage_key_string):
root_xblock,
include_child_info=True,
course_outline=True,
include_children_predicate=lambda xblock: not xblock.category
== "vertical",
include_children_predicate=lambda xblock: xblock.scope_ids.block_type != "vertical",
)
)
else:
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def _course_outline_json(request, course_block):
Returns a JSON representation of the course block and recursively all of its children.
"""
is_concise = request.GET.get('format') == 'concise'
include_children_predicate = lambda xblock: not xblock.category == 'vertical'
include_children_predicate = lambda xblock: xblock.scope_ids.block_type != 'vertical'
if is_concise:
include_children_predicate = lambda xblock: xblock.has_children
return create_xblock_info(
Expand Down
4 changes: 2 additions & 2 deletions cms/djangoapps/contentstore/views/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _prepare_runtime_for_preview(request, block):
"""

course_id = block.location.course_key
display_name_only = (block.category == 'static_tab')
display_name_only = (block.scope_ids.block_type == 'static_tab')

wrappers = [
# This wrapper wraps the block in the template specified above
Expand Down Expand Up @@ -337,7 +337,7 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
can_move = False

if upstream_link.error_message is None and upstream_link.upstream_ref:
can_edit = xblock.category in editable_library_components
can_edit = xblock.scope_ids.block_type in editable_library_components

# Is this a course or a library?
is_course = xblock.context_key.is_course
Expand Down
12 changes: 6 additions & 6 deletions cms/djangoapps/contentstore/views/tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def assert_xblock_info(xblock, xblock_info):
"""
self.assertEqual(str(xblock.location), xblock_info["id"])
self.assertEqual(xblock.display_name, xblock_info["display_name"])
self.assertEqual(xblock.category, xblock_info["category"])
self.assertEqual(xblock.scope_ids.block_type, xblock_info["category"])

for usage_key in (
problem_usage_key,
Expand Down Expand Up @@ -727,7 +727,7 @@ def _verify_duplicate_display_name(
"""
if is_child:
if original_item.display_name is None:
return duplicated_item.display_name == original_item.category
return duplicated_item.display_name == original_item.scope_ids.block_type
return duplicated_item.display_name == original_item.display_name
if original_item.display_name is not None:
return (
Expand All @@ -737,7 +737,7 @@ def _verify_duplicate_display_name(
)
)
return duplicated_item.display_name == "Duplicate of {display_name}".format(
display_name=original_item.category
display_name=original_item.scope_ids.block_type
)

def _duplicate_item(self, parent_usage_key, source_usage_key, display_name=None):
Expand Down Expand Up @@ -2469,8 +2469,8 @@ def test_create_groups(self):
self.assertEqual(2, len(split_test.children))
vertical_0 = self.get_item_from_modulestore(split_test.children[0])
vertical_1 = self.get_item_from_modulestore(split_test.children[1])
self.assertEqual("vertical", vertical_0.category)
self.assertEqual("vertical", vertical_1.category)
self.assertEqual("vertical", vertical_0.scope_ids.block_type)
self.assertEqual("vertical", vertical_1.scope_ids.block_type)
self.assertEqual(
"Group ID " + str(MINIMUM_UNUSED_PARTITION_ID + 1), vertical_0.display_name
)
Expand Down Expand Up @@ -3836,7 +3836,7 @@ def validate_component_xblock_info(self, xblock_info, original_block):
"""
Validate that the xblock info is correct for the test component.
"""
self.assertEqual(xblock_info["category"], original_block.category)
self.assertEqual(xblock_info["category"], original_block.scope_ids.block_type)
self.assertEqual(xblock_info["id"], str(original_block.location))
self.assertEqual(xblock_info["display_name"], original_block.display_name)
self.assertIsNone(xblock_info.get("has_changes", None))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_course_outline_initial_state(self):
course_structure = create_xblock_info(
course_block,
include_child_info=True,
include_children_predicate=lambda xblock: not xblock.category == 'vertical'
include_children_predicate=lambda xblock: xblock.scope_ids.block_type != 'vertical'
)

# Verify that None is returned for a non-existent locator
Expand Down
4 changes: 2 additions & 2 deletions cms/djangoapps/contentstore/views/transcripts_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def validate_video_block(request, locator):
error, item = None, None
try:
item = _get_item(request, {'locator': locator})
if item.category != 'video':
if item.scope_ids.block_type != 'video':
error = _('Transcripts are supported only for "video" blocks.')

except (InvalidKeyError, ItemNotFoundError):
Expand Down Expand Up @@ -523,7 +523,7 @@ def _validate_transcripts_data(request):
except (InvalidKeyError, ItemNotFoundError):
raise TranscriptsRequestValidationException(_("Can't find item by locator.")) # lint-amnesty, pylint: disable=raise-missing-from

if item.category != 'video':
if item.scope_ids.block_type != 'video':
raise TranscriptsRequestValidationException(_('Transcripts are supported only for "video" blocks.'))

# parse data form request.GET.['data']['video'] to useful format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def _save_xblock(
)

# Save gating info
if xblock.category == "sequential" and course.enable_subsection_gating:
if xblock.scope_ids.block_type == "sequential" and course.enable_subsection_gating:
if is_prereq is not None:
if is_prereq:
gating_api.add_prerequisite(
Expand All @@ -601,7 +601,7 @@ def _save_xblock(
# If publish is set to 'republish' and this item is not in direct only categories and has previously been
# published, then this item should be republished. This is used by staff locking to ensure that changing the
# draft value of the staff lock will also update the published version, but only at the unit level.
if publish == "republish" and xblock.category not in DIRECT_ONLY_CATEGORIES:
if publish == "republish" and xblock.scope_ids.block_type not in DIRECT_ONLY_CATEGORIES:
if modulestore().has_published_version(xblock):
publish = "make_public"

Expand All @@ -610,7 +610,7 @@ def _save_xblock(
modulestore().publish(xblock.location, user.id)

# If summary_configuration_enabled is not None, use AIAsideSummary to update it.
if xblock.category == "vertical" and summary_configuration_enabled is not None:
if xblock.scope_ids.block_type == "vertical" and summary_configuration_enabled is not None:
AiAsideSummaryConfig(course.id).set_summary_settings(xblock.location, {
'enabled': summary_configuration_enabled
})
Expand Down Expand Up @@ -883,8 +883,8 @@ def _move_item(source_usage_key, target_parent_usage_key, user, target_index=Non
source_item = store.get_item(source_usage_key)
source_parent = source_item.get_parent()
target_parent = store.get_item(target_parent_usage_key)
source_type = source_item.category
target_parent_type = target_parent.category
source_type = source_item.scope_ids.block_type
target_parent_type = target_parent.scope_ids.block_type
error = None

# Store actual/initial index of the source item. This would be sent back with response,
Expand Down Expand Up @@ -1102,7 +1102,7 @@ def _get_gating_info(course, xblock):
dict: Gating information
"""
info = {}
if xblock.category == "sequential" and course.enable_subsection_gating:
if xblock.scope_ids.block_type == "sequential" and course.enable_subsection_gating:
if not hasattr(course, "gating_prerequisites"):
# Cache gating prerequisites on course block so that we are not
# hitting the database for every xblock in the course
Expand Down Expand Up @@ -1211,7 +1211,7 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements

release_date = _get_release_date(xblock, user)

if xblock.category != "course" and not is_concise:
if xblock.scope_ids.block_type != "course" and not is_concise:
visibility_state = _compute_visibility_state(
xblock, child_info, is_xblock_unit and has_changes, is_self_paced(course)
)
Expand Down Expand Up @@ -1240,7 +1240,7 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements
explanatory_message = None

# is_entrance_exam is inherited metadata.
if xblock.category == "chapter" and getattr(xblock, "is_entrance_exam", None):
if xblock.scope_ids.block_type == "chapter" and getattr(xblock, "is_entrance_exam", None):
# Entrance exam section should not be deletable, draggable and not have 'New Subsection' button.
xblock_actions["deletable"] = xblock_actions["childAddable"] = xblock_actions[
"draggable"
Expand All @@ -1263,7 +1263,7 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements
xblock_info = {
"id": str(xblock.location),
"display_name": xblock.display_name_with_default,
"category": xblock.category,
"category": xblock.scope_ids.block_type,
"has_children": xblock.has_children,
}

Expand All @@ -1278,7 +1278,7 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements
}
)

if xblock.category == "course":
if xblock.scope_ids.block_type == "course":
discussions_config = DiscussionsConfiguration.get(course.id)
show_unit_level_discussions_toggle = (
discussions_config.enabled
Expand Down Expand Up @@ -1336,20 +1336,20 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements
}
)

if xblock.category == "sequential":
if xblock.scope_ids.block_type == "sequential":
xblock_info.update(
{
"hide_after_due": xblock.hide_after_due,
}
)
elif xblock.category in ("chapter", "course"):
if xblock.category == "chapter":
elif xblock.scope_ids.block_type in ("chapter", "course"):
if xblock.scope_ids.block_type == "chapter":
xblock_info.update(
{
"highlights": xblock.highlights,
}
)
elif xblock.category == "course":
elif xblock.scope_ids.block_type == "course":
xblock_info.update(
{
"highlights_enabled_for_messaging": course.highlights_enabled_for_messaging,
Expand All @@ -1370,15 +1370,15 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements

# update xblock_info with special exam information if the feature flag is enabled
if settings.FEATURES.get("ENABLE_SPECIAL_EXAMS"):
if xblock.category == "course":
if xblock.scope_ids.block_type == "course":
xblock_info.update(
{
"enable_proctored_exams": xblock.enable_proctored_exams,
"create_zendesk_tickets": xblock.create_zendesk_tickets,
"enable_timed_exams": xblock.enable_timed_exams,
}
)
elif xblock.category == "sequential":
elif xblock.scope_ids.block_type == "sequential":
rules_url = settings.PROCTORING_SETTINGS.get("LINK_URLS", {}).get(
"online_proctoring_rules", ""
)
Expand Down Expand Up @@ -1441,7 +1441,7 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements
# if xblock is a Unit we add the discussion_enabled option
xblock_info["discussion_enabled"] = xblock.discussion_enabled

if xblock.category == "sequential":
if xblock.scope_ids.block_type == "sequential":
# Entrance exam subsection should be hidden. in_entrance_exam is
# inherited metadata, all children will have it.
if getattr(xblock, "in_entrance_exam", False):
Expand Down
Loading
Loading