當前位置: 首頁>>代碼示例>>Python>>正文


Python fragment.Fragment方法代碼示例

本文整理匯總了Python中xblock.fragment.Fragment方法的典型用法代碼示例。如果您正苦於以下問題:Python fragment.Fragment方法的具體用法?Python fragment.Fragment怎麽用?Python fragment.Fragment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xblock.fragment的用法示例。


在下文中一共展示了fragment.Fragment方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: student_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def student_view(self, context):  # pylint: disable=unused-argument
        """
        Player view, displayed to the student
        """
        fragment = Fragment()

        fragment.add_content(RESOURCE_LOADER.render_django_template(
            DOCUMENT_TEMPLATE,
            context={"self": self},
            i18n_service=self.runtime.service(self, 'i18n'),
        ))
        fragment.add_css(RESOURCE_LOADER.load_unicode('public/css/google_docs.css'))
        fragment.add_javascript(RESOURCE_LOADER.load_unicode('public/js/google_docs.js'))

        fragment.initialize_js('GoogleDocumentBlock')

        return fragment

    # Context argument is specified for xblocks, but we are not using herein 
開發者ID:edx-solutions,項目名稱:xblock-google-drive,代碼行數:21,代碼來源:google_docs.py

示例2: studio_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def studio_view(self, context):  # pylint: disable=unused-argument
        """
        Editing view in Studio
        """
        fragment = Fragment()
        # Need to access protected members of fields to get their default value
        default_name = self.fields['display_name']._default  # pylint: disable=protected-access,unsubscriptable-object
        fragment.add_content(RESOURCE_LOADER.render_template(DOCUMENT_EDIT_TEMPLATE, {
            'self': self,
            'defaultName': default_name,
        }))
        fragment.add_javascript(RESOURCE_LOADER.load_unicode('public/js/google_docs_edit.js'))
        fragment.add_css(RESOURCE_LOADER.load_unicode('public/css/google_edit.css'))

        fragment.initialize_js('GoogleDocumentEditBlock')

        return fragment

    # suffix argument is specified for xblocks, but we are not using herein 
開發者ID:edx-solutions,項目名稱:xblock-google-drive,代碼行數:21,代碼來源:google_docs.py

示例3: student_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def student_view(self, context):  # pylint: disable=unused-argument
        """
        Player view, displayed to the student
        """
        fragment = Fragment()

        fragment.add_content(RESOURCE_LOADER.render_django_template(
            CALENDAR_TEMPLATE,
            context={
                "mode": self.views[self.default_view][1],
                "src": self.calendar_id,
                "title": self.display_name,
                "language": utils.translation.get_language(),
            },
            i18n_service=self.runtime.service(self, "i18n"),
        ))
        fragment.add_css(RESOURCE_LOADER.load_unicode('public/css/google_calendar.css'))
        fragment.add_javascript(RESOURCE_LOADER.load_unicode('public/js/google_calendar.js'))

        fragment.initialize_js('GoogleCalendarBlock')

        return fragment

    # Context argument is specified for xblocks, but we are not using herein 
開發者ID:edx-solutions,項目名稱:xblock-google-drive,代碼行數:26,代碼來源:google_calendar.py

示例4: studio_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def studio_view(self, context):  # pylint: disable=unused-argument
        """
        Editing view in Studio
        """
        fragment = Fragment()
        # Need to access protected members of fields to get their default value
        default_name = self.fields['display_name']._default  # pylint: disable=protected-access,unsubscriptable-object
        fragment.add_content(RESOURCE_LOADER.render_template(CALENDAR_EDIT_TEMPLATE, {
            'self': self,
            'defaultName': default_name,
            'defaultID': self.fields['calendar_id']._default  # pylint: disable=protected-access,unsubscriptable-object
        }))
        fragment.add_javascript(RESOURCE_LOADER.load_unicode('public/js/google_calendar_edit.js'))
        fragment.add_css(RESOURCE_LOADER.load_unicode('public/css/google_edit.css'))

        fragment.initialize_js('GoogleCalendarEditBlock')

        return fragment

    # suffix argument is specified for xblocks, but we are not using herein 
開發者ID:edx-solutions,項目名稱:xblock-google-drive,代碼行數:22,代碼來源:google_calendar.py

