From 248ce8803bc7ef921c9639b5b438ff68b9b6f2c7 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 8 Mar 2013 15:09:59 -0500 Subject: [PATCH] Make annotable module use the new xmodule format --- .../lib/xmodule/xmodule/annotatable_module.py | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/common/lib/xmodule/xmodule/annotatable_module.py b/common/lib/xmodule/xmodule/annotatable_module.py index 58ecfb9131..ceeef6d004 100644 --- a/common/lib/xmodule/xmodule/annotatable_module.py +++ b/common/lib/xmodule/xmodule/annotatable_module.py @@ -8,6 +8,7 @@ from xmodule.raw_module import RawDescriptor from xmodule.modulestore.mongo import MongoModuleStore from xmodule.modulestore.django import modulestore from xmodule.contentstore.content import StaticContent +from xblock.core import Scope, String log = logging.getLogger(__name__) @@ -22,6 +23,18 @@ class AnnotatableModule(XModule): css = {'scss': [resource_string(__name__, 'css/annotatable/display.scss')]} icon_class = 'annotatable' + data = String(help="XML data for the annotation", scope=Scope.content) + + def __init__(self, *args, **kwargs): + XModule.__init__(self, *args, **kwargs) + + xmltree = etree.fromstring(self.data) + + self.instructions = self._extract_instructions(xmltree) + self.content = etree.tostring(xmltree, encoding='unicode') + self.element_id = self.location.html_id() + self.highlight_colors = ['yellow', 'orange', 'purple', 'blue', 'green'] + def _get_annotation_class_attr(self, index, el): """ Returns a dict with the CSS class attribute to set on the annotation and an XML key to delete from the element. @@ -111,17 +124,6 @@ class AnnotatableModule(XModule): return self.system.render_template('annotatable.html', context) - def __init__(self, system, location, definition, descriptor, - instance_state=None, shared_state=None, **kwargs): - XModule.__init__(self, system, location, definition, descriptor, - instance_state, shared_state, **kwargs) - - xmltree = etree.fromstring(self.definition['data']) - - self.instructions = self._extract_instructions(xmltree) - self.content = etree.tostring(xmltree, encoding='unicode') - self.element_id = self.location.html_id() - self.highlight_colors = ['yellow', 'orange', 'purple', 'blue', 'green'] class AnnotatableDescriptor(RawDescriptor): module_class = AnnotatableModule