Commit 069e29a2 by Sarina Canelake

Merge pull request #4295 from mitocw/cg/psycho_require_auth

Check if user is anonymous before calling PSYCHOMETRICS
parents d6c188f9 87fa6cc7
...@@ -512,8 +512,7 @@ def get_module_system_for_user(user, field_data_cache, ...@@ -512,8 +512,7 @@ def get_module_system_for_user(user, field_data_cache,
position = None position = None
system.set('position', position) system.set('position', position)
if settings.FEATURES.get('ENABLE_PSYCHOMETRICS') and user.is_authenticated():
if settings.FEATURES.get('ENABLE_PSYCHOMETRICS'):
system.set( system.set(
'psychometrics_handler', # set callback for updating PsychometricsData 'psychometrics_handler', # set callback for updating PsychometricsData
make_psychometrics_data_update_handler(course_id, user, descriptor.location) make_psychometrics_data_update_handler(course_id, user, descriptor.location)
......
...@@ -998,3 +998,14 @@ class TestRebindModule(TestSubmittingProblems): ...@@ -998,3 +998,14 @@ class TestRebindModule(TestSubmittingProblems):
self.assertEqual(module.system.anonymous_student_id, anonymous_id_for_user(user2, self.course.id)) self.assertEqual(module.system.anonymous_student_id, anonymous_id_for_user(user2, self.course.id))
self.assertEqual(module.scope_ids.user_id, user2.id) self.assertEqual(module.scope_ids.user_id, user2.id)
self.assertEqual(module.descriptor.scope_ids.user_id, user2.id) self.assertEqual(module.descriptor.scope_ids.user_id, user2.id)
@patch('courseware.module_render.make_psychometrics_data_update_handler')
@patch.dict(settings.FEATURES, {'ENABLE_PSYCHOMETRICS': True})
def test_psychometrics_anonymous(self, psycho_handler):
"""
Make sure that noauth modules with anonymous users don't have
the psychometrics callback bound.
"""
module = self.get_module_for_user(self.anon_user)
module.system.rebind_noauth_module_to_user(module, self.anon_user)
self.assertFalse(psycho_handler.called)
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