Commit c4d6102a by chrisndodge

Merge pull request #584 from edx/fix/cdodge/allow-courseware-links-in-capa-module

tie in the normal courseware link url rewriting in capa module since tha...
parents 13339fb9 9e96b952
......@@ -534,8 +534,16 @@ class CapaModule(CapaFields, XModule):
id=self.location.html_id(), ajax_url=self.system.ajax_url
) + html + "</div>"
# now do the substitutions which are filesystem based, e.g. '/static/' prefixes
return self.system.replace_urls(html)
# now do all the substitutions which the LMS module_render normally does, but
# we need to do here explicitly since we can get called for our HTML via AJAX
html = self.system.replace_urls(html)
if self.system.replace_course_urls:
html = self.system.replace_course_urls(html)
if self.system.replace_jump_to_id_urls:
html = self.system.replace_jump_to_id_urls(html)
return html
def handle_ajax(self, dispatch, data):
"""
......
......@@ -902,6 +902,8 @@ class ModuleSystem(Runtime):
s3_interface=None,
cache=None,
can_execute_unsafe_code=None,
replace_course_urls=None,
replace_jump_to_id_urls=None
):
'''
Create a closure around the system environment.
......@@ -978,6 +980,8 @@ class ModuleSystem(Runtime):
self.cache = cache or DoNothingCache()
self.can_execute_unsafe_code = can_execute_unsafe_code or (lambda: False)
self.replace_course_urls = replace_course_urls
self.replace_jump_to_id_urls = replace_jump_to_id_urls
def get(self, attr):
''' provide uniform access to attributes (like etree).'''
......
......@@ -349,6 +349,15 @@ def get_module_for_descriptor_internal(user, descriptor, model_data_cache, cours
data_directory=getattr(descriptor, 'data_dir', None),
course_namespace=descriptor.location._replace(category=None, name=None),
),
replace_course_urls=partial(
static_replace.replace_course_urls,
course_id=course_id
),
replace_jump_to_id_urls=partial(
static_replace.replace_jump_to_id_urls,
course_id=course_id,
jump_to_id_base_url=reverse('jump_to_id', kwargs={'course_id': course_id, 'module_id': ''})
),
node_path=settings.NODE_PATH,
xblock_model_data=xblock_model_data,
publish=publish,
......
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