From f4c9044d2e4ea9e75fd5c39b778f14c9d0d7cfb5 Mon Sep 17 00:00:00 2001 From: Brandon Baker Date: Fri, 9 Jun 2017 18:51:10 +0000 Subject: [PATCH] EDUCATOR-344 Removed instances of track function --- .../xmodule/partitions/partitions_service.py | 5 +-- .../partitions/tests/test_partitions.py | 3 +- .../courseware/tests/test_group_access.py | 2 +- .../instructor_task/tests/test_integration.py | 2 +- lms/djangoapps/lms_xblock/runtime.py | 1 - .../course_groups/partition_scheme.py | 2 +- .../djangoapps/user_api/partition_schemes.py | 43 +++++++++---------- 7 files changed, 27 insertions(+), 31 deletions(-) diff --git a/common/lib/xmodule/xmodule/partitions/partitions_service.py b/common/lib/xmodule/xmodule/partitions/partitions_service.py index 39c8dbe930..f302757b8b 100644 --- a/common/lib/xmodule/xmodule/partitions/partitions_service.py +++ b/common/lib/xmodule/xmodule/partitions/partitions_service.py @@ -87,9 +87,8 @@ class PartitionService(object): with a given course. """ - def __init__(self, course_id, track_function=None, cache=None): + def __init__(self, course_id, cache=None): self._course_id = course_id - self._track_function = track_function self._cache = cache def get_course(self): @@ -165,7 +164,7 @@ class PartitionService(object): the partition's scheme. """ return user_partition.scheme.get_group_for_user( - self._course_id, user, user_partition, assign=assign, track_function=self._track_function + self._course_id, user, user_partition, assign=assign, ) diff --git a/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py b/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py index 3b37bbb4d8..9df778df3d 100644 --- a/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py +++ b/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py @@ -96,7 +96,7 @@ class MockUserPartitionScheme(object): self.name = name self.current_group = current_group - def get_group_for_user(self, course_id, user, user_partition, assign=True, track_function=None): # pylint: disable=unused-argument + def get_group_for_user(self, course_id, user, user_partition, assign=True): # pylint: disable=unused-argument """ Returns the current group if set, else the first group from the specified user partition. """ @@ -446,7 +446,6 @@ class PartitionServiceBaseClass(PartitionTestCase): return MockPartitionService( self.course, course_id=self.course.id, - track_function=Mock(), cache=cache ) diff --git a/lms/djangoapps/courseware/tests/test_group_access.py b/lms/djangoapps/courseware/tests/test_group_access.py index a762e4d88b..0bab2f7c69 100644 --- a/lms/djangoapps/courseware/tests/test_group_access.py +++ b/lms/djangoapps/courseware/tests/test_group_access.py @@ -31,7 +31,7 @@ class MemoryUserPartitionScheme(object): """ self.current_group.setdefault(user.id, {})[user_partition.id] = group - def get_group_for_user(self, course_id, user, user_partition, track_function=None): # pylint: disable=unused-argument + def get_group_for_user(self, course_id, user, user_partition): # pylint: disable=unused-argument """ Fetch the group to which this user is linked in this partition, or None. """ diff --git a/lms/djangoapps/instructor_task/tests/test_integration.py b/lms/djangoapps/instructor_task/tests/test_integration.py index 96bbf1f8d9..f7e52470bb 100644 --- a/lms/djangoapps/instructor_task/tests/test_integration.py +++ b/lms/djangoapps/instructor_task/tests/test_integration.py @@ -604,7 +604,7 @@ class TestGradeReportConditionalContent(TestReportMixin, TestConditionalContent, group_config_hdr_tpl = 'Experiment Group ({})' return { group_config_hdr_tpl.format(self.partition.name): self.partition.scheme.get_group_for_user( - self.course.id, user, self.partition, track_function=None + self.course.id, user, self.partition ).name } diff --git a/lms/djangoapps/lms_xblock/runtime.py b/lms/djangoapps/lms_xblock/runtime.py index 58bf0f1f96..9a3720da2b 100644 --- a/lms/djangoapps/lms_xblock/runtime.py +++ b/lms/djangoapps/lms_xblock/runtime.py @@ -140,7 +140,6 @@ class LmsModuleSystem(ModuleSystem): # pylint: disable=abstract-method services['library_tools'] = LibraryToolsService(modulestore()) services['partitions'] = PartitionService( course_id=kwargs.get('course_id'), - track_function=kwargs.get('track_function', None), cache=request_cache_dict ) store = modulestore() diff --git a/openedx/core/djangoapps/course_groups/partition_scheme.py b/openedx/core/djangoapps/course_groups/partition_scheme.py index e47981a5f0..7fdfa92e7b 100644 --- a/openedx/core/djangoapps/course_groups/partition_scheme.py +++ b/openedx/core/djangoapps/course_groups/partition_scheme.py @@ -25,7 +25,7 @@ class CohortPartitionScheme(object): # pylint: disable=unused-argument @classmethod - def get_group_for_user(cls, course_key, user, user_partition, track_function=None, use_cached=True): + def get_group_for_user(cls, course_key, user, user_partition, use_cached=True): """ Returns the Group from the specified user partition to which the user is assigned, via their cohort membership and any mappings from cohorts diff --git a/openedx/core/djangoapps/user_api/partition_schemes.py b/openedx/core/djangoapps/user_api/partition_schemes.py index b2bf27977e..91f13aea41 100644 --- a/openedx/core/djangoapps/user_api/partition_schemes.py +++ b/openedx/core/djangoapps/user_api/partition_schemes.py @@ -19,7 +19,7 @@ class NotImplementedPartitionScheme(object): """ @classmethod - def get_group_for_user(cls, course_key, user, user_partition, assign=True, track_function=None): # pylint: disable=unused-argument + def get_group_for_user(cls, course_key, user, user_partition, assign=True): # pylint: disable=unused-argument """ Returning None is equivalent to saying "This user is not in any groups using this partition scheme", be sure the scheme you're removing is @@ -33,7 +33,7 @@ class ReturnGroup1PartitionScheme(object): This scheme is needed to allow verification partitions to be killed, see EDUCATOR-199 """ @classmethod - def get_group_for_user(cls, course_key, user, user_partition, assign=True, track_function=None): # pylint: disable=unused-argument + def get_group_for_user(cls, course_key, user, user_partition, assign=True): # pylint: disable=unused-argument """ The previous "allow" definition for verification was defined as 1, so return that. Details at https://github.com/edx/edx-platform/pull/14913/files#diff-feff1466ec4d1b8c38894310d8342a80 @@ -48,7 +48,7 @@ class RandomUserPartitionScheme(object): RANDOM = random.Random() @classmethod - def get_group_for_user(cls, course_key, user, user_partition, assign=True, track_function=None): + def get_group_for_user(cls, course_key, user, user_partition, assign=True): """ Returns the group from the specified user position to which the user is assigned. If the user has not yet been assigned, a group will be randomly chosen for them if assign flag is True. @@ -85,25 +85,24 @@ class RandomUserPartitionScheme(object): # persist the value as a course tag course_tag_api.set_course_tag(user, course_key, partition_key, group.id) - if track_function: - # emit event for analytics - # FYI - context is always user ID that is logged in, NOT the user id that is - # being operated on. If instructor can move user explicitly, then we should - # put in event_info the user id that is being operated on. - event_name = 'xmodule.partitions.assigned_user_to_partition' - event_info = { - 'group_id': group.id, - 'group_name': group.name, - 'partition_id': user_partition.id, - 'partition_name': user_partition.name - } - # pylint: disable=fixme - # TODO: Use the XBlock publish api instead - with tracker.get_tracker().context(event_name, {}): - tracker.emit( - event_name, - event_info, - ) + # emit event for analytics + # FYI - context is always user ID that is logged in, NOT the user id that is + # being operated on. If instructor can move user explicitly, then we should + # put in event_info the user id that is being operated on. + event_name = 'xmodule.partitions.assigned_user_to_partition' + event_info = { + 'group_id': group.id, + 'group_name': group.name, + 'partition_id': user_partition.id, + 'partition_name': user_partition.name + } + # pylint: disable=fixme + # TODO: Use the XBlock publish api instead + with tracker.get_tracker().context(event_name, {}): + tracker.emit( + event_name, + event_info, + ) return group