Skip to content
Snippets Groups Projects
Commit c6b477c8 authored by Calen Pennington's avatar Calen Pennington
Browse files

Use html safe IDs for sequences and videos

parent de07b8b3
No related merge requests found
......@@ -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
......
......@@ -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>', '<"+"/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}
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment