Make custom tags work in the LMS

This commit is contained in:
Calen Pennington
2012-06-28 08:56:18 -04:00
parent c140fe8766
commit bae90ab16d
3 changed files with 36 additions and 14 deletions

View File

@@ -1,14 +1,9 @@
import json
from x_module import XModule, XModuleDescriptor
from xmodule.x_module import XModule
from xmodule.raw_module import RawDescriptor
from lxml import etree
class ModuleDescriptor(XModuleDescriptor):
pass
class Module(XModule):
class CustomTagModule(XModule):
"""
This module supports tags of the form
<customtag option="val" option2="val2">
@@ -34,9 +29,13 @@ class Module(XModule):
def get_html(self):
return self.html
def __init__(self, system, xml, item_id, instance_state=None, shared_state=None):
XModule.__init__(self, system, xml, item_id, instance_state, shared_state)
xmltree = etree.fromstring(xml)
def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs)
xmltree = etree.fromstring(self.definition['data'])
filename = xmltree.find('impl').text
params = dict(xmltree.items())
self.html = self.system.render_template(filename, params, namespace='custom_tags')
class CustomTagDescriptor(RawDescriptor):
module_class = CustomTagModule