Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class TranscriptsMixin(XBlock):
"""
TranscriptsMixin class to encapsulate transcripts-related logic.
"""
THREE_PLAY_MEDIA_API_DOMAIN = 'https://static.3playmedia.com/'
threeplaymedia_streaming = Boolean(
default=False,
display_name=_('Direct 3PlayMedia'),
scope=Scope.content,
help=_("Direct <a href="http://www.3playmedia.com/">3PlayMedia</a> transcripts usage enabled.")
)
threeplaymedia_apikey = String(
default='',
display_name=_('3PlayMedia API Key'),
help=_('You can generate a client token following official documentation of your video platform\'s API.'),
scope=Scope.content,
resettable_editor=False
)
threeplaymedia_file_id = String(
default='',
display_name=_('File Id'),
help=_('3playmedia file id for download bind transcripts.'),
scope=Scope.content,
resettable_editor=False
)
@staticmethod
)
action = String(display_name="Action",
help="Select the action to be performed "
"when the condition is met",
scope=Scope.content,
default="display_message",
values_provider=_actions_generator)
condition = String(display_name="Flow control condition",
help="Select a conditon to evaluate",
scope=Scope.content,
default='single_problem',
values_provider=_conditions_generator)
operator = String(display_name="Comparison type",
help="Select an operator for the condition",
scope=Scope.content,
default='eq',
values_provider=_operators_generator)
ref_value = Integer(help="Enter the value to be used in "
"the comparison. (From 0 to 100)",
default=0,
scope=Scope.content,
display_name="Score percentage")
tab_to = Integer(help="Number of unit tab to redirect to. (1, 2, 3...)",
default=1,
scope=Scope.content,
display_name="Tab to redirect to")
"the comparison. (From 0 to 100)",
default=0,
scope=Scope.content,
display_name="Score percentage")
tab_to = Integer(help="Number of unit tab to redirect to. (1, 2, 3...)",
default=1,
scope=Scope.content,
display_name="Tab to redirect to")
target_url = String(help="URL to redirect to, supports relative "
"or absolute urls",
scope=Scope.content,
display_name="URL to redirect to")
target_id = String(help="Unit identifier to redirect to (Location id)",
scope=Scope.content,
display_name="Unit identifier to redirect to")
message = String(help="Message for the learners to view "
"when the condition is met",
scope=Scope.content,
default='',
display_name="Message",
multiline_editor='html')
problem_id = String(help="Problem id to use for the condition. (Not the "
"complete problem locator. Only the 32 characters "
"alfanumeric id. "
"Example: 618c5933b8b544e4a4cc103d3e508378)",
scope=Scope.content,
display_name="Problem id")
class VideoXBlock(
SettingsMixin, TranscriptsMixin, PlaybackStateMixin, LocationMixin,
StudioEditableXBlockMixin, ContentStoreMixin, WorkbenchMixin, XBlock
):
"""
Main VideoXBlock class, responsible for saving video settings and rendering it for students.
VideoXBlock only provide a storage facilities for fields data, but not
decide what fields to show to user. `BaseVideoPlayer` and it's subclassess
declare what fields are required for proper configuration of a video.
See `BaseVideoPlayer.basic_fields` and `BaseVideoPlayer.advanced_fields`.
"""
icon_class = "video"
display_name = String(
default=_('Video'),
display_name=_('Component Display Name'),
help=_('The name students see. This name appears in the course ribbon and as a header for the video.'),
scope=Scope.content,
)
href = String(
default='',
display_name=_('Video URL'),
help=_('URL of the video page. E.g. https://example.wistia.com/medias/12345abcde'),
scope=Scope.content
)
download_video_allowed = Boolean(
default=False,
scope=Scope.content,
@XBlock.json_handler
def on_select(self, data, suffix=''):
self.position = data.get('position', 0)
self.runtime.publish(self, {'position': self.position})
return {'position': self.position}
@XBlock.needs('jinja')
class VerticalBlock(XBlock):
"""An XBlock which presents its children in a vertical list.
See xmodule.vertical_module.VerticalModule in
https://github.com/edx/edx-platform.
"""
display_name = String(default=None, scope=Scope.content)
has_children = True
def __init__(self, *args, **kwargs):
super(VerticalBlock, self).__init__(*args, **kwargs)
self.templates_dirs = [os.path.join(os.path.dirname(__file__), 'templates')]
self.get_template = self.runtime.service(self, 'jinja')
def student_view(self, context=None):
template = self.get_template('vertical.html', self.templates_dirs)
child_frags = self.runtime.render_children(self, context=context)
result = Fragment()
result.add_frags_resources(child_frags)
result.add_content(template.render(
{'children': [frag.body_html() for frag in child_frags]}))
return result
import pkg_resources
from xblock.core import XBlock
from xblock.fields import Scope, Integer, String
from xblock.fragment import Fragment
class OppiaXBlock(XBlock):
"""
An XBlock providing an embedded Oppia exploration.
"""
# Note: These fields are defined on the class, and can be accessed in the
# code as self..
oppiaid = String(
help="ID of the Oppia exploration to embed",
default=None,
scope=Scope.content)
src = String(
help="Source URL of the site",
default="https://www.oppia.org",
scope=Scope.content)
width = Integer(
help="Width of the embedded exploration",
default=700,
scope=Scope.content)
height = Integer(
help="Height of the embedded exploration",
default=500,
scope=Scope.content)
)
lesson_score = Float(
scope=Scope.user_state,
default=0
)
weight = Float(
default=1,
scope=Scope.settings
)
has_score = Boolean(
display_name=_("Scored"),
help=_("Select False if this component will not receive a numerical score from the Scorm"),
default=True,
scope=Scope.settings
)
icon_class = String(
default="video",
scope=Scope.settings,
)
width = Integer(
display_name=_("Display Width (px)"),
help=_('Width of iframe, if empty, the default 100%'),
scope=Scope.settings
)
height = Integer(
display_name=_("Display Height (px)"),
help=_('Height of iframe'),
default=450,
scope=Scope.settings
)
has_author_view = True
from xblock.core import XBlock
from xblock.fields import Scope, Integer, String, Boolean
from xblock.fragment import Fragment
class videojsXBlock(XBlock):
'''
Icon of the XBlock. Values : [other (default), video, problem]
'''
icon_class = "video"
'''
Fields
'''
display_name = String(display_name="Display Name",
default="Video JS",
scope=Scope.settings,
help="This name appears in the horizontal navigation at the top of the page.")
url = String(display_name="Video URL",
default="http://vjs.zencdn.net/v/oceans.mp4",
scope=Scope.content,
help="The URL for your video.")
allow_download = Boolean(display_name="Video Download Allowed",
default=True,
scope=Scope.content,
help="Allow students to download this video.")
source_text = String(display_name="Source document button text",
default="",
help=_("Display name for this module"),
default="Scorm",
scope=Scope.settings,
)
scorm_file = String(
display_name=_("Upload scorm file"),
scope=Scope.settings,
)
path_index_page = String(
display_name=_("Path to the index page in scorm file"),
scope=Scope.settings,
)
scorm_file_meta = Dict(
scope=Scope.content
)
version_scorm = String(
default="SCORM_12",
scope=Scope.settings,
)
# save completion_status for SCORM_2004
lesson_status = String(
scope=Scope.user_state,
default='not attempted'
)
success_status = String(
scope=Scope.user_state,
default='unknown'
)
data_scorm = Dict(
scope=Scope.user_state,
default={}
)
source_text = String(display_name="Source document button text",
default="",
scope=Scope.content,
help="Add a download link for the source file of your video. Use it for example to provide the PowerPoint or PDF file used for this video.")
source_url = String(display_name="Source document URL",
default="",
scope=Scope.content,
help="Add a download link for the source file of your video. Use it for example to provide the PowerPoint or PDF file used for this video.")
start_time = String(display_name="Start time",
default="",
scope=Scope.content,
help="The start and end time of your video. Equivalent to 'video.mp4#t=startTime,endTime' in the url.")
end_time = String(display_name="End time",
default="",
scope=Scope.content,
help="The start and end time of your video. Equivalent to 'video.mp4#t=startTime,endTime' in the url.")
'''
Util functions
'''
def load_resource(self, resource_path):
"""
Gets the content of a resource
"""
resource_content = pkg_resources.resource_string(__name__, resource_path)
return unicode(resource_content)
def render_template(self, template_path, context={}):
"""