From 80ba9bd0ffcfb0f903614561faf6316a17f8cb2f Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Thu, 10 May 2012 22:25:14 -0400 Subject: [PATCH] Remove unused `init_js` and `destroy_js` --- .../management/commands/check_course.py | 2 +- djangoapps/courseware/module_render.py | 11 ++--------- .../courseware/modules/vertical_module.py | 9 --------- djangoapps/courseware/modules/x_module.py | 19 ------------------- 4 files changed, 3 insertions(+), 38 deletions(-) diff --git a/djangoapps/courseware/management/commands/check_course.py b/djangoapps/courseware/management/commands/check_course.py index 2f069ee5f3..17a97268cf 100644 --- a/djangoapps/courseware/management/commands/check_course.py +++ b/djangoapps/courseware/management/commands/check_course.py @@ -33,7 +33,7 @@ class Command(BaseCommand): ajax_url='', state=None, track_function = lambda x,y,z:None, - render_function = lambda x: {'content':'','destroy_js':'','init_js':'','type':'video'}) + render_function = lambda x: {'content':'','type':'video'}) except: print "==============> Error in ", etree.tostring(module) check = False diff --git a/djangoapps/courseware/module_render.py b/djangoapps/courseware/module_render.py index 278d19fd2c..2463e31d9b 100644 --- a/djangoapps/courseware/module_render.py +++ b/djangoapps/courseware/module_render.py @@ -130,8 +130,6 @@ def render_x_module(user, request, xml_module, module_object_preload): # Grab content content = instance.get_html() - init_js = instance.get_init_js() - destory_js = instance.get_destroy_js() # special extra information about each problem, only for users who are staff if user.is_staff: @@ -140,13 +138,8 @@ def render_x_module(user, request, xml_module, module_object_preload): content=content+render_to_string("staff_problem_info.html", {'xml':etree.tostring(xml_module), 'module_id' : module_id, 'render_histogram' : render_histogram}) - if render_histogram: - init_js = init_js+render_to_string("staff_problem_histogram.js", {'histogram' : histogram, - 'module_id' : module_id}) - - content = {'content':content, - "destroy_js":destory_js, - 'init_js':init_js, + + content = {'content':content, 'type':module_type} return content diff --git a/djangoapps/courseware/modules/vertical_module.py b/djangoapps/courseware/modules/vertical_module.py index e57a58e33e..a834614e26 100644 --- a/djangoapps/courseware/modules/vertical_module.py +++ b/djangoapps/courseware/modules/vertical_module.py @@ -18,17 +18,8 @@ class Module(XModule): def get_html(self): return render_to_string('vert_module.html',{'items':self.contents}) - def get_init_js(self): - return self.init_js_text - - def get_destroy_js(self): - return self.destroy_js_text - - def __init__(self, system, xml, item_id, state=None): XModule.__init__(self, system, xml, item_id, state) xmltree=etree.fromstring(xml) self.contents=[(e.get("name"),self.render_function(e)) \ for e in xmltree] - self.init_js_text="".join([e[1]['init_js'] for e in self.contents if 'init_js' in e[1]]) - self.destroy_js_text="".join([e[1]['destroy_js'] for e in self.contents if 'destroy_js' in e[1]]) diff --git a/djangoapps/courseware/modules/x_module.py b/djangoapps/courseware/modules/x_module.py index b475fd0280..464e2f0a90 100644 --- a/djangoapps/courseware/modules/x_module.py +++ b/djangoapps/courseware/modules/x_module.py @@ -78,25 +78,6 @@ class XModule(object): ''' return "Unimplemented" - # TODO: - # def get_header_js(self): - # ''' Filename of common js that needs to be included in the header - # ''' - # raise NotImplementedError - - def get_init_js(self): - ''' JavaScript code to be run when problem is shown. Be aware - that this may happen several times on the same page - (e.g. student switching tabs). Common functions should be put - in the main course .js files for now. ''' - return "" - - def get_destroy_js(self): - ''' JavaScript called to destroy the problem (e.g. when a user switches to a different tab). - We make an attempt, but not a promise, to call this when the user closes the web page. - ''' - return "" - def handle_ajax(self, dispatch, get): ''' dispatch is last part of the URL. get is a dictionary-like object '''