From 658810a94fc4fc9554b5711092a4ccf91ff2293f Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 4 Oct 2013 16:47:03 -0400 Subject: [PATCH] Use xblock render shortcuts --- cms/djangoapps/contentstore/views/preview.py | 4 +- .../lib/xmodule/xmodule/conditional_module.py | 2 +- .../lib/xmodule/xmodule/crowdsource_hinter.py | 2 +- .../lib/xmodule/xmodule/randomize_module.py | 2 +- common/lib/xmodule/xmodule/seq_module.py | 2 +- .../xmodule/tests/test_combined_open_ended.py | 54 +++++++++---------- .../xmodule/xmodule/tests/test_conditional.py | 7 ++- .../xmodule/tests/test_crowdsource_hinter.py | 6 +-- .../xmodule/tests/test_error_module.py | 8 +-- .../xmodule/tests/test_xblock_wrappers.py | 8 +-- .../lib/xmodule/xmodule/timelimit_module.py | 2 +- common/lib/xmodule/xmodule/vertical_module.py | 2 +- common/lib/xmodule/xmodule/x_module.py | 6 +-- lms/djangoapps/courseware/courses.py | 4 +- lms/djangoapps/courseware/tabs.py | 2 +- lms/djangoapps/courseware/tests/test_lti.py | 2 +- .../courseware/tests/test_module_render.py | 16 +++--- .../courseware/tests/test_timelimit_module.py | 4 +- .../courseware/tests/test_video_mongo.py | 4 +- .../courseware/tests/test_video_xml.py | 2 +- .../courseware/tests/test_word_cloud.py | 2 +- lms/djangoapps/courseware/views.py | 2 +- lms/djangoapps/instructor/views/legacy.py | 2 +- requirements/edx/github.txt | 2 +- 24 files changed, 75 insertions(+), 72 deletions(-) diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 7e55d97899..eb2d92880d 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -81,7 +81,7 @@ def preview_component(request, location): return render_to_response('component.html', { 'preview': get_preview_html(request, component, 0), - 'editor': component.runtime.render(component, None, 'studio_view').content, + 'editor': component.render('studio_view').content, }) @@ -157,4 +157,4 @@ def get_preview_html(request, descriptor, idx): specified by the descriptor and idx. """ module = load_preview_module(request, str(idx), descriptor) - return module.runtime.render(module, None, "student_view").content + return module.render("student_view").content diff --git a/common/lib/xmodule/xmodule/conditional_module.py b/common/lib/xmodule/xmodule/conditional_module.py index 03eea40ee3..f80184832f 100644 --- a/common/lib/xmodule/xmodule/conditional_module.py +++ b/common/lib/xmodule/xmodule/conditional_module.py @@ -149,7 +149,7 @@ class ConditionalModule(ConditionalFields, XModule): context) return json.dumps({'html': [html], 'message': bool(message)}) - html = [self.runtime.render_child(child, None, 'student_view').content for child in self.get_display_items()] + html = [child.render('student_view').content for child in self.get_display_items()] return json.dumps({'html': html}) diff --git a/common/lib/xmodule/xmodule/crowdsource_hinter.py b/common/lib/xmodule/xmodule/crowdsource_hinter.py index 8c2ea8a743..62bfe5b586 100644 --- a/common/lib/xmodule/xmodule/crowdsource_hinter.py +++ b/common/lib/xmodule/xmodule/crowdsource_hinter.py @@ -113,7 +113,7 @@ class CrowdsourceHinterModule(CrowdsourceHinterFields, XModule): try: child = self.get_display_items()[0] - out = self.runtime.render_child(child, None, 'student_view').content + out = child.render('student_view').content # The event listener uses the ajax url to find the child. child_id = child.id except IndexError: diff --git a/common/lib/xmodule/xmodule/randomize_module.py b/common/lib/xmodule/xmodule/randomize_module.py index 0cc853fd90..b53e44768b 100644 --- a/common/lib/xmodule/xmodule/randomize_module.py +++ b/common/lib/xmodule/xmodule/randomize_module.py @@ -82,7 +82,7 @@ class RandomizeModule(RandomizeFields, XModule): # raise error instead? In fact, could complain on descriptor load... return u"
Nothing to randomize between
" - return self.runtime.render_child(self.child, None, 'student_view').content + return self.child.render('student_view').content def get_icon_class(self): return self.child.get_icon_class() if self.child else 'other' diff --git a/common/lib/xmodule/xmodule/seq_module.py b/common/lib/xmodule/xmodule/seq_module.py index 103311dcb5..bb4acfdf11 100644 --- a/common/lib/xmodule/xmodule/seq_module.py +++ b/common/lib/xmodule/xmodule/seq_module.py @@ -79,7 +79,7 @@ class SequenceModule(SequenceFields, XModule): for child in self.get_display_items(): progress = child.get_progress() childinfo = { - 'content': self.runtime.render_child(child, None, 'student_view').content, + 'content': child.render('student_view').content, 'title': "\n".join( grand_child.display_name for grand_child in child.get_children() diff --git a/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py b/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py index bb7015ecaf..9aa5aeb5ce 100644 --- a/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py +++ b/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py @@ -519,7 +519,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase): """ See if we can get the max score from the actual xmodule """ - #The progress view requires that this function be exposed + # The progress view requires that this function be exposed max_score = self.combinedoe_container.max_score() self.assertEqual(max_score, None) @@ -751,7 +751,7 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore): assessment = [0, 1] module = self.get_module_from_location(self.problem_location, COURSE) - #Simulate a student saving an answer + # Simulate a student saving an answer html = module.handle_ajax("get_html", {}) module.save() module.handle_ajax("save_answer", {"student_answer": self.answer}) @@ -759,7 +759,7 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore): html = module.handle_ajax("get_html", {}) module.save() - #Mock a student submitting an assessment + # Mock a student submitting an assessment assessment_dict = MockQueryDict() assessment_dict.update({'assessment': sum(assessment), 'score_list[]': assessment}) module.handle_ajax("save_assessment", assessment_dict) @@ -769,12 +769,12 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore): rubric = module.handle_ajax("get_combined_rubric", {}) module.save() - #Move to the next step in the problem + # Move to the next step in the problem module.handle_ajax("next_problem", {}) module.save() self.assertEqual(module.current_task_number, 0) - html = module.runtime.render(module, None, 'student_view').content + html = module.render('student_view').content self.assertIsInstance(html, basestring) rubric = module.handle_ajax("get_combined_rubric", {}) @@ -792,17 +792,17 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore): @return: """ assessment = [1, 1] - #Load the module + # Load the module module = self.get_module_from_location(self.problem_location, COURSE) - #Simulate a student saving an answer + # Simulate a student saving an answer module.handle_ajax("save_answer", {"student_answer": self.answer}) module.save() status = module.handle_ajax("get_status", {}) module.save() self.assertIsInstance(status, basestring) - #Mock a student submitting an assessment + # Mock a student submitting an assessment assessment_dict = MockQueryDict() assessment_dict.update({'assessment': sum(assessment), 'score_list[]': assessment}) module.handle_ajax("save_assessment", assessment_dict) @@ -810,25 +810,25 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore): task_one_json = json.loads(module.task_states[0]) self.assertEqual(json.loads(task_one_json['child_history'][0]['post_assessment']), assessment) - #Move to the next step in the problem + # Move to the next step in the problem try: module.handle_ajax("next_problem", {}) module.save() except GradingServiceError: - #This error is okay. We don't have a grading service to connect to! + # This error is okay. We don't have a grading service to connect to! pass self.assertEqual(module.current_task_number, 1) try: - module.runtime.render(module, None, 'student_view') + module.render('student_view') except GradingServiceError: - #This error is okay. We don't have a grading service to connect to! + # This error is okay. We don't have a grading service to connect to! pass - #Try to get the rubric from the module + # Try to get the rubric from the module module.handle_ajax("get_combined_rubric", {}) module.save() - #Make a fake reply from the queue + # Make a fake reply from the queue queue_reply = { 'queuekey': "", 'xqueue_body': json.dumps({ @@ -847,23 +847,23 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore): module.handle_ajax("check_for_score", {}) module.save() - #Update the module with the fake queue reply + # Update the module with the fake queue reply module.handle_ajax("score_update", queue_reply) module.save() self.assertFalse(module.ready_to_reset) self.assertEqual(module.current_task_number, 1) - #Get html and other data client will request - module.runtime.render(module, None, 'student_view') + # Get html and other data client will request + module.render('student_view') module.handle_ajax("skip_post_assessment", {}) module.save() - #Get all results + # Get all results module.handle_ajax("get_combined_rubric", {}) module.save() - #reset the problem + # reset the problem module.handle_ajax("reset", {}) module.save() self.assertEqual(module.state, "initial") @@ -896,11 +896,11 @@ class OpenEndedModuleXmlAttemptTest(unittest.TestCase, DummyModulestore): module = self.get_module_from_location(self.problem_location, COURSE) module.save() - #Simulate a student saving an answer + # Simulate a student saving an answer module.handle_ajax("save_answer", {"student_answer": self.answer}) module.save() - #Mock a student submitting an assessment + # Mock a student submitting an assessment assessment_dict = MockQueryDict() assessment_dict.update({'assessment': sum(assessment), 'score_list[]': assessment}) module.handle_ajax("save_assessment", assessment_dict) @@ -908,21 +908,21 @@ class OpenEndedModuleXmlAttemptTest(unittest.TestCase, DummyModulestore): task_one_json = json.loads(module.task_states[0]) self.assertEqual(json.loads(task_one_json['child_history'][0]['post_assessment']), assessment) - #Move to the next step in the problem + # Move to the next step in the problem module.handle_ajax("next_problem", {}) module.save() self.assertEqual(module.current_task_number, 0) - html = module.runtime.render(module, None, 'student_view').content + html = module.render('student_view').content self.assertIsInstance(html, basestring) - #Module should now be done + # Module should now be done rubric = module.handle_ajax("get_combined_rubric", {}) module.save() self.assertIsInstance(rubric, basestring) self.assertEqual(module.state, "done") - #Try to reset, should fail because only 1 attempt is allowed + # Try to reset, should fail because only 1 attempt is allowed reset_data = json.loads(module.handle_ajax("reset", {})) module.save() self.assertEqual(reset_data['success'], False) @@ -953,7 +953,7 @@ class OpenEndedModuleXmlImageUploadTest(unittest.TestCase, DummyModulestore): """ module = self.get_module_from_location(self.problem_location, COURSE) - #Simulate a student saving an answer + # Simulate a student saving an answer response = module.handle_ajax("save_answer", {"student_answer": self.answer_text}) response = json.loads(response) self.assertFalse(response['success']) @@ -973,7 +973,7 @@ class OpenEndedModuleXmlImageUploadTest(unittest.TestCase, DummyModulestore): """ module = self.get_module_from_location(self.problem_location, COURSE) - #Simulate a student saving an answer with a file + # Simulate a student saving an answer with a file response = module.handle_ajax("save_answer", { "student_answer": self.answer_text, "valid_files_attached": True, diff --git a/common/lib/xmodule/xmodule/tests/test_conditional.py b/common/lib/xmodule/xmodule/tests/test_conditional.py index 742f37c94f..8771af3db7 100644 --- a/common/lib/xmodule/xmodule/tests/test_conditional.py +++ b/common/lib/xmodule/xmodule/tests/test_conditional.py @@ -70,13 +70,16 @@ class ConditionalFactory(object): source_descriptor.location = source_location source_descriptor.runtime = descriptor_system + source_descriptor.render = lambda view, context=None: descriptor_system.render(source_descriptor, view, context) # construct other descriptors: child_descriptor = Mock() child_descriptor._xmodule.student_view.return_value.content = u'

