Commit 3fdae56a by Calen Pennington

Remove dead code

parent d7ee0387
......@@ -25,7 +25,7 @@ class I4xSystem(object):
Note that these functions can be closures over e.g. a django request
and user, or other environment-specific info.
'''
def __init__(self, ajax_url, track_function, render_function,
def __init__(self, ajax_url, track_function,
get_module, render_template, user=None,
filestore=None):
'''
......@@ -38,10 +38,6 @@ class I4xSystem(object):
files. Update or remove.
get_module - function that takes (location) and returns a corresponding
module instance object.
render_function - function that takes (module_xml) and renders it,
returning a dictionary with a context for rendering the
module to html. Dictionary will contain keys 'content'
and 'type'.
render_template - a function that takes (template_file, context), and returns
rendered html.
user - The user to base the seed off of for this request
......@@ -52,7 +48,6 @@ class I4xSystem(object):
self.track_function = track_function
self.filestore = filestore
self.get_module = get_module
self.render_function = render_function
self.render_template = render_template
self.exception404 = Http404
self.DEBUG = settings.DEBUG
......@@ -230,8 +225,6 @@ def get_module(user, request, location, student_module_cache, position=None):
return module
system = I4xSystem(track_function=make_track_function(request),
render_function=lambda xml: render_x_module(
user, xml, student_module_cache, position),
render_template=render_to_string,
ajax_url=ajax_url,
# TODO (cpennington): Figure out how to share info between systems
......@@ -290,48 +283,6 @@ def add_histogram(module):
return module
def render_x_module(user, module, student_module_cache, position=None):
''' Generic module for extensions. This renders to HTML.
modules include sequential, vertical, problem, video, html
Note that modules can recurse. problems, video, html, can be inside sequential or vertical.
Arguments:
- user : current django User
- module : lxml etree of xml subtree for the current module
- student_module_cache : list of StudentModule objects, one of which may match this module type and id
- position : extra information from URL for user-specified position within module
Returns:
- dict which is context for HTML rendering of the specified module. Will have
key 'content', and will have 'type' key if passed a valid module.
'''
if module_xml is None:
return {"content": ""}
(instance, _, _, module_type) = get_module(
user, module_xml, student_module_cache, position)
content = instance.get_html()
# special extra information about each problem, only for users who are staff
if settings.MITX_FEATURES.get('DISPLAY_HISTOGRAMS_TO_STAFF') and user.is_staff:
module_id = module_xml.get('id')
histogram = grade_histogram(module_id)
render_histogram = len(histogram) > 0
staff_context = {'xml': etree.tostring(module_xml),
'module_id': module_id,
'histogram': json.dumps(histogram),
'render_histogram': render_histogram}
content += render_to_string("staff_problem_info.html", staff_context)
context = {'content': content, 'type': module_type}
return context
def modx_dispatch(request, dispatch=None, id=None):
''' Generic view for extensions. This is where AJAX calls go.
......
......@@ -16,7 +16,7 @@ from django.views.decorators.cache import cache_control
from lxml import etree
from module_render import render_x_module, toc_for_course, get_module, get_section
from module_render import toc_for_course, get_module, get_section
from models import StudentModuleCache
from student.models import UserProfile
from multicourse import multicourse_settings
......@@ -115,47 +115,6 @@ def render_accordion(request, course, chapter, section):
return render_to_string('accordion.html', context)
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
def render_section(request, section):
''' TODO: Consolidate with index
'''
user = request.user
if not settings.COURSEWARE_ENABLED:
return redirect('/')
coursename = multicourse_settings.get_coursename_from_request(request)
try:
dom = content_parser.section_file(user, section, coursename)
except:
log.exception("Unable to parse courseware xml")
return render_to_response('courseware-error.html', {})
context = {
'csrf': csrf(request)['csrf_token'],
'accordion': render_accordion(request, get_course(request), '', '')
}
student_module_cache = StudentModuleCache(request.user, dom)
try:
module = render_x_module(user, dom, student_module_cache)
except:
log.exception("Unable to load module")
context.update({
'init': '',
'content': render_to_string("module-error.html", {}),
})
return render_to_response('courseware.html', context)
context.update({
'content': module['content'],
})
result = render_to_response('courseware.html', context)
return result
def get_course(request, course):
''' Figure out what the correct course is.
......
......@@ -56,7 +56,6 @@ if settings.COURSEWARE_ENABLED:
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/$', 'courseware.views.index', name="courseware_chapter"),
url(r'^courseware/(?P<course>[^/]*)/$', 'courseware.views.index', name="courseware_course"),
url(r'^jumpto/(?P<probname>[^/]+)/$', 'courseware.views.jump_to'),
url(r'^section/(?P<section>[^/]*)/$', 'courseware.views.render_section'),
url(r'^modx/(?P<id>.*?)/(?P<dispatch>[^/]*)$', 'courseware.module_render.modx_dispatch'), #reset_problem'),
url(r'^profile$', 'courseware.views.profile'),
url(r'^profile/(?P<student_id>[^/]*)/$', 'courseware.views.profile'),
......
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