File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
common/lib/xmodule/xmodule Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -811,7 +811,10 @@ def get_answer(self, _data):
811
811
new_answers = dict ()
812
812
for answer_id in answers :
813
813
try :
814
- new_answer = {answer_id : self .runtime .replace_urls (answers [answer_id ])}
814
+ answer_content = self .runtime .replace_urls (answers [answer_id ])
815
+ if self .runtime .replace_jump_to_id_urls :
816
+ answer_content = self .runtime .replace_jump_to_id_urls (answer_content )
817
+ new_answer = {answer_id : answer_content }
815
818
except TypeError :
816
819
log .debug (u'Unable to perform URL substitution on answers[%s]: %s' ,
817
820
answer_id , answers [answer_id ])
Original file line number Diff line number Diff line change @@ -1890,3 +1890,29 @@ def test_file_inputs(self):
1890
1890
'variant' : ''
1891
1891
}
1892
1892
})
1893
+
1894
+ def test_get_answer_with_jump_to_id_urls (self ):
1895
+ """
1896
+ Make sure replace_jump_to_id_urls() is called in get_answer.
1897
+ """
1898
+ problem_xml = textwrap .dedent ("""
1899
+ <problem>
1900
+ <p>What is 1+4?</p>
1901
+ <numericalresponse answer="5">
1902
+ <formulaequationinput />
1903
+ </numericalresponse>
1904
+
1905
+ <solution>
1906
+ <div class="detailed-solution">
1907
+ <p>Explanation</p>
1908
+ <a href="/jump_to_id/c0f8d54964bc44a4a1deb8ecce561ecd">here's the same link to the hint page.</a>
1909
+ </div>
1910
+ </solution>
1911
+ </problem>
1912
+ """ )
1913
+
1914
+ data = dict ()
1915
+ problem = CapaFactory .create (showanswer = 'always' , xml = problem_xml )
1916
+ problem .runtime .replace_jump_to_id_urls = Mock ()
1917
+ problem .get_answer (data )
1918
+ self .assertTrue (problem .runtime .replace_jump_to_id_urls .called )
You can’t perform that action at this time.
0 commit comments