This is a secret

' + child_descriptor.student_view = child_descriptor._xmodule.student_view child_descriptor.displayable_items.return_value = [child_descriptor] child_descriptor.runtime = descriptor_system child_descriptor.xmodule_runtime = get_test_system() + child_descriptor.render = lambda view, context=None: descriptor_system.render(child_descriptor, view, context) descriptor_system.load_item = {'child': child_descriptor, 'source': source_descriptor}.get @@ -125,7 +128,7 @@ class ConditionalModuleBasicTest(unittest.TestCase): modules = ConditionalFactory.create(self.test_system) # because get_test_system returns the repr of the context dict passed to render_template, # we reverse it here - html = modules['cond_module'].runtime.render(modules['cond_module'], None, 'student_view').content + html = modules['cond_module'].render('student_view').content expected = modules['cond_module'].xmodule_runtime.render_template('conditional_ajax.html', { 'ajax_url': modules['cond_module'].xmodule_runtime.ajax_url, 'element_id': 'i4x-edX-conditional_test-conditional-SampleConditional', @@ -216,7 +219,7 @@ class ConditionalModuleXmlTest(unittest.TestCase): print "module children: ", module.get_children() print "module display items (children): ", module.get_display_items() - html = module.runtime.render(module, None, 'student_view').content + html = module.render('student_view').content print "html type: ", type(html) print "html: ", html html_expect = module.xmodule_runtime.render_template( diff --git a/common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py b/common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py index 0757732f3f..33fc264ff9 100644 --- a/common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py +++ b/common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py @@ -243,7 +243,7 @@ class CrowdsourceHinterTest(unittest.TestCase): """ return [FakeChild()] mock_module.get_display_items = fake_get_display_items - out_html = mock_module.runtime.render(mock_module, None, 'student_view').content + out_html = mock_module.render('student_view').content self.assertTrue('This is supposed to be test html.' in out_html) self.assertTrue('i4x://this/is/a/fake/id' in out_html) @@ -260,7 +260,7 @@ class CrowdsourceHinterTest(unittest.TestCase): """ return [] mock_module.get_display_items = fake_get_display_items - out_html = mock_module.runtime.render(mock_module, None, 'student_view').content + out_html = mock_module.render('student_view').content self.assertTrue('Error in loading crowdsourced hinter' in out_html) @unittest.skip("Needs to be finished.") @@ -271,7 +271,7 @@ class CrowdsourceHinterTest(unittest.TestCase): NOT WORKING RIGHT NOW """ mock_module = VerticalWithModulesFactory.create() - out_html = mock_module.runtime.render(mock_module, None, 'student_view').content + out_html = mock_module.render('student_view').content self.assertTrue('Test numerical problem.' in out_html) self.assertTrue('Another test numerical problem.' in out_html) diff --git a/common/lib/xmodule/xmodule/tests/test_error_module.py b/common/lib/xmodule/xmodule/tests/test_error_module.py index 5b898aa6f8..ce2f68754c 100644 --- a/common/lib/xmodule/xmodule/tests/test_error_module.py +++ b/common/lib/xmodule/xmodule/tests/test_error_module.py @@ -31,7 +31,7 @@ class TestErrorModule(unittest.TestCase, SetupTestErrorModules): self.valid_xml, self.system, self.org, self.course, self.error_msg) self.assertIsInstance(descriptor, error_module.ErrorDescriptor) descriptor.xmodule_runtime = self.system - context_repr = self.system.render(descriptor, None, 'student_view').content + context_repr = self.system.render(descriptor, 'student_view').content self.assertIn(self.error_msg, context_repr) self.assertIn(repr(self.valid_xml), context_repr) @@ -45,7 +45,7 @@ class TestErrorModule(unittest.TestCase, SetupTestErrorModules): descriptor, self.error_msg) self.assertIsInstance(error_descriptor, error_module.ErrorDescriptor) error_descriptor.xmodule_runtime = self.system - context_repr = self.system.render(error_descriptor, None, 'student_view').content + context_repr = self.system.render(error_descriptor, 'student_view').content self.assertIn(self.error_msg, context_repr) self.assertIn(repr(descriptor), context_repr) @@ -66,7 +66,7 @@ class TestNonStaffErrorModule(unittest.TestCase, SetupTestErrorModules): descriptor = error_module.NonStaffErrorDescriptor.from_xml( self.valid_xml, self.system, self.org, self.course) descriptor.xmodule_runtime = self.system - context_repr = self.system.render(descriptor, None, 'student_view').content + context_repr = self.system.render(descriptor, 'student_view').content self.assertNotIn(self.error_msg, context_repr) self.assertNotIn(repr(self.valid_xml), context_repr) @@ -80,6 +80,6 @@ class TestNonStaffErrorModule(unittest.TestCase, SetupTestErrorModules): descriptor, self.error_msg) self.assertIsInstance(error_descriptor, error_module.ErrorDescriptor) error_descriptor.xmodule_runtime = self.system - context_repr = self.system.render(error_descriptor, None, 'student_view').content + context_repr = self.system.render(error_descriptor, 'student_view').content self.assertNotIn(self.error_msg, context_repr) self.assertNotIn(str(descriptor), context_repr) diff --git a/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py b/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py index e86e75dd92..4d677cbc53 100644 --- a/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py +++ b/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py @@ -146,7 +146,7 @@ class TestStudentView(TestXBlockWrapper): descriptor = self.leaf_module(descriptor_cls) assert_equal( descriptor._xmodule.get_html(), - descriptor.runtime.render(descriptor, None, 'student_view').content + descriptor.render('student_view').content ) # Test that for all container XModule Descriptors, @@ -168,7 +168,7 @@ class TestStudentView(TestXBlockWrapper): descriptor = self.container_module(descriptor_cls, 2) assert_equal( descriptor._xmodule.get_html(), - descriptor.runtime.render(descriptor, None, 'student_view').content + descriptor.render('student_view').content ) # Check that when an xmodule is generated from descriptor_cls @@ -200,7 +200,7 @@ class TestStudioView(TestXBlockWrapper): raise SkipTest(descriptor_cls.__name__ + "is not editable in studio") descriptor = self.leaf_descriptor(descriptor_cls) - assert_equal(descriptor.get_html(), descriptor.runtime.render(descriptor, None, 'studio_view').content) + assert_equal(descriptor.get_html(), descriptor.render('studio_view').content) # Test that for all of the Descriptors listed in CONTAINER_XMODULES @@ -223,7 +223,7 @@ class TestStudioView(TestXBlockWrapper): raise SkipTest(descriptor_cls.__name__ + "is not editable in studio") descriptor = self.container_descriptor(descriptor_cls, 2) - assert_equal(descriptor.get_html(), descriptor.runtime.render(descriptor, None, 'studio_view').content) + assert_equal(descriptor.get_html(), descriptor.render('studio_view').content) # Check that when a descriptor is generated from descriptor_cls # with mixed xmodule and xblock children, it generates the same html from studio_view diff --git a/common/lib/xmodule/xmodule/timelimit_module.py b/common/lib/xmodule/xmodule/timelimit_module.py index 70d3d9dba9..b4bde1928c 100644 --- a/common/lib/xmodule/xmodule/timelimit_module.py +++ b/common/lib/xmodule/xmodule/timelimit_module.py @@ -89,7 +89,7 @@ class TimeLimitModule(TimeLimitFields, XModule): children = self.get_display_items() if children: child = children[0] - return self.runtime.render_child(child, None, 'student_view').content + return child.render('student_view').content else: return u"" diff --git a/common/lib/xmodule/xmodule/vertical_module.py b/common/lib/xmodule/xmodule/vertical_module.py index 2d6bfaa633..d825181033 100644 --- a/common/lib/xmodule/xmodule/vertical_module.py +++ b/common/lib/xmodule/xmodule/vertical_module.py @@ -23,7 +23,7 @@ class VerticalModule(VerticalFields, XModule): if self.contents is None: self.contents = [{ 'id': child.id, - 'content': self.runtime.render_child(child, None, 'student_view').content + 'content': child.render('student_view').content } for child in self.get_display_items()] return self.system.render_template('vert_module.html', { diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index 01e2750976..1c8bd4ed14 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -861,12 +861,12 @@ class DescriptorSystem(ConfigurableFragmentWrapper, Runtime): # pylint: disable result['default_value'] = field.to_json(field.default) return result - def render(self, block, context, view_name): + def render(self, block, view_name, context=None): if isinstance(block, (XModule, XModuleDescriptor)) and view_name == 'student_view': assert block.xmodule_runtime is not None - return block.xmodule_runtime.render(block._xmodule, context, view_name) + return block.xmodule_runtime.render(block._xmodule, view_name, context) else: - return super(DescriptorSystem, self).render(block, context, view_name) + return super(DescriptorSystem, self).render(block, view_name, context) class XMLParsingSystem(DescriptorSystem): diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 78e1d51cbc..625453aad0 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -164,7 +164,7 @@ def get_course_about_section(course, section_key): html = '' if about_module is not None: - html = about_module.runtime.render(about_module, None, 'student_view').content + html = about_module.render('student_view').content return html @@ -213,7 +213,7 @@ def get_course_info_section(request, course, section_key): html = '' if info_module is not None: - html = info_module.runtime.render(info_module, None, 'student_view').content + html = info_module.render('student_view').content return html diff --git a/lms/djangoapps/courseware/tabs.py b/lms/djangoapps/courseware/tabs.py index 6579e631d6..7ee16adcfb 100644 --- a/lms/djangoapps/courseware/tabs.py +++ b/lms/djangoapps/courseware/tabs.py @@ -419,6 +419,6 @@ def get_static_tab_contents(request, course, tab): html = '' if tab_module is not None: - html = tab_module.runtime.render(tab_module, None, 'student_view').content + html = tab_module.render('student_view').content return html diff --git a/lms/djangoapps/courseware/tests/test_lti.py b/lms/djangoapps/courseware/tests/test_lti.py index 9c3ae2bd58..1996f95cbf 100644 --- a/lms/djangoapps/courseware/tests/test_lti.py +++ b/lms/djangoapps/courseware/tests/test_lti.py @@ -69,7 +69,7 @@ class TestLTI(BaseTestXmodule): """ Makes sure that all parameters extracted. """ - generated_context = self.item_module.runtime.render(self.item_module, None, 'student_view').content + generated_context = self.item_module.render('student_view').content expected_context = { 'input_fields': self.correct_headers, 'element_class': self.item_module.location.category, diff --git a/lms/djangoapps/courseware/tests/test_module_render.py b/lms/djangoapps/courseware/tests/test_module_render.py index 9d720109e7..8cc9ce8c0a 100644 --- a/lms/djangoapps/courseware/tests/test_module_render.py +++ b/lms/djangoapps/courseware/tests/test_module_render.py @@ -74,7 +74,7 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase): ) # get the rendered HTML output which should have the rewritten link - html = module.runtime.render(module, None, 'student_view').content + html = module.render('student_view').content # See if the url got rewritten to the target link # note if the URL mapping changes then this assertion will break @@ -297,7 +297,7 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.course.id, wrap_xmodule_display=True, ) - result_fragment = module.runtime.render(module, None, 'student_view') + result_fragment = module.render('student_view') self.assertIn('section class="xmodule_display xmodule_HtmlModule"', result_fragment.content) @@ -310,7 +310,7 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.course.id, wrap_xmodule_display=False, ) - result_fragment = module.runtime.render(module, None, 'student_view') + result_fragment = module.render('student_view') self.assertNotIn('section class="xmodule_display xmodule_HtmlModule"', result_fragment.content) @@ -322,7 +322,7 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.field_data_cache, self.course.id, ) - result_fragment = module.runtime.render(module, None, 'student_view') + result_fragment = module.render('student_view') self.assertIn( '/c4x/{org}/{course}/asset/foo_content'.format( @@ -340,7 +340,7 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.field_data_cache, self.course.id, ) - result_fragment = module.runtime.render(module, None, 'student_view') + result_fragment = module.render('student_view') self.assertIn( '/c4x/{org}/{course}/asset/_file.jpg'.format( @@ -364,7 +364,7 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.course.id, static_asset_path="toy_course_dir", ) - result_fragment = module.runtime.render(module, None, 'student_view') + result_fragment = module.render('student_view') self.assertIn('href="/static/toy_course_dir', result_fragment.content) def test_course_image(self): @@ -390,7 +390,7 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.field_data_cache, self.course.id, ) - result_fragment = module.runtime.render(module, None, 'student_view') + result_fragment = module.render('student_view') self.assertIn( '/courses/{course_id}/bar/content'.format( @@ -408,7 +408,7 @@ class TestHtmlModifiers(ModuleStoreTestCase): self.field_data_cache, self.course.id, ) - result_fragment = module.runtime.render(module, None, 'student_view') + result_fragment = module.render('student_view') self.assertIn( 'Staff Debug', diff --git a/lms/djangoapps/courseware/tests/test_timelimit_module.py b/lms/djangoapps/courseware/tests/test_timelimit_module.py index 532dd23675..3e3e0943f3 100644 --- a/lms/djangoapps/courseware/tests/test_timelimit_module.py +++ b/lms/djangoapps/courseware/tests/test_timelimit_module.py @@ -20,10 +20,10 @@ class TestTimeLimitModuleRendering(XModuleRenderingTestBase): block.xmodule_runtime = self.new_module_runtime() ItemFactory.create(category='html', data='This is just text', parent=block) - assert_student_view(block, self.runtime.render(block, None, 'student_view')) + assert_student_view(block, block.render('student_view')) def test_without_children(self): block = ItemFactory.create(category='timelimit') block.xmodule_runtime = self.new_module_runtime() - assert_student_view(block, self.runtime.render(block, None, 'student_view')) + assert_student_view(block, block.render('student_view')) diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py index 2b94b561d0..d364dc6fe5 100644 --- a/lms/djangoapps/courseware/tests/test_video_mongo.py +++ b/lms/djangoapps/courseware/tests/test_video_mongo.py @@ -32,7 +32,7 @@ class TestVideo(BaseTestXmodule): def test_video_constructor(self): """Make sure that all parameters extracted correclty from xml""" - context = self.item_module.runtime.render(self.item_module, None, 'student_view').content + context = self.item_module.render('student_view').content sources = { 'main': u'example.mp4', @@ -93,7 +93,7 @@ class TestVideoNonYouTube(TestVideo): u'ogv': u'example.ogv' } - context = self.item_module.runtime.render(self.item_module, None, 'student_view').content + context = self.item_module.render('student_view').content expected_context = { 'data_dir': getattr(self, 'data_dir', None), diff --git a/lms/djangoapps/courseware/tests/test_video_xml.py b/lms/djangoapps/courseware/tests/test_video_xml.py index 3402855a67..616c518ffe 100644 --- a/lms/djangoapps/courseware/tests/test_video_xml.py +++ b/lms/djangoapps/courseware/tests/test_video_xml.py @@ -95,7 +95,7 @@ class VideoModuleUnitTest(unittest.TestCase): } self.assertEqual( - module.runtime.render(module, None, 'student_view').content, + module.render('student_view').content, module.runtime.render_template('video.html', expected_context) ) diff --git a/lms/djangoapps/courseware/tests/test_word_cloud.py b/lms/djangoapps/courseware/tests/test_word_cloud.py index 9967ea4915..53e7c20850 100644 --- a/lms/djangoapps/courseware/tests/test_word_cloud.py +++ b/lms/djangoapps/courseware/tests/test_word_cloud.py @@ -242,7 +242,7 @@ class TestWordCloud(BaseTestXmodule): def test_word_cloud_constructor(self): """Make sure that all parameters extracted correclty from xml""" - fragment = self.runtime.render(self.item_module, None, 'student_view') + fragment = self.runtime.render(self.item_module, 'student_view') expected_context = { 'ajax_url': self.item_module.xmodule_runtime.ajax_url, diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 672dc4d747..56471d25f1 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -407,7 +407,7 @@ def index(request, course_id, chapter=None, section=None, # add in the appropriate timer information to the rendering context: context.update(check_for_active_timelimit_module(request, course_id, course)) - context['content'] = section_module.runtime.render(section_module, None, 'student_view').content + context['content'] = section_module.render('student_view').content else: # section is none, so display a message prev_section = get_current_child(chapter_module) diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py index 6d7e75baa4..53be1d3347 100644 --- a/lms/djangoapps/instructor/views/legacy.py +++ b/lms/djangoapps/instructor/views/legacy.py @@ -817,7 +817,7 @@ def instructor_dashboard(request, course_id): # HTML editor for email if idash_mode == 'Email' and is_studio_course: html_module = HtmlDescriptor(course.system, DictFieldData({'data': html_message}), ScopeIds(None, None, None, None)) - fragment = course.system.render(html_module, None, 'studio_view') + fragment = course.system.render(html_module, 'studio_view') fragment = wrap_xmodule('xmodule_edit.html', html_module, 'studio_view', fragment, None) email_editor = fragment.content diff --git a/requirements/edx/github.txt b/requirements/edx/github.txt index 31ee9b3fd5..363b3682b8 100644 --- a/requirements/edx/github.txt +++ b/requirements/edx/github.txt @@ -15,7 +15,7 @@ -e git+https://github.com/eventbrite/zendesk.git@d53fe0e81b623f084e91776bcf6369f8b7b63879#egg=zendesk # Our libraries: --e git+https://github.com/edx/XBlock.git@8a66ca3#egg=XBlock +-e git+https://github.com/edx/XBlock.git@cee38a15f#egg=XBlock -e git+https://github.com/edx/codejail.git@0a1b468#egg=codejail -e git+https://github.com/edx/diff-cover.git@v0.2.5#egg=diff_cover -e git+https://github.com/edx/js-test-tool.git@v0.1.1#egg=js_test_tool