Make location into a named tuple, and use it more as a first class entity, rather than URL for identifying content
This commit is contained in:
@@ -85,6 +85,7 @@ class StudentModuleCache(object):
|
||||
student=user,
|
||||
module_state_key__in=id_chunk)
|
||||
)
|
||||
|
||||
else:
|
||||
self.cache = []
|
||||
|
||||
@@ -93,7 +94,7 @@ class StudentModuleCache(object):
|
||||
Get a list of the state_keys needed for StudentModules
|
||||
required for this chunk of module xml
|
||||
'''
|
||||
keys = [descriptor.url]
|
||||
keys = [descriptor.location.url()]
|
||||
|
||||
shared_state_key = getattr(descriptor, 'shared_state_key', None)
|
||||
if shared_state_key is not None:
|
||||
|
||||
@@ -207,7 +207,7 @@ def get_module(user, request, location, student_module_cache, position=None):
|
||||
'''
|
||||
descriptor = keystore().get_item(location)
|
||||
|
||||
instance_module = student_module_cache.lookup(descriptor.category, descriptor.url)
|
||||
instance_module = student_module_cache.lookup(descriptor.category, descriptor.location.url())
|
||||
shared_state_key = getattr(descriptor, 'shared_state_key', None)
|
||||
if shared_state_key is not None:
|
||||
shared_module = student_module_cache.lookup(descriptor.category, shared_state_key)
|
||||
@@ -218,7 +218,7 @@ def get_module(user, request, location, student_module_cache, position=None):
|
||||
shared_state = shared_module.state if shared_module is not None else None
|
||||
|
||||
# Setup system context for module instance
|
||||
ajax_url = settings.MITX_ROOT_URL + '/modx/' + descriptor.url + '/'
|
||||
ajax_url = settings.MITX_ROOT_URL + '/modx/' + descriptor.location.url() + '/'
|
||||
|
||||
def _get_module(location):
|
||||
(module, _, _, _) = get_module(user, request, location, student_module_cache, position)
|
||||
|
||||
@@ -209,7 +209,7 @@ def index(request, course=None, chapter=None, section=None,
|
||||
course_location = multicourse_settings.get_course_location(course)
|
||||
section = get_section(course_location, chapter, section)
|
||||
student_module_cache = StudentModuleCache(request.user, section)
|
||||
module, _, _, _ = get_module(request.user, request, section.url, student_module_cache)
|
||||
module, _, _, _ = get_module(request.user, request, section.location, student_module_cache)
|
||||
context['content'] = module.get_html()
|
||||
|
||||
result = render_to_response('courseware.html', context)
|
||||
|
||||
Reference in New Issue
Block a user