示例5: student_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def student_view(self, context):
        """Provide the default student view."""
        # WARNING: This assumes that the XBlock container does not refresh
        # or redirect pages so that the location hash disappears. It also
        # assumes that there are no other hashes.

        user_id = self._get_current_user_id()
        room_id = self.user_id_to_room_id.get(user_id, '')

        frag = Fragment(self._jinja_env.get_template(
            self.STUDENT_TEMPLATE_PATH).render({'room_id': room_id}))
        frag.add_css(self._get_resource_string(
            'public/lib/candy/res/default.css'))
        frag.add_css(self._get_resource_string('public/css/chat.css'))
        frag.add_javascript(self._get_resource_string(self.STUDENT_JS_PATH))
        js_dep_paths = [
            'public/lib/candy/libs/libs.min.js',
            'public/lib/candy/candy.bundle.js',
        ]
        for js_dep_path in js_dep_paths:
            frag.add_javascript(self._get_resource_string(js_dep_path))

        frag.initialize_js('Chat')
        return frag 
開發者ID:google,項目名稱:realtime-help,代碼行數:26,代碼來源:chat.py

示例6: studio_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def studio_view(self, context=None):
        """
        The secondary view of the XBlock, shown to teachers
        when editing the XBlock.
        """
        context = {
            'display_name': self.display_name,
            'url': self.url,
            'allow_download': self.allow_download,
            'source_text': self.source_text,
            'source_url': self.source_url,
            'start_time': self.start_time,
            'end_time': self.end_time
        }
        html = self.render_template('static/html/videojs_edit.html', context)
        
        frag = Fragment(html)
        frag.add_javascript(self.load_resource("static/js/videojs_edit.js"))
        frag.initialize_js('videojsXBlockInitStudio')
        return frag 
開發者ID:MarCnu,項目名稱:videojsXBlock,代碼行數:22,代碼來源:videojs.py

示例7: studio_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def studio_view(self, context=None):
        """
        The secondary view of the XBlock, shown to teachers
        when editing the XBlock.
        """
        context = {
            'display_name': self.display_name,
            'app_id' : self.app_id,
            'file_id': self.file_id,
            'width': self.width,
            'height': self.height
        }
        html = self.render_template('static/html/youku_edit.html', context)

        frag = Fragment(html)
        frag.add_javascript(self.load_resource("static/js/youku_edit.js"))
        frag.initialize_js('youkuXBlockInitStudio')
        return frag 
開發者ID:wwj718,項目名稱:youkuXBlock,代碼行數:20,代碼來源:youku.py

示例8: student_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def student_view(self, context=None):
        base = reverse('xblock_jupyter_viewer:jupyter_nb_viewer') + "?{}"

        # setup start/end tags
        if self.start_tag != '':
            base += "&{}".format(urlencode({'start': self.start_tag}))
        if self.end_tag != '':
            base += "&{}".format(urlencode({'end': self.end_tag}))
        # Add Image root
        base += "&{}".format(urlencode({'images_url': self.image_url}))

        # setup full url and inject into template iframe
        full_url = base.format(urlencode({'url': self.jupyter_url}))
        log.debug("Full URL: {}".format(full_url))
        base_html = self.resource_string('static/html/student_view.html')\
            .format(self.xblock_height, full_url)
        
        # add html and css
        frag = Fragment(base_html)
        # frag.add_css(self.resource_string('static/css/style.css'))
        return frag

    # TO-DO: change this to create the scenarios you'd like to see in the
    # workbench while developing your XBlock. 
開發者ID:ibleducation,項目名稱:jupyter-edx-viewer-xblock,代碼行數:26,代碼來源:xblock_jupyter_viewer.py

示例9: student_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def student_view(self, context=None):
        context_html = self.get_context_student()
        template = self.render_template('static/html/scormxblock.html', context_html)
        frag = Fragment(template)
        frag.add_css(self.resource_string("static/css/scormxblock.css"))
        frag.add_javascript(self.resource_string("static/js/src/scormxblock.js"))
        settings = {
            'version_scorm': self.version_scorm
        }
        frag.initialize_js('ScormXBlock', json_args=settings)
        return frag 
開發者ID:raccoongang,項目名稱:edx_xblock_scorm,代碼行數:13,代碼來源:scormxblock.py

示例10: studio_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def studio_view(self, context=None):
        context_html = self.get_context_studio()
        template = self.render_template('static/html/studio.html', context_html)
        frag = Fragment(template)
        frag.add_css(self.resource_string("static/css/scormxblock.css"))
        frag.add_javascript(self.resource_string("static/js/src/studio.js"))
        frag.initialize_js('ScormStudioXBlock')
        return frag 
開發者ID:raccoongang,項目名稱:edx_xblock_scorm,代碼行數:10,代碼來源:scormxblock.py

示例11: author_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def author_view(self, context=None):
        html = self.render_template("static/html/author_view.html", context)
        frag = Fragment(html)
        return frag 
開發者ID:raccoongang,項目名稱:edx_xblock_scorm,代碼行數:6,代碼來源:scormxblock.py

示例12: get_frag

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def get_frag(self, **context):  # pylint: disable=unused-argument
        """
        Return a Fragment required to render video player on the client side.
        """
        return Fragment(u'[Here be Video]') 
