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