Commit 94a88c57 by Braden MacDonald

Fix: Unhelpful tooltips shown in sequential accordion in the LMS

parent 21fc19e0
......@@ -759,10 +759,16 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
"""
By default, each Sequential block in a course ("Subsection" in Studio parlance) will
display the display_name of each descendant in a tooltip above the content. We don't
want that - we only want to display the mentoring block as a whole as one item.
want that - we only want to display one title for this mentoring block as a whole.
Otherwise things like "Choice (yes) (Correct)" will appear in the tooltip.
If this block has no title set, don't display any title. Then, if this is the only block
in the unit, the unit's title will be used. (Why isn't it always just used?)
"""
return [self.display_name]
has_explicitly_set_title = self.fields['display_name'].is_set_on(self)
if has_explicitly_set_title:
return [self.display_name]
return []
@staticmethod
def workbench_scenarios():
......
......@@ -6,6 +6,7 @@ from problem_builder import MentoringBlock
from problem_builder.mentoring import _default_theme_config
@ddt.ddt
class TestMentoringBlock(unittest.TestCase):
def test_sends_progress_event_when_rendered_student_view_with_display_submit_false(self):
block = MentoringBlock(MagicMock(), DictFieldData({
......@@ -31,6 +32,21 @@ class TestMentoringBlock(unittest.TestCase):
self.assertFalse(patched_runtime.publish.called)
@ddt.data(True, False)
def test_get_content_titles(self, has_title_set):
"""
Test that we don't send a title to the LMS for the sequential's tooltips when no title
is set
"""
if has_title_set:
data = {'display_name': 'Custom Title'}
expected = ['Custom Title']
else:
data = {}
expected = []
block = MentoringBlock(MagicMock(), DictFieldData(data), Mock())
self.assertEqual(block.get_content_titles(), expected)
@ddt.ddt
class TestMentoringBlockTheming(unittest.TestCase):
......
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