diff --git a/common/lib/keystore/__init__.py b/common/lib/keystore/__init__.py index 77f0213281..df9b72839e 100644 --- a/common/lib/keystore/__init__.py +++ b/common/lib/keystore/__init__.py @@ -113,6 +113,12 @@ class Location(object): url += "/" + self.revision return url + def html_id(self): + """ + Return a string with a version of the location that is safe for use in html id attributes + """ + return "-".join(str(v) for v in self.list() if v is not None) + def list(self): """ Return a list representing this location diff --git a/common/lib/xmodule/seq_module.py b/common/lib/xmodule/seq_module.py index b60f0e4656..b3ea6cf9cf 100644 --- a/common/lib/xmodule/seq_module.py +++ b/common/lib/xmodule/seq_module.py @@ -67,7 +67,7 @@ class SequenceModule(XModule): # of script, even if it occurs mid-string. Do this after json.dumps()ing # so that we can be sure of the quotations being used params = {'items': json.dumps(contents).replace('', '<"+"/script>'), - 'element_id': "-".join(str(v) for v in self.location.list()), + 'element_id': self.location.html_id(), 'item_id': self.id, 'position': self.position, 'tag': self.location.category} diff --git a/common/lib/xmodule/video_module.py b/common/lib/xmodule/video_module.py index 1585944cc9..020f8db899 100644 --- a/common/lib/xmodule/video_module.py +++ b/common/lib/xmodule/video_module.py @@ -46,7 +46,7 @@ class VideoModule(XModule): def get_html(self): return self.system.render_template('video.html', { 'streams': self.video_list(), - 'id': self.id, + 'id': self.location.html_id(), 'position': self.position, 'name': self.name, 'annotations': self.annotations,