From 3359928520deedf0b3a28388269f2f89f488429b Mon Sep 17 00:00:00 2001 From: Ali-D-Akbar Date: Tue, 24 Mar 2020 15:08:44 +0500 Subject: [PATCH] add static links re-write for demnadhint tag --- common/lib/xmodule/xmodule/capa_base.py | 2 +- .../xmodule/xmodule/tests/test_capa_module.py | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/capa_base.py b/common/lib/xmodule/xmodule/capa_base.py index 45882b7abb..9de45d785b 100644 --- a/common/lib/xmodule/xmodule/capa_base.py +++ b/common/lib/xmodule/xmodule/capa_base.py @@ -681,7 +681,7 @@ class CapaMixin(ScorableXBlockMixin, CapaFields): ) ), # Course-authored HTML demand hints are supported. - hint_text=HTML(get_inner_html_from_xpath(demand_hints[counter])) + hint_text=HTML(self.runtime.replace_urls(get_inner_html_from_xpath(demand_hints[counter]))) ) counter += 1 diff --git a/common/lib/xmodule/xmodule/tests/test_capa_module.py b/common/lib/xmodule/xmodule/tests/test_capa_module.py index 9e48967ca0..f48da0c915 100644 --- a/common/lib/xmodule/xmodule/tests/test_capa_module.py +++ b/common/lib/xmodule/xmodule/tests/test_capa_module.py @@ -1611,6 +1611,37 @@ class ProblemBlockTest(unittest.TestCase): self.assertEqual(result['hint_index'], 0) self.assertFalse(result['should_enable_next_hint']) + def test_image_hint(self): + """ + Test the hint button shows an image without the static url. + """ + test_xml = """ + +

That is the question

+ + + Alpha A hint + + Beta + + + + + + You can add an optional hint like this. Problems that have a hint include a hint button, and this text appears the first time learners select the button. + +
""" + module = CapaFactory.create(xml=test_xml) + module.get_problem_html() # ignoring html result + context = module.system.render_template.call_args[0][1] + self.assertTrue(context['demand_hint_possible']) + self.assertTrue(context['should_enable_next_hint']) + + # Check the AJAX call that gets the hint by index + result = module.get_demand_hint(0) + self.assertEqual(result['hint_index'], 0) + self.assertFalse(result['should_enable_next_hint']) + def test_demand_hint_logging(self): def mock_location_text(self): """