開發者ID:appsembler,項目名稱:xblock-video,代碼行數:7,代碼來源:dummy.py

示例13: get_frag

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def get_frag(self, **context):
        """
        Compose an XBlock fragment with video player to be rendered in student view.

        Brightcove backend is a special case and doesn't use vanilla Video.js player.
        Because of this it doesn't use `super.get_frag()`.
        """
        context['player_state'] = json.dumps(context['player_state'])
        log.debug('CONTEXT: player_state: %s', context.get('player_state'))

        frag = Fragment(
            self.render_template('brightcove.html', **context)
        )
        frag.add_css_url(
            'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'
        )
        frag.add_javascript(
            self.render_resource('static/js/context.js', **context)
        )
        js_files = [
            'static/js/base.js',
            'static/vendor/js/array-from-polyfill.js',
            'static/js/student-view/player-state.js'
        ]
        js_files += [
            'static/js/videojs/videojs-tabindex.js',
            'static/js/videojs/toggle-button.js',
            'static/js/videojs/videojs-event-plugin.js',
            'static/js/videojs/brightcove-videojs-init.js',
        ]

        for js_file in js_files:
            frag.add_javascript(self.resource_string(js_file))

        frag.add_css(
            self.resource_string('static/css/brightcove.css')
        )
        log.debug("[get_frag] initialized scripts: %s", js_files)
        return frag 
開發者ID:appsembler,項目名稱:xblock-video,代碼行數:41,代碼來源:brightcove.py

示例14: student_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def student_view(self, _context=None):
        """
        The primary view of the `VideoXBlock`, shown to students when viewing courses.
        """
        player_url = self.runtime.handler_url(self, 'render_player')
        download_transcript_handler_url = self.runtime.handler_url(self, 'download_transcript')
        transcript_download_link = self.get_transcript_download_link()
        full_transcript_download_link = ''

        if transcript_download_link:
            full_transcript_download_link = download_transcript_handler_url + transcript_download_link

        context = {
            'player_url': player_url,
            'display_name': self.display_name,
            'usage_id': self.usage_id,
            'handout': self.handout,
            'transcripts': list(self.route_transcripts()),
            'download_transcript_allowed': self.download_transcript_allowed,
            'transcripts_streaming_enabled': self.threeplaymedia_streaming,
            'download_video_url': self.get_download_video_url(),
            'handout_file_name': self.get_file_name_from_path(self.handout),
            'transcript_download_link': full_transcript_download_link,
            'version': __version__
        }
        log.debug("[student_view_context]: transcripts %s", context['transcripts'])
        frag = Fragment(
            render_resource(
                'static/html/student_view.html',
                **context
            )
        )
        frag.add_javascript(resource_string("static/js/student-view/video-xblock.js"))
        frag.add_css(resource_string("static/css/student-view.css"))
        frag.initialize_js('VideoXBlockStudentViewInit')
        return frag 
開發者ID:appsembler,項目名稱:xblock-video,代碼行數:38,代碼來源:video_xblock.py

示例15: test_student_view

# 需要導入模塊: from xblock import fragment [as 別名]
# 或者: from xblock.fragment import Fragment [as 別名]
def test_student_view(self, route_transcripts, resource_string_mock, render_resource_mock):
        """
        Test xBlock's student view builds proper Fragment.
        """
        # Arrange
        unused_context_stub = object()
        render_resource_mock.return_value = u'<iframe/>'
        handler_url = self.xblock.runtime.handler_url = Mock()
        handler_url.side_effect = ['/player/url', '/transcript/download/url']
        route_transcripts.return_value = ['transcripts.vtt']
        self.xblock.get_transcript_download_link = Mock(return_value='/transcript/link.vtt')
        self.xblock.threeplaymedia_streaming = True

        # Act
        student_view = self.xblock.student_view(unused_context_stub)

        # Assert
        self.assertIsInstance(student_view, Fragment)
        render_resource_mock.assert_called_once_with(
            'static/html/student_view.html',
            display_name='Video',
            download_transcript_allowed=False,
            transcripts_streaming_enabled=True,
            download_video_url=False,
            handout='',
            handout_file_name='',
            player_url='/player/url',
            transcript_download_link='/transcript/download/url'+'/transcript/link.vtt',
            transcripts=['transcripts.vtt'],
            usage_id='usage_id',
            version=__version__,
        )
        resource_string_mock.assert_called_with('static/css/student-view.css')
        handler_url.assert_called_with(self.xblock, 'download_transcript')
        route_transcripts.assert_called_once_with() 
開發者ID:appsembler,項目名稱:xblock-video,代碼行數:37,代碼來源:test_video_xblock.py


注:本文中的xblock.fragment.Fragment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。