Commit dbc47600 by Waheed Ahmed

Merge pull request #5809 from edx/waheed/tnl729-fix-jump-to-id-in-problem-solution

Fixed jump_to_id in problem solution.
parents 831453c5 b6d4a533
......@@ -811,7 +811,10 @@ class CapaMixin(CapaFields):
new_answers = dict()
for answer_id in answers:
try:
new_answer = {answer_id: self.runtime.replace_urls(answers[answer_id])}
answer_content = self.runtime.replace_urls(answers[answer_id])
if self.runtime.replace_jump_to_id_urls:
answer_content = self.runtime.replace_jump_to_id_urls(answer_content)
new_answer = {answer_id: answer_content}
except TypeError:
log.debug(u'Unable to perform URL substitution on answers[%s]: %s',
answer_id, answers[answer_id])
......
......@@ -1890,3 +1890,29 @@ class TestProblemCheckTracking(unittest.TestCase):
'variant': ''
}
})
def test_get_answer_with_jump_to_id_urls(self):
"""
Make sure replace_jump_to_id_urls() is called in get_answer.
"""
problem_xml = textwrap.dedent("""
<problem>
<p>What is 1+4?</p>
<numericalresponse answer="5">
<formulaequationinput />
</numericalresponse>
<solution>
<div class="detailed-solution">
<p>Explanation</p>
<a href="/jump_to_id/c0f8d54964bc44a4a1deb8ecce561ecd">here's the same link to the hint page.</a>
</div>
</solution>
</problem>
""")
data = dict()
problem = CapaFactory.create(showanswer='always', xml=problem_xml)
problem.runtime.replace_jump_to_id_urls = Mock()
problem.get_answer(data)
self.assertTrue(problem.runtime.replace_jump_to_id_urls.called)
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