diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 8489b5f986..dbd535a471 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -534,8 +534,16 @@ class CapaModule(CapaFields, XModule): id=self.location.html_id(), ajax_url=self.system.ajax_url ) + html + "" - # 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): """ diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index d399001a6a..b991858dca 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -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).''' diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index caa8967476..0a48c56f87 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -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,