diff --git a/common/lib/xmodule/xmodule/imageannotation_module.py b/common/lib/xmodule/xmodule/imageannotation_module.py index e5a3306f7cfe..c6dc50d9cefa 100644 --- a/common/lib/xmodule/xmodule/imageannotation_module.py +++ b/common/lib/xmodule/xmodule/imageannotation_module.py @@ -9,6 +9,7 @@ from xblock.core import Scope, String from xmodule.annotator_mixin import get_instructions, html_to_text from xmodule.annotator_token import retrieve_token +from xblock.fragment import Fragment import textwrap @@ -94,7 +95,7 @@ def _extract_instructions(self, xmltree): """ Removes from the xmltree and returns them as a string, otherwise None. """ return get_instructions(xmltree) - def get_html(self): + def student_view(self, context): """ Renders parameters to template. """ context = { 'display_name': self.display_name_with_default, @@ -105,7 +106,10 @@ def get_html(self): 'openseadragonjson': self.openseadragonjson, } - return self.system.render_template('imageannotation.html', context) + fragment = Fragment(self.system.render_template('imageannotation.html', context)) + fragment.add_javascript_url("/static/js/vendor/tinymce/js/tinymce/tinymce.full.min.js") + fragment.add_javascript_url("/static/js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js") + return fragment class ImageAnnotationDescriptor(AnnotatableFields, RawDescriptor): # pylint: disable=abstract-method diff --git a/common/lib/xmodule/xmodule/tests/test_imageannotation.py b/common/lib/xmodule/xmodule/tests/test_imageannotation.py index c19ffc25d069..531d4784ac40 100644 --- a/common/lib/xmodule/xmodule/tests/test_imageannotation.py +++ b/common/lib/xmodule/xmodule/tests/test_imageannotation.py @@ -69,10 +69,10 @@ def test_extract_instructions(self): actual = self.mod._extract_instructions(xmltree) # pylint: disable=protected-access self.assertIsNone(actual) - def test_get_html(self): + def test_student_view(self): """ Tests the function that passes in all the information in the context that will be used in templates/textannotation.html """ - context = self.mod.get_html() + context = self.mod.student_view({}).content for key in ['display_name', 'instructions_html', 'annotation_storage', 'token', 'tag', 'openseadragonjson']: self.assertIn(key, context) diff --git a/common/lib/xmodule/xmodule/tests/test_textannotation.py b/common/lib/xmodule/xmodule/tests/test_textannotation.py index 907eb787802d..31d420dd088b 100644 --- a/common/lib/xmodule/xmodule/tests/test_textannotation.py +++ b/common/lib/xmodule/xmodule/tests/test_textannotation.py @@ -54,10 +54,10 @@ def test_extract_instructions(self): actual = self.mod._extract_instructions(xmltree) # pylint: disable=W0212 self.assertIsNone(actual) - def test_get_html(self): + def test_student_view(self): """ Tests the function that passes in all the information in the context that will be used in templates/textannotation.html """ - context = self.mod.get_html() + context = self.mod.student_view({}).content for key in ['display_name', 'tag', 'source', 'instructions_html', 'content_html', 'annotation_storage', 'token']: self.assertIn(key, context) diff --git a/common/lib/xmodule/xmodule/tests/test_videoannotation.py b/common/lib/xmodule/xmodule/tests/test_videoannotation.py index 410d39d4b18f..0dc1a5d90274 100644 --- a/common/lib/xmodule/xmodule/tests/test_videoannotation.py +++ b/common/lib/xmodule/xmodule/tests/test_videoannotation.py @@ -62,10 +62,10 @@ def test_get_extension(self): self.assertEqual(expectedyoutube, result2) self.assertEqual(expectednotyoutube, result1) - def test_get_html(self): + def test_student_view(self): """ Tests to make sure variables passed in truly exist within the html once it is all rendered. """ - context = self.mod.get_html() + context = self.mod.student_view({}).content for key in ['display_name', 'instructions_html', 'sourceUrl', 'typeSource', 'poster', 'annotation_storage']: self.assertIn(key, context) diff --git a/common/lib/xmodule/xmodule/textannotation_module.py b/common/lib/xmodule/xmodule/textannotation_module.py index 9468f7e58f3d..afbdd86f2766 100644 --- a/common/lib/xmodule/xmodule/textannotation_module.py +++ b/common/lib/xmodule/xmodule/textannotation_module.py @@ -8,7 +8,7 @@ from xblock.core import Scope, String from xmodule.annotator_mixin import get_instructions from xmodule.annotator_token import retrieve_token - +from xblock.fragment import Fragment import textwrap # Make '_' a no-op so we can scrape strings @@ -73,7 +73,7 @@ def _extract_instructions(self, xmltree): """ Removes from the xmltree and returns them as a string, otherwise None. """ return get_instructions(xmltree) - def get_html(self): + def student_view(self, context): """ Renders parameters to template. """ context = { 'course_key': self.runtime.course_id, @@ -85,7 +85,10 @@ def get_html(self): 'annotation_storage': self.annotation_storage_url, 'token': retrieve_token(self.user_email, self.annotation_token_secret), } - return self.system.render_template('textannotation.html', context) + fragment = Fragment(self.system.render_template('textannotation.html', context)) + fragment.add_javascript_url("/static/js/vendor/tinymce/js/tinymce/tinymce.full.min.js") + fragment.add_javascript_url("/static/js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js") + return fragment class TextAnnotationDescriptor(AnnotatableFields, RawDescriptor): diff --git a/common/lib/xmodule/xmodule/videoannotation_module.py b/common/lib/xmodule/xmodule/videoannotation_module.py index 564d19b18296..72e3d8cab5c2 100644 --- a/common/lib/xmodule/xmodule/videoannotation_module.py +++ b/common/lib/xmodule/xmodule/videoannotation_module.py @@ -9,6 +9,7 @@ from xblock.core import Scope, String from xmodule.annotator_mixin import get_instructions, get_extension from xmodule.annotator_token import retrieve_token +from xblock.fragment import Fragment import textwrap @@ -72,7 +73,7 @@ def _get_extension(self, src_url): ''' get the extension of a given url ''' return get_extension(src_url) - def get_html(self): + def student_view(self, context): """ Renders parameters to template. """ extension = self._get_extension(self.sourceurl) @@ -87,8 +88,10 @@ def get_html(self): 'annotation_storage': self.annotation_storage_url, 'token': retrieve_token(self.user_email, self.annotation_token_secret), } - - return self.system.render_template('videoannotation.html', context) + fragment = Fragment(self.system.render_template('videoannotation.html', context)) + fragment.add_javascript_url("/static/js/vendor/tinymce/js/tinymce/tinymce.full.min.js") + fragment.add_javascript_url("/static/js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js") + return fragment class VideoAnnotationDescriptor(AnnotatableFields, RawDescriptor): diff --git a/lms/templates/imageannotation.html b/lms/templates/imageannotation.html index 3342d296bb0f..e815c495063b 100644 --- a/lms/templates/imageannotation.html +++ b/lms/templates/imageannotation.html @@ -31,8 +31,6 @@ <%namespace name='static' file='/static_content.html'/> ${static.css(group='style-vendor-tinymce-content', raw=True)} ${static.css(group='style-vendor-tinymce-skin', raw=True)} -