Commit 7d2d0657 by Brandon Baker Committed by GitHub

Merge pull request #15290 from edx/bbaker/educator-344

Bbaker/educator 344
parents 54eb9e84 6b62bf9b
...@@ -87,9 +87,8 @@ class PartitionService(object): ...@@ -87,9 +87,8 @@ class PartitionService(object):
with a given course. 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._course_id = course_id
self._track_function = track_function
self._cache = cache self._cache = cache
def get_course(self): def get_course(self):
...@@ -165,7 +164,7 @@ class PartitionService(object): ...@@ -165,7 +164,7 @@ class PartitionService(object):
the partition's scheme. the partition's scheme.
""" """
return user_partition.scheme.get_group_for_user( 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,
) )
......
...@@ -96,7 +96,7 @@ class MockUserPartitionScheme(object): ...@@ -96,7 +96,7 @@ class MockUserPartitionScheme(object):
self.name = name self.name = name
self.current_group = current_group 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. Returns the current group if set, else the first group from the specified user partition.
""" """
...@@ -446,7 +446,6 @@ class PartitionServiceBaseClass(PartitionTestCase): ...@@ -446,7 +446,6 @@ class PartitionServiceBaseClass(PartitionTestCase):
return MockPartitionService( return MockPartitionService(
self.course, self.course,
course_id=self.course.id, course_id=self.course.id,
track_function=Mock(),
cache=cache cache=cache
) )
......
...@@ -96,7 +96,6 @@ class SplitTestModuleTest(XModuleXmlImportTest, PartitionTestCase): ...@@ -96,7 +96,6 @@ class SplitTestModuleTest(XModuleXmlImportTest, PartitionTestCase):
partitions_service = MockPartitionService( partitions_service = MockPartitionService(
self.course, self.course,
course_id=self.course.id, course_id=self.course.id,
track_function=Mock(name='track_function'),
) )
self.module_system._services['partitions'] = partitions_service # pylint: disable=protected-access self.module_system._services['partitions'] = partitions_service # pylint: disable=protected-access
......
...@@ -30,7 +30,7 @@ class MemoryUserPartitionScheme(object): ...@@ -30,7 +30,7 @@ class MemoryUserPartitionScheme(object):
""" """
self.current_group.setdefault(user.id, {})[user_partition.id] = group 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. Fetch the group to which this user is linked in this partition, or None.
""" """
......
...@@ -600,7 +600,7 @@ class TestGradeReportConditionalContent(TestReportMixin, TestConditionalContent, ...@@ -600,7 +600,7 @@ class TestGradeReportConditionalContent(TestReportMixin, TestConditionalContent,
group_config_hdr_tpl = 'Experiment Group ({})' group_config_hdr_tpl = 'Experiment Group ({})'
return { return {
group_config_hdr_tpl.format(self.partition.name): self.partition.scheme.get_group_for_user( 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 ).name
} }
......
...@@ -139,7 +139,6 @@ class LmsModuleSystem(ModuleSystem): # pylint: disable=abstract-method ...@@ -139,7 +139,6 @@ class LmsModuleSystem(ModuleSystem): # pylint: disable=abstract-method
services['library_tools'] = LibraryToolsService(modulestore()) services['library_tools'] = LibraryToolsService(modulestore())
services['partitions'] = PartitionService( services['partitions'] = PartitionService(
course_id=kwargs.get('course_id'), course_id=kwargs.get('course_id'),
track_function=kwargs.get('track_function', None),
cache=request_cache_dict cache=request_cache_dict
) )
store = modulestore() store = modulestore()
......
...@@ -25,7 +25,7 @@ class CohortPartitionScheme(object): ...@@ -25,7 +25,7 @@ class CohortPartitionScheme(object):
# pylint: disable=unused-argument # pylint: disable=unused-argument
@classmethod @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 Returns the Group from the specified user partition to which the user
is assigned, via their cohort membership and any mappings from cohorts is assigned, via their cohort membership and any mappings from cohorts
......
...@@ -5,6 +5,8 @@ import logging ...@@ -5,6 +5,8 @@ import logging
import random import random
import course_tag.api as course_tag_api import course_tag.api as course_tag_api
from eventtracking import tracker
from xmodule.partitions.partitions import UserPartitionError, NoSuchUserPartitionGroupError from xmodule.partitions.partitions import UserPartitionError, NoSuchUserPartitionGroupError
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -17,7 +19,7 @@ class NotImplementedPartitionScheme(object): ...@@ -17,7 +19,7 @@ class NotImplementedPartitionScheme(object):
""" """
@classmethod @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 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 using this partition scheme", be sure the scheme you're removing is
...@@ -31,7 +33,7 @@ class ReturnGroup1PartitionScheme(object): ...@@ -31,7 +33,7 @@ class ReturnGroup1PartitionScheme(object):
This scheme is needed to allow verification partitions to be killed, see EDUCATOR-199 This scheme is needed to allow verification partitions to be killed, see EDUCATOR-199
""" """
@classmethod @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. 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 Details at https://github.com/edx/edx-platform/pull/14913/files#diff-feff1466ec4d1b8c38894310d8342a80
...@@ -46,7 +48,7 @@ class RandomUserPartitionScheme(object): ...@@ -46,7 +48,7 @@ class RandomUserPartitionScheme(object):
RANDOM = random.Random() RANDOM = random.Random()
@classmethod @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. 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. If the user has not yet been assigned, a group will be randomly chosen for them if assign flag is True.
...@@ -83,11 +85,11 @@ class RandomUserPartitionScheme(object): ...@@ -83,11 +85,11 @@ class RandomUserPartitionScheme(object):
# persist the value as a course tag # persist the value as a course tag
course_tag_api.set_course_tag(user, course_key, partition_key, group.id) course_tag_api.set_course_tag(user, course_key, partition_key, group.id)
if track_function:
# emit event for analytics # emit event for analytics
# FYI - context is always user ID that is logged in, NOT the user id that is # 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 # being operated on. If instructor can move user explicitly, then we should
# put in event_info the user id that is being operated on. # put in event_info the user id that is being operated on.
event_name = 'xmodule.partitions.assigned_user_to_partition'
event_info = { event_info = {
'group_id': group.id, 'group_id': group.id,
'group_name': group.name, 'group_name': group.name,
...@@ -96,7 +98,11 @@ class RandomUserPartitionScheme(object): ...@@ -96,7 +98,11 @@ class RandomUserPartitionScheme(object):
} }
# pylint: disable=fixme # pylint: disable=fixme
# TODO: Use the XBlock publish api instead # TODO: Use the XBlock publish api instead
track_function('xmodule.partitions.assigned_user_to_partition', event_info) with tracker.get_tracker().context(event_name, {}):
tracker.emit(
event_name,
event_info,
)
return group return group
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment