Make the id property available on both modules and descriptors, and make it a property, so that we aren't duplicating the location data

This commit is contained in:
Calen Pennington
2013-03-13 11:56:53 -04:00
parent 92e99d7a8b
commit 5379a9fd2b
2 changed files with 9 additions and 5 deletions

View File

@@ -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(

View File

@@ -123,15 +123,18 @@ 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):
'''
@@ -393,6 +396,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):
'''