Commit 5379a9fd by Calen Pennington

Make the id property available on both modules and descriptors, and make it a…

Make the id property available on both modules and descriptors, and make it a property, so that we aren't duplicating the location data
parent 92e99d7a
......@@ -37,8 +37,6 @@ class PollFields(object):
answers = List(help="Poll answers from xml", scope=Scope.content, default=[])
question = String(help="Poll question", scope=Scope.content, default='')
id = String(help="ID attribute for this module", scope=Scope.settings)
class PollModule(PollFields, XModule):
"""Poll Module"""
......@@ -193,7 +191,6 @@ class PollDescriptor(PollFields, MakoModuleDescriptor, XmlDescriptor):
tag_name=self._tag_name, text=self.question)
xml_object = etree.fromstring(poll_str)
xml_object.set('display_name', self.display_name)
xml_object.set('id', self.id)
def add_child(xml_obj, answer):
child_str = '<{tag_name} id="{id}">{text}</{tag_name}>'.format(
......
......@@ -123,16 +123,19 @@ class XModule(XModuleFields, HTMLSnippet, XBlock):
model_data: A dictionary-like object that maps field names to values
for those fields.
'''
self._model_data = model_data
self.system = system
self.location = Location(location)
self.descriptor = descriptor
self.id = self.location.url()
self.url_name = self.location.name
self.category = self.location.category
self._model_data = model_data
self._loaded_children = None
@property
def id(self):
return self.location.url()
@property
def display_name_with_default(self):
'''
Return a display name for the module: use display_name if defined in
......@@ -394,6 +397,10 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock):
self._child_instances = None
@property
def id(self):
return self.location.url()
@property
def display_name_with_default(self):
'''
Return a display name for the module: use display_name if defined in
......
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