diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index ea17c23bb4..525cf0ba87 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -347,7 +347,7 @@ class CapaModule(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, self.metadata['data_dir']) + return self.system.replace_urls(html, self.metadata['data_dir'], self.location) def handle_ajax(self, dispatch, get): ''' @@ -451,7 +451,7 @@ class CapaModule(XModule): new_answers = dict() for answer_id in answers: try: - new_answer = {answer_id: self.system.replace_urls(answers[answer_id], self.metadata['data_dir'])} + new_answer = {answer_id: self.system.replace_urls(answers[answer_id], self.metadata['data_dir'], self.location)} except TypeError: log.debug('Unable to perform URL substitution on answers[%s]: %s' % (answer_id, answers[answer_id])) new_answer = {answer_id: answers[answer_id]} diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 6300b2c491..f3e435e4dc 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -148,7 +148,7 @@ def get_course_about_section(course, section_key): request = get_request_for_thread() loc = course.location._replace(category='about', name=section_key) - course_module = get_module(request.user, request, loc, None, course.id, not_found_ok = True) + course_module = get_module(request.user, request, loc, None, course.id, not_found_ok = True, wrap_xmodule_display = False) html = '' @@ -186,8 +186,7 @@ def get_course_info_section(request, cache, course, section_key): loc = Location(course.location.tag, course.location.org, course.location.course, 'course_info', section_key) - course_module = get_module(request.user, request, loc, cache, course.id) - + course_module = get_module(request.user, request, loc, cache, course.id, wrap_xmodule_display = False) html = '' if course_module is not None: @@ -196,7 +195,6 @@ def get_course_info_section(request, cache, course, section_key): return html - # TODO: Fix this such that these are pulled in as extra course-specific tabs. # arjun will address this by the end of October if no one does so prior to # then. @@ -222,7 +220,7 @@ def get_course_syllabus_section(course, section_key): filepath = find_file(fs, dirs, section_key + ".html") with fs.open(filepath) as htmlFile: return replace_urls(htmlFile.read().decode('utf-8'), - course.metadata['data_dir']) + course.metadata['data_dir'], course.location) except ResourceNotFoundError: log.exception("Missing syllabus section {key} in course {url}".format( key=section_key, url=course.location.url())) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 3880170169..9343301fb7 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -115,7 +115,7 @@ def toc_for_course(user, request, course, active_chapter, active_section): return chapters -def get_module(user, request, location, student_module_cache, course_id, position=None, not_found_ok = False): +def get_module(user, request, location, student_module_cache, course_id, position=None, not_found_ok = False, wrap_xmodule_display = True): """ Get an instance of the xmodule class identified by location, setting the state based on an existing StudentModule, or creating one if none @@ -136,7 +136,7 @@ def get_module(user, request, location, student_module_cache, course_id, positio if possible. If not possible, return None. """ try: - return _get_module(user, request, location, student_module_cache, course_id, position) + return _get_module(user, request, location, student_module_cache, course_id, position, wrap_xmodule_display) except ItemNotFoundError: if not not_found_ok: log.exception("Error in get_module") @@ -146,7 +146,7 @@ def get_module(user, request, location, student_module_cache, course_id, positio log.exception("Error in get_module") return None -def _get_module(user, request, location, student_module_cache, course_id, position=None): +def _get_module(user, request, location, student_module_cache, course_id, position=None, wrap_xmodule_display = True): """ Actually implement get_module. See docstring there for details. """ @@ -261,8 +261,13 @@ def _get_module(user, request, location, student_module_cache, course_id, positi # Make an error module return err_descriptor.xmodule_constructor(system)(None, None) + _get_html = module.get_html + + if wrap_xmodule_display == True: + _get_html = wrap_xmodule(module.get_html, module, 'xmodule_display.html') + module.get_html = replace_static_urls( - wrap_xmodule(module.get_html, module, 'xmodule_display.html'), + _get_html, module.metadata['data_dir'] if 'data_dir' in module.metadata else '', course_namespace = module.location._replace(category=None, name=None))