示例#1
0
 def render(self, node, handler):
     if handler.can_record_student_events():
         tracking_text = (
             '<script src="' + os.path.join(
                 _STATIC_URL, 'js', 'html5_video.js') + '">' +
             '</script>' +
             '<script>' +
             '  gcbTagHtml5TrackVideo("%s");' % (
                 jinja_utils.js_string_raw(node.attrib.get('instanceid'))) +
             '</script>')
     else:
         tracking_text = ''
     video_text = (
         '<div>' +
         '  <video></video>'
         '%s' % tracking_text +
         '</div>')
     video = cElementTree.XML(video_text)
     video[0].set('id', node.attrib.get('instanceid'))
     video[0].set('src', node.attrib.get('url'))
     if node.attrib.get('width'):
         video[0].set('width', node.attrib.get('width'))
     if node.attrib.get('height'):
         video[0].set('height', node.attrib.get('height'))
     video[0].set('controls', 'true')
     return video
示例#2
0
 def render(self, node, unused_handler):
     if utils.CAN_PERSIST_TAG_EVENTS.value:
         tracking_text = (
             '<script src="' + os.path.join(
                 RESOURCE_FOLDER, 'html5_video.js') + '">' +
             '</script>' +
             '<script>' +
             '  gcbTagHtml5TrackVideo("%s");' % (
                 jinja_utils.js_string_raw(node.attrib.get('instanceid'))) +
             '</script>')
     else:
         tracking_text = ''
     video_text = (
         '<div>' +
         '  <video></video>'
         '%s' % tracking_text +
         '</div>')
     video = cElementTree.XML(video_text)
     video[0].set('id', node.attrib.get('instanceid'))
     video[0].set('src', node.attrib.get('url'))
     if node.attrib.get('width'):
         video[0].set('width', node.attrib.get('width'))
     if node.attrib.get('height'):
         video[0].set('height', node.attrib.get('height'))
     video[0].set('controls', 'true')
     return video
示例#3
0
 def render(self, node, handler):
     if handler.can_record_student_events():
         tracking_text = (
             '<script src="' + os.path.join(
                 _STATIC_URL, 'js', 'html5_video.js') + '">' +
             '</script>' +
             '<script>' +
             '  gcbTagHtml5TrackVideo("%s");' % (
                 jinja_utils.js_string_raw(node.attrib.get('instanceid'))) +
             '</script>')
     else:
         tracking_text = ''
     video_text = (
         '<div>' +
         '  <video></video>'
         '%s' % tracking_text +
         '</div>')
     video = cElementTree.XML(video_text)
     video[0].set('id', node.attrib.get('instanceid'))
     video[0].set('src', node.attrib.get('url'))
     if node.attrib.get('width'):
         video[0].set('width', node.attrib.get('width'))
     if node.attrib.get('height'):
         video[0].set('height', node.attrib.get('height'))
     video[0].set('controls', 'true')
     return video
示例#4
0
    def _render_with_tracking(self, video_id):
        """Embed video and enable event tracking."""
        video_id = jinja_utils.js_string_raw(video_id)
        return cElementTree.XML("""
<p>
    <script src='/extensions/tags/gcb/resources/youtube_video.js'></script>
    <script>
      gcbTagYoutubeEnqueueVideo('""" + video_id + """');
    </script>
</p>""")
    def _render_with_tracking(self, video_id):
        """Embed video and enable event tracking."""
        video_id = jinja_utils.js_string_raw(video_id)
        return cElementTree.XML("""
<p>
    <script src='/extensions/tags/gcb/resources/youtube_video.js'></script>
    <script>
      gcbTagYoutubeEnqueueVideo('""" + video_id + """');
    </script>
</p>""")
示例#6
0
    def _render_with_tracking(self, video_id):
        """Embed video and enable event tracking."""
        video_id = jinja_utils.js_string_raw(video_id)
        uid = common_utils.generate_instance_id()
        dom = cElementTree.XML("""
<p>
    <script></script>
    <script></script>
</p>""")
        dom.attrib['id'] = uid
        dom[0].attrib['src'] = os.path.join(RESOURCE_FOLDER, 'youtube_video.js')
        dom[1].text = 'gcbTagYoutubeEnqueueVideo("%s", "%s");' % (video_id, uid)
        return dom
示例#7
0
    def _render_with_tracking(self, video_id):
        """Embed video and enable event tracking."""
        video_id = jinja_utils.js_string_raw(video_id)
        uid = common_utils.generate_instance_id()
        dom = cElementTree.XML("""
<p>
    <script></script>
    <script></script>
</p>""")
        dom.attrib['id'] = uid
        dom[0].attrib['src'] = os.path.join(
            _STATIC_URL, 'js', 'youtube_video.js')
        dom[1].text = 'gcbTagYoutubeEnqueueVideo("%s", "%s");' % (video_id, uid)
        return dom
示例#8
0
 def render(self, node, unused_handler):
     if utils.CAN_PERSIST_TAG_EVENTS.value:
         tracking_text = (
             '<script src="' +
             os.path.join(RESOURCE_FOLDER, 'html5_video.js') + '">' +
             '</script>' + '<script>' + '  gcbTagHtml5TrackVideo("%s");' %
             (jinja_utils.js_string_raw(node.attrib.get('instanceid'))) +
             '</script>')
     else:
         tracking_text = ''
     video_text = ('<div>' + '  <video></video>'
                   '%s' % tracking_text + '</div>')
     video = cElementTree.XML(video_text)
     video[0].set('id', node.attrib.get('instanceid'))
     video[0].set('src', node.attrib.get('url'))
     if node.attrib.get('width'):
         video[0].set('width', node.attrib.get('width'))
     if node.attrib.get('height'):
         video[0].set('height', node.attrib.get('height'))
     video[0].set('controls', 'true')
     return video