Skip to content

Commit

Permalink
fix: Show tag count when paste a component in a course
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV committed Mar 3, 2025
1 parent cf7e45c commit a0d6476
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cms/djangoapps/contentstore/views/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ def xblock_view_handler(request, usage_key_string, view_name):

force_render = request.GET.get("force_render", None)

# Fetch tags of children components
# Fetch tags of xblock and children components
tags_count_map = {}
if not is_tagging_feature_disabled():
tags_count_map = get_children_tags_count(xblock)
tags_count_map = get_children_tags_count(xblock, get_parent=True)

# Set up the context to be passed to each XBlock's render method.
context = request.GET.dict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ def usage_key_with_run(usage_key_string):
return usage_key


def get_children_tags_count(xblock):
def get_children_tags_count(xblock, get_parent=False):
"""
Returns a map with tag count of each child
Use `get_parent` to also get the `xblock` tags in the same query
"""
children = xblock.get_children()
child_usage_keys = [str(child.location) for child in children]
tags_count_query = ','.join(child_usage_keys)

if (get_parent):
tags_count_query += f',{xblock.location}'

return get_object_tag_counts(tags_count_query, count_implicit=True)

0 comments on commit a0d6476

Please sign in to comment.