Skip to content
Merged
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
14 changes: 7 additions & 7 deletions cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,20 @@ def reverse_usage_url(handler_name, usage_key, kwargs=None):
return reverse_url(handler_name, 'usage_key_string', usage_key, kwargs)


def get_group_display_name(user_partitions, xblock_display_name):
def get_split_group_display_name(xblock, course):
"""
Get the group name if matching group xblock is found.
Returns group name if an xblock is found in user partition groups that are suitable for the split_test module.

Arguments:
user_partitions (Dict): Locator of source item.
xblock_display_name (String): Display name of group xblock.
xblock (XBlock): The courseware component.
course (XBlock): The course descriptor.

Returns:
group name (String): Group name of the matching group.
group name (String): Group name of the matching group xblock.
"""
for user_partition in user_partitions:
for user_partition in get_user_partition_info(xblock, schemes=['random'], course=course):
for group in user_partition['groups']:
if str(group['id']) in xblock_display_name:
if 'Group ID {group_id}'.format(group_id=group['id']) == xblock.display_name_with_default:
return group['name']


Expand Down
6 changes: 3 additions & 3 deletions cms/djangoapps/contentstore/views/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from contentstore.utils import (
find_release_date_source, find_staff_lock_source, is_currently_visible_to_students,
ancestor_has_staff_lock, has_children_visible_to_specific_content_groups,
get_user_partition_info, get_group_display_name,
get_user_partition_info, get_split_group_display_name,
)
from contentstore.views.helpers import is_unit, xblock_studio_url, xblock_primary_child_category, \
xblock_type_display_name, get_parent_xblock, create_xblock, usage_key_with_run
Expand Down Expand Up @@ -1125,7 +1125,6 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
# a percent value out of 100, e.g. "58%" means "58/100".
pct_sign=_('%'))

user_partitions = get_user_partition_info(xblock, course=course)
xblock_info = {
'id': unicode(xblock.location),
'display_name': xblock.display_name_with_default,
Expand All @@ -1136,9 +1135,10 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
if child_info and len(child_info.get('children', [])) > 0:
xblock_info['child_info'] = child_info
# Groups are labelled with their internal ids, rather than with the group name. Replace id with display name.
group_display_name = get_group_display_name(user_partitions, xblock_info['display_name'])
group_display_name = get_split_group_display_name(xblock, course)
xblock_info['display_name'] = group_display_name if group_display_name else xblock_info['display_name']
else:
user_partitions = get_user_partition_info(xblock, course=course)
xblock_info.update({
'edited_on': get_default_time_display(xblock.subtree_edited_on) if xblock.subtree_edited_on else None,
'published': published,
Expand Down