Skip to content

Commit

Permalink
refactor: cleaning build_object_tree_with_objecttags function
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Feb 16, 2024
1 parent a153ec9 commit 610c01a
Showing 1 changed file with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,12 @@ def build_object_tree_with_objecttags(
tagged_content, children = _get_course_tagged_object_and_children(
content_key, object_tag_cache
)
get_tagged_children = _get_xblock_tagged_object_and_children
elif isinstance(content_key, LibraryLocatorV2):
tagged_content, children = _get_library_tagged_object_and_children(
content_key, object_tag_cache
)
get_tagged_children = _get_library_block_tagged_object
else:
raise ValueError(f"Invalid content_key: {type(content_key)} -> {content_key}")

Expand All @@ -161,19 +163,8 @@ def build_object_tree_with_objecttags(
for child in block_children:
child_children: list | None

if isinstance(child, UsageKey):
tagged_child, child_children = _get_xblock_tagged_object_and_children(
child, object_tag_cache
)
elif isinstance(child, LibraryXBlockMetadata):
tagged_child, child_children = _get_library_block_tagged_object(
child, object_tag_cache
)
else:
raise NotImplementedError(f"Invalid child: {type(child)} -> {child}")

tagged_child, child_children = get_tagged_children(child, object_tag_cache)
tagged_block.children.append(tagged_child)

blocks.append((tagged_child, child_children))

return tagged_content

0 comments on commit 610c01a

Please sign in to comment.