diff --git a/common/lib/xmodule/xmodule/annotatable_module.py b/common/lib/xmodule/xmodule/annotatable_module.py
index 9e492f755a..665be210e4 100644
--- a/common/lib/xmodule/xmodule/annotatable_module.py
+++ b/common/lib/xmodule/xmodule/annotatable_module.py
@@ -29,14 +29,13 @@ class AnnotatableModule(XModule):
attr = {}
cls = ['annotatable-span', 'highlight']
- valid_colors = ['yellow', 'orange', 'purple', 'blue', 'green']
highlight_key = 'highlight'
-
color = el.get(highlight_key)
- if color is not None and color in valid_colors:
- cls.append('highlight-'+color)
- attr['_delete'] = highlight_key
+ if color is not None:
+ if color in self.highlight_colors:
+ cls.append('highlight-'+color)
+ attr['_delete'] = highlight_key
attr['value'] = ' '.join(cls)
return { 'class' : attr }
@@ -120,6 +119,7 @@ class AnnotatableModule(XModule):
self.instructions = self._extract_instructions(xmltree)
self.content = etree.tostring(xmltree, encoding='unicode')
self.element_id = self.location.html_id()
+ self.highlight_colors = ['yellow', 'orange', 'purple', 'blue', 'green']
class AnnotatableDescriptor(RawDescriptor):
module_class = AnnotatableModule
diff --git a/common/lib/xmodule/xmodule/tests/test_annotatable_module.py b/common/lib/xmodule/xmodule/tests/test_annotatable_module.py
index 7a87dcc16d..3a470879e8 100644
--- a/common/lib/xmodule/xmodule/tests/test_annotatable_module.py
+++ b/common/lib/xmodule/xmodule/tests/test_annotatable_module.py
@@ -45,6 +45,70 @@ class AnnotatableModuleTestCase(unittest.TestCase):
'data-problem-id': {'value': '0', '_delete': 'problem'}
}
- data_attr = self.annotatable._get_annotation_data_attr(0, el)
- self.assertTrue(type(data_attr) is dict)
- self.assertDictEqual(expected_attr, data_attr)
\ No newline at end of file
+ actual_attr = self.annotatable._get_annotation_data_attr(0, el)
+
+ self.assertTrue(type(actual_attr) is dict)
+ self.assertDictEqual(expected_attr, actual_attr)
+
+ def test_annotation_class_attr_default(self):
+ xml = '