From 18233ef0d78a9ab390444ded01f7e9b6ad5d6045 Mon Sep 17 00:00:00 2001
From: Arthur Barrett
Date: Tue, 26 Feb 2013 12:15:43 -0500
Subject: [PATCH] bolded the section titles and added unittest skeleton for
module
---
.../lib/xmodule/xmodule/annotatable_module.py | 29 +++++++------
.../xmodule/css/annotatable/display.scss | 5 ++-
.../xmodule/tests/test_annotatable_module.py | 42 ++++++++++++++++++-
lms/templates/annotatable.html | 6 ++-
4 files changed, 65 insertions(+), 17 deletions(-)
diff --git a/common/lib/xmodule/xmodule/annotatable_module.py b/common/lib/xmodule/xmodule/annotatable_module.py
index 7a0adc0bf2..9e492f755a 100644
--- a/common/lib/xmodule/xmodule/annotatable_module.py
+++ b/common/lib/xmodule/xmodule/annotatable_module.py
@@ -63,26 +63,29 @@ class AnnotatableModule(XModule):
return data_attrs
+ def _render_annotation(self, index, el):
+ """ Renders an annotation element for HTML output. """
+ attr = {}
+ attr.update(self._get_annotation_class_attr(index, el))
+ attr.update(self._get_annotation_data_attr(index, el))
+
+ el.tag = 'span'
+
+ for key in attr.keys():
+ el.set(key, attr[key]['value'])
+ if '_delete' in attr[key] and attr[key]['_delete'] is not None:
+ delete_key = attr[key]['_delete']
+ del el.attrib[delete_key]
+
+
def _render_content(self):
""" Renders annotatable content with annotation spans and returns HTML. """
-
xmltree = etree.fromstring(self.content)
xmltree.tag = 'div'
index = 0
for el in xmltree.findall('.//annotation'):
- el.tag = 'span'
-
- attr = {}
- attr.update(self._get_annotation_class_attr(index, el))
- attr.update(self._get_annotation_data_attr(index, el))
-
- for key in attr.keys():
- el.set(key, attr[key]['value'])
- if '_delete' in attr[key] and attr[key]['_delete'] is not None:
- delete_key = attr[key]['_delete']
- del el.attrib[delete_key]
-
+ self._render_annotation(index, el)
index += 1
return etree.tostring(xmltree, encoding='unicode')
diff --git a/common/lib/xmodule/xmodule/css/annotatable/display.scss b/common/lib/xmodule/xmodule/css/annotatable/display.scss
index eef4ab28b7..fc22537899 100644
--- a/common/lib/xmodule/xmodule/css/annotatable/display.scss
+++ b/common/lib/xmodule/xmodule/css/annotatable/display.scss
@@ -14,7 +14,10 @@
border-radius: .5em;
margin-bottom: .5em;
- .annotatable-section-title {}
+ .annotatable-section-title {
+ font-weight: bold;
+ a { font-weight: normal; }
+ }
.annotatable-section-body {
border-top: 1px solid $border-color;
margin-top: .5em;
diff --git a/common/lib/xmodule/xmodule/tests/test_annotatable_module.py b/common/lib/xmodule/xmodule/tests/test_annotatable_module.py
index 5d270d2350..422372b1b0 100644
--- a/common/lib/xmodule/xmodule/tests/test_annotatable_module.py
+++ b/common/lib/xmodule/xmodule/tests/test_annotatable_module.py
@@ -1,7 +1,47 @@
"""Module annotatable tests"""
import unittest
-from xmodule import annotatable
+
+from lxml import etree
+from mock import Mock
+
+from xmodule.annotatable_module import AnnotatableModule
+from xmodule.modulestore import Location
+
+from . import test_system
class AnnotatableModuleTestCase(unittest.TestCase):
+ location = Location(["i4x", "edX", "toy", "annotatable", "guided_discussion"])
+ sample_text = '''
+
+ Read the text.
+
+ Sing,
+ O goddess,
+ the anger of Achilles son of Peleus,
+ that brought countless ills upon the Achaeans. Many a brave soul did it send
+ hurrying down to Hades, and many a hero did it yield a prey to dogs and
+
vultures, for so were the counsels
+ of Jove fulfilled from the day on which the son of Atreus, king of men, and great
+ Achilles, first fell out with one another.
+
+ The Iliad of Homer by Samuel Butler
+
+ '''
+ definition = { 'data': sample_text }
+ descriptor = Mock()
+ instance_state = None
+ shared_state = None
+ annotation_el = {
+ 'tag': 'annotation',
+ 'attrib': [
+ 'title',
+ 'body', # required
+ 'problem',
+ 'highlight'
+ ]
+ }
+
+ def setUp(self):
+ self.annotatable = AnnotatableModule(test_system, self.location, self.definition, self.descriptor, self.instance_state, self.shared_state)
diff --git a/lms/templates/annotatable.html b/lms/templates/annotatable.html
index abefe77f1b..bdb5a8acc3 100644
--- a/lms/templates/annotatable.html
+++ b/lms/templates/annotatable.html
@@ -18,8 +18,10 @@
% endif
${content_html}