diff --git a/common/lib/xmodule/xmodule/capa_base.py b/common/lib/xmodule/xmodule/capa_base.py
index 0a95bbff74..87a2e4b7f3 100644
--- a/common/lib/xmodule/xmodule/capa_base.py
+++ b/common/lib/xmodule/xmodule/capa_base.py
@@ -641,12 +641,15 @@ class CapaMixin(ScorableXBlockMixin, CapaFields):
# Translators: {previous_hints} is the HTML of hints that have already been generated, {hint_number_prefix}
# is a header for this hint, and {hint_text} is the text of the hint itself.
# This string is being passed to translation only for possible reordering of the placeholders.
- total_text = HTML(_('{previous_hints}
{hint_number_prefix}{hint_text}')).format(
+ total_text = HTML(_('{previous_hints}{list_start_tag}{strong_text}{hint_text}')).format(
previous_hints=HTML(total_text),
- # Translators: e.g. "Hint 1 of 3: " meaning we are showing the first of three hints.
- # This text is shown in bold before the accompanying hint text.
- hint_number_prefix=Text(_("Hint ({hint_num} of {hints_count}): ")).format(
- hint_num=counter + 1, hints_count=len(demand_hints)
+ list_start_tag=HTML('').format(counter=counter),
+ strong_text=HTML('{hint_number_prefix}').format(
+ # Translators: e.g. "Hint 1 of 3: " meaning we are showing the first of three hints.
+ # This text is shown in bold before the accompanying hint text.
+ hint_number_prefix=Text(_("Hint ({hint_num} of {hints_count}): ")).format(
+ hint_num=counter + 1, hints_count=len(demand_hints)
+ )
),
# Course-authored HTML demand hints are supported.
hint_text=HTML(get_inner_html_from_xpath(demand_hints[counter]))
diff --git a/common/lib/xmodule/xmodule/js/src/capa/display.js b/common/lib/xmodule/xmodule/js/src/capa/display.js
index 46c2e0c933..e5acc1e375 100644
--- a/common/lib/xmodule/xmodule/js/src/capa/display.js
+++ b/common/lib/xmodule/xmodule/js/src/capa/display.js
@@ -486,8 +486,8 @@
this.focus_on_notification('submit');
};
- Problem.prototype.focus_on_hint_notification = function() {
- this.focus_on_notification('hint');
+ Problem.prototype.focus_on_hint_notification = function(hintIndex) {
+ this.$('.notification-hint .notification-message > ol > li.hint-index-' + hintIndex).focus();
};
Problem.prototype.focus_on_save_notification = function() {
@@ -1312,7 +1312,7 @@
that.hintButton.attr({disabled: 'disabled'});
}
that.el.find('.notification-hint').show();
- that.focus_on_hint_notification();
+ that.focus_on_hint_notification(nextIndex);
} else {
that.gentle_alert(response.msg);
}
diff --git a/common/test/acceptance/pages/lms/problem.py b/common/test/acceptance/pages/lms/problem.py
index f33c13807b..6ac1e14dc7 100644
--- a/common/test/acceptance/pages/lms/problem.py
+++ b/common/test/acceptance/pages/lms/problem.py
@@ -329,19 +329,28 @@ class ProblemPage(PageObject):
self.wait_for_element_visibility('.notification.general.notification-submit', msg)
self.wait_for_focus_on_submit_notification()
- def click_hint(self):
+ def click_hint(self, hint_index=0):
"""
Click the Hint button.
+
+ Arguments:
+ hint_index (int): Index of a displayed hint
"""
click_css(self, '.problem .hint-button', require_notification=False)
- self.wait_for_focus_on_hint_notification()
+ self.wait_for_focus_on_hint_notification(hint_index)
- def wait_for_focus_on_hint_notification(self):
+ def wait_for_focus_on_hint_notification(self, hint_index=0):
"""
Wait for focus to be on the hint notification.
+
+ Arguments:
+ hint_index (int): Index of a displayed hint
"""
+ css = '.notification-hint .notification-message > ol > li.hint-index-{hint_index}'.format(
+ hint_index=hint_index
+ )
self.wait_for(
- lambda: self.q(css='.notification-hint').focused,
+ lambda: self.q(css=css).focused,
'Waiting for the focus to be on the hint notification'
)
diff --git a/common/test/acceptance/tests/lms/test_lms_problems.py b/common/test/acceptance/tests/lms/test_lms_problems.py
index f4fd5516b9..7e14c2650f 100644
--- a/common/test/acceptance/tests/lms/test_lms_problems.py
+++ b/common/test/acceptance/tests/lms/test_lms_problems.py
@@ -144,13 +144,13 @@ class ProblemHintTest(ProblemsTest, EventsTestMixin):
self.assertEqual([None, None], problem_page.get_hint_button_disabled_attr())
# The hint button rotates through multiple hints
- problem_page.click_hint()
+ problem_page.click_hint(hint_index=0)
self.assertTrue(problem_page.is_hint_notification_visible())
self.assertEqual(problem_page.hint_text, first_hint)
# Now there are two "hint" buttons, as there is also one in the hint notification.
self.assertEqual([None, None], problem_page.get_hint_button_disabled_attr())
- problem_page.click_hint()
+ problem_page.click_hint(hint_index=1)
self.assertEqual(problem_page.hint_text, second_hint)
# Now both "hint" buttons should be disabled, as there are no more hints.
self.assertEqual(['true', 'true'], problem_page.get_hint_button_disabled_attr())
@@ -573,7 +573,7 @@ class ProblemWithMathjax(ProblemsTest):
problem_page.verify_mathjax_rendered_in_problem()
# The hint button rotates through multiple hints
- problem_page.click_hint()
+ problem_page.click_hint(hint_index=0)
self.assertEqual(
["Hint (1 of 2): mathjax should work1"],
problem_page.extract_hint_text_from_html
@@ -581,7 +581,7 @@ class ProblemWithMathjax(ProblemsTest):
problem_page.verify_mathjax_rendered_in_hint()
# Rotate the hint and check the problem hint
- problem_page.click_hint()
+ problem_page.click_hint(hint_index=1)
self.assertEqual(
[