From 4ded4be700f5b22b48af2fc6fbabcf0ac802859c Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 14 Jul 2014 14:34:43 -0400 Subject: [PATCH] Fix calls to get_module to not pass course ids as positions --- lms/djangoapps/courseware/courses.py | 2 -- lms/djangoapps/courseware/module_render.py | 8 ++++++++ .../courseware/tests/test_module_render.py | 18 ++---------------- lms/djangoapps/courseware/views.py | 2 +- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 86ec963a71..724efc1989 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -187,7 +187,6 @@ def get_course_about_section(course, section_key): request, loc, field_data_cache, - course.id, log_if_not_found=False, wrap_xmodule_display=False, static_asset_path=course.static_asset_path @@ -241,7 +240,6 @@ def get_course_info_section(request, course, section_key): request, usage_key, field_data_cache, - course.id, log_if_not_found=False, wrap_xmodule_display=False, static_asset_path=course.static_asset_path diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index f3130e7745..d162467b9c 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -504,7 +504,15 @@ def get_module_system_for_user(user, field_data_cache, ) # pass position specified in URL to module through ModuleSystem + if position is not None: + try: + position = int(position) + except (ValueError, TypeError): + log.exception('Non-integer %r passed as position.', position) + position = None + system.set('position', position) + if settings.FEATURES.get('ENABLE_PSYCHOMETRICS'): system.set( 'psychometrics_handler', # set callback for updating PsychometricsData diff --git a/lms/djangoapps/courseware/tests/test_module_render.py b/lms/djangoapps/courseware/tests/test_module_render.py index 8933a83e7e..40d3d64797 100644 --- a/lms/djangoapps/courseware/tests/test_module_render.py +++ b/lms/djangoapps/courseware/tests/test_module_render.py @@ -68,7 +68,7 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase): def test_get_module(self): self.assertEqual( None, - render.get_module('dummyuser', None, 'invalid location', None, None) + render.get_module('dummyuser', None, 'invalid location', None) ) def test_module_render_with_jump_to_id(self): @@ -90,7 +90,6 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase): mock_request, self.course_key.make_usage_key('html', 'toyjumpto'), field_data_cache, - self.course_key ) # get the rendered HTML output which should have the rewritten link @@ -414,7 +413,6 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.request, self.location, self.field_data_cache, - self.course.id, wrap_xmodule_display=True, ) result_fragment = module.render(STUDENT_VIEW) @@ -427,7 +425,6 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.request, self.location, self.field_data_cache, - self.course.id, wrap_xmodule_display=False, ) result_fragment = module.render(STUDENT_VIEW) @@ -440,7 +437,6 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.request, self.location, self.field_data_cache, - self.course.id, ) result_fragment = module.render(STUDENT_VIEW) @@ -458,7 +454,6 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.request, self.location, self.field_data_cache, - self.course.id, ) result_fragment = module.render(STUDENT_VIEW) @@ -481,7 +476,6 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.request, self.location, self.field_data_cache, - self.course.id, static_asset_path="toy_course_dir", ) result_fragment = module.render(STUDENT_VIEW) @@ -508,7 +502,6 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.request, self.location, self.field_data_cache, - self.course.id, ) result_fragment = module.render(STUDENT_VIEW) @@ -546,7 +539,6 @@ class ViewInStudioTest(ModuleStoreTestCase): self.request, location, field_data_cache, - course_id, ) def setup_mongo_course(self, course_edit_method='Studio'): @@ -693,7 +685,6 @@ class TestStaffDebugInfo(ModuleStoreTestCase): self.request, self.location, self.field_data_cache, - self.course.id, ) result_fragment = module.render(STUDENT_VIEW) self.assertNotIn('Staff Debug', result_fragment.content) @@ -704,7 +695,6 @@ class TestStaffDebugInfo(ModuleStoreTestCase): self.request, self.location, self.field_data_cache, - self.course.id, ) result_fragment = module.render(STUDENT_VIEW) self.assertIn('Staff Debug', result_fragment.content) @@ -716,7 +706,6 @@ class TestStaffDebugInfo(ModuleStoreTestCase): self.request, self.location, self.field_data_cache, - self.course.id, ) result_fragment = module.render(STUDENT_VIEW) self.assertNotIn('histrogram', result_fragment.content) @@ -740,7 +729,6 @@ class TestStaffDebugInfo(ModuleStoreTestCase): self.request, html_descriptor.location, field_data_cache, - self.course.id, ) module.render(STUDENT_VIEW) self.assertFalse(mock_grade_histogram.called) @@ -763,7 +751,6 @@ class TestStaffDebugInfo(ModuleStoreTestCase): self.request, self.location, self.field_data_cache, - self.course.id, ) module.render(STUDENT_VIEW) self.assertTrue(mock_grade_histogram.called) @@ -929,7 +916,6 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems): mock_request, self.problem.location, field_data_cache, - self.course.id )._xmodule def set_module_grade_using_publish(self, grade_dict): @@ -978,7 +964,7 @@ class TestRebindModule(TestSubmittingProblems): mock_request, self.lti.location, field_data_cache, - self.course.id)._xmodule + )._xmodule def test_rebind_noauth_module_to_user_not_anonymous(self): """ diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 2ddb4b3b1f..d5434406da 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -870,7 +870,7 @@ def get_static_tab_contents(request, course, tab): course.id, request.user, modulestore().get_item(loc), depth=0 ) tab_module = get_module( - request.user, request, loc, field_data_cache, course.id, static_asset_path=course.static_asset_path + request.user, request, loc, field_data_cache, static_asset_path=course.static_asset_path ) logging.debug('course_module = {0}'.format(tab_module))