Commit 643a7bfa by lduarte1991 Committed by David Baumgold

Annotation Tools: PR #3907

Annotation Tools: Load Tinymce in student_view

Annotation Tools: Fixing tests for student_view

Fixed typo from autocomplete

Fixed dict for tests
parent 0df70376
...@@ -9,6 +9,7 @@ from xmodule.raw_module import RawDescriptor ...@@ -9,6 +9,7 @@ from xmodule.raw_module import RawDescriptor
from xblock.core import Scope, String from xblock.core import Scope, String
from xmodule.annotator_mixin import get_instructions, html_to_text from xmodule.annotator_mixin import get_instructions, html_to_text
from xmodule.annotator_token import retrieve_token from xmodule.annotator_token import retrieve_token
from xblock.fragment import Fragment
import textwrap import textwrap
...@@ -91,7 +92,7 @@ class ImageAnnotationModule(AnnotatableFields, XModule): ...@@ -91,7 +92,7 @@ class ImageAnnotationModule(AnnotatableFields, XModule):
""" Removes <instructions> from the xmltree and returns them as a string, otherwise None. """ """ Removes <instructions> from the xmltree and returns them as a string, otherwise None. """
return get_instructions(xmltree) return get_instructions(xmltree)
def get_html(self): def student_view(self, context):
""" Renders parameters to template. """ """ Renders parameters to template. """
context = { context = {
'display_name': self.display_name_with_default, 'display_name': self.display_name_with_default,
...@@ -102,7 +103,10 @@ class ImageAnnotationModule(AnnotatableFields, XModule): ...@@ -102,7 +103,10 @@ class ImageAnnotationModule(AnnotatableFields, XModule):
'openseadragonjson': self.openseadragonjson, '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 class ImageAnnotationDescriptor(AnnotatableFields, RawDescriptor): # pylint: disable=abstract-method
......
...@@ -69,10 +69,10 @@ class ImageAnnotationModuleTestCase(unittest.TestCase): ...@@ -69,10 +69,10 @@ class ImageAnnotationModuleTestCase(unittest.TestCase):
actual = self.mod._extract_instructions(xmltree) # pylint: disable=protected-access actual = self.mod._extract_instructions(xmltree) # pylint: disable=protected-access
self.assertIsNone(actual) 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 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']: for key in ['display_name', 'instructions_html', 'annotation_storage', 'token', 'tag', 'openseadragonjson']:
self.assertIn(key, context) self.assertIn(key, context)
...@@ -54,10 +54,10 @@ class TextAnnotationModuleTestCase(unittest.TestCase): ...@@ -54,10 +54,10 @@ class TextAnnotationModuleTestCase(unittest.TestCase):
actual = self.mod._extract_instructions(xmltree) # pylint: disable=W0212 actual = self.mod._extract_instructions(xmltree) # pylint: disable=W0212
self.assertIsNone(actual) 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 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']: for key in ['display_name', 'tag', 'source', 'instructions_html', 'content_html', 'annotation_storage', 'token']:
self.assertIn(key, context) self.assertIn(key, context)
...@@ -62,10 +62,10 @@ class VideoAnnotationModuleTestCase(unittest.TestCase): ...@@ -62,10 +62,10 @@ class VideoAnnotationModuleTestCase(unittest.TestCase):
self.assertEqual(expectedyoutube, result2) self.assertEqual(expectedyoutube, result2)
self.assertEqual(expectednotyoutube, result1) 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. 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']: for key in ['display_name', 'instructions_html', 'sourceUrl', 'typeSource', 'poster', 'annotation_storage']:
self.assertIn(key, context) self.assertIn(key, context)
...@@ -8,7 +8,7 @@ from xmodule.raw_module import RawDescriptor ...@@ -8,7 +8,7 @@ from xmodule.raw_module import RawDescriptor
from xblock.core import Scope, String from xblock.core import Scope, String
from xmodule.annotator_mixin import get_instructions from xmodule.annotator_mixin import get_instructions
from xmodule.annotator_token import retrieve_token from xmodule.annotator_token import retrieve_token
from xblock.fragment import Fragment
import textwrap import textwrap
# Make '_' a no-op so we can scrape strings # Make '_' a no-op so we can scrape strings
...@@ -73,7 +73,7 @@ class TextAnnotationModule(AnnotatableFields, XModule): ...@@ -73,7 +73,7 @@ class TextAnnotationModule(AnnotatableFields, XModule):
""" Removes <instructions> from the xmltree and returns them as a string, otherwise None. """ """ Removes <instructions> from the xmltree and returns them as a string, otherwise None. """
return get_instructions(xmltree) return get_instructions(xmltree)
def get_html(self): def student_view(self, context):
""" Renders parameters to template. """ """ Renders parameters to template. """
context = { context = {
'course_key': self.runtime.course_id, 'course_key': self.runtime.course_id,
...@@ -85,7 +85,10 @@ class TextAnnotationModule(AnnotatableFields, XModule): ...@@ -85,7 +85,10 @@ class TextAnnotationModule(AnnotatableFields, XModule):
'annotation_storage': self.annotation_storage_url, 'annotation_storage': self.annotation_storage_url,
'token': retrieve_token(self.user_email, self.annotation_token_secret), '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): class TextAnnotationDescriptor(AnnotatableFields, RawDescriptor):
......
...@@ -9,6 +9,7 @@ from xmodule.raw_module import RawDescriptor ...@@ -9,6 +9,7 @@ from xmodule.raw_module import RawDescriptor
from xblock.core import Scope, String from xblock.core import Scope, String
from xmodule.annotator_mixin import get_instructions, get_extension from xmodule.annotator_mixin import get_instructions, get_extension
from xmodule.annotator_token import retrieve_token from xmodule.annotator_token import retrieve_token
from xblock.fragment import Fragment
import textwrap import textwrap
...@@ -72,7 +73,7 @@ class VideoAnnotationModule(AnnotatableFields, XModule): ...@@ -72,7 +73,7 @@ class VideoAnnotationModule(AnnotatableFields, XModule):
''' get the extension of a given url ''' ''' get the extension of a given url '''
return get_extension(src_url) return get_extension(src_url)
def get_html(self): def student_view(self, context):
""" Renders parameters to template. """ """ Renders parameters to template. """
extension = self._get_extension(self.sourceurl) extension = self._get_extension(self.sourceurl)
...@@ -87,8 +88,10 @@ class VideoAnnotationModule(AnnotatableFields, XModule): ...@@ -87,8 +88,10 @@ class VideoAnnotationModule(AnnotatableFields, XModule):
'annotation_storage': self.annotation_storage_url, 'annotation_storage': self.annotation_storage_url,
'token': retrieve_token(self.user_email, self.annotation_token_secret), 'token': retrieve_token(self.user_email, self.annotation_token_secret),
} }
fragment = Fragment(self.system.render_template('videoannotation.html', context))
return 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): class VideoAnnotationDescriptor(AnnotatableFields, RawDescriptor):
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
<%namespace name='static' file='/static_content.html'/> <%namespace name='static' file='/static_content.html'/>
${static.css(group='style-vendor-tinymce-content', raw=True)} ${static.css(group='style-vendor-tinymce-content', raw=True)}
${static.css(group='style-vendor-tinymce-skin', raw=True)} ${static.css(group='style-vendor-tinymce-skin', raw=True)}
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/tinymce.full.min.js', raw=True)}" />
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js', raw=True)}" />
</div> </div>
<div id="catchDIV"> <div id="catchDIV">
## Translators: Notes below refer to annotations. They wil later be put under a "Notes" section. ## Translators: Notes below refer to annotations. They wil later be put under a "Notes" section.
...@@ -180,7 +178,6 @@ ...@@ -180,7 +178,6 @@
optionsOSDA:{}, optionsOSDA:{},
}; };
tinymce.baseURL = "${settings.STATIC_URL}" + "js/vendor/tinymce/js/tinymce";
var imgURLRoot = "${settings.STATIC_URL}" + "js/vendor/ova/catch/img/"; var imgURLRoot = "${settings.STATIC_URL}" + "js/vendor/ova/catch/img/";
if (typeof Annotator != 'undefined'){ if (typeof Annotator != 'undefined'){
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
<%namespace name='static' file='/static_content.html'/> <%namespace name='static' file='/static_content.html'/>
${static.css(group='style-vendor-tinymce-content', raw=True)} ${static.css(group='style-vendor-tinymce-content', raw=True)}
${static.css(group='style-vendor-tinymce-skin', raw=True)} ${static.css(group='style-vendor-tinymce-skin', raw=True)}
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/tinymce.full.min.js', raw=True)}" />
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js', raw=True)}" />
<div class="annotatable-wrapper"> <div class="annotatable-wrapper">
<div class="annotatable-header"> <div class="annotatable-header">
...@@ -167,7 +165,6 @@ ${static.css(group='style-vendor-tinymce-skin', raw=True)} ...@@ -167,7 +165,6 @@ ${static.css(group='style-vendor-tinymce-skin', raw=True)}
}; };
var imgURLRoot = "${settings.STATIC_URL}" + "js/vendor/ova/catch/img/"; var imgURLRoot = "${settings.STATIC_URL}" + "js/vendor/ova/catch/img/";
tinymce.baseURL = "${settings.STATIC_URL}" + "js/vendor/tinymce/js/tinymce";
//remove old instances //remove old instances
if (Annotator._instances.length !== 0) { if (Annotator._instances.length !== 0) {
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
<%namespace name='static' file='/static_content.html'/> <%namespace name='static' file='/static_content.html'/>
${static.css(group='style-vendor-tinymce-content', raw=True)} ${static.css(group='style-vendor-tinymce-content', raw=True)}
${static.css(group='style-vendor-tinymce-skin', raw=True)} ${static.css(group='style-vendor-tinymce-skin', raw=True)}
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/tinymce.full.min.js', raw=True)}" />
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js', raw=True)}" />
<div class="annotatable-wrapper"> <div class="annotatable-wrapper">
<div class="annotatable-header"> <div class="annotatable-header">
...@@ -168,7 +165,6 @@ ${static.css(group='style-vendor-tinymce-skin', raw=True)} ...@@ -168,7 +165,6 @@ ${static.css(group='style-vendor-tinymce-skin', raw=True)}
}; };
var imgURLRoot = "${settings.STATIC_URL}" + "js/vendor/ova/catch/img/"; var imgURLRoot = "${settings.STATIC_URL}" + "js/vendor/ova/catch/img/";
tinymce.baseURL = "${settings.STATIC_URL}" + "js/vendor/tinymce/js/tinymce";
//remove old instances //remove old instances
if (Annotator._instances.length !== 0) { if (Annotator._instances.length !== 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment