How to use the xblock.fields.Scope.settings function in XBlock

To help you get started, we’ve selected a few XBlock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github edx / XBlock / xblock / core.py View on Github external
# -- Base Block
class XBlock(XmlSerializationMixin, HierarchyMixin, ScopedStorageMixin, RuntimeServicesMixin, HandlersMixin,
             IndexInfoMixin, ViewsMixin, SharedBlockBase):
    """Base class for XBlocks.

    Derive from this class to create a new kind of XBlock.  There are no
    required methods, but you will probably need at least one view.

    Don't provide the ``__init__`` method when deriving from this class.

    """
    entry_point = 'xblock.v1'

    name = String(help="Short name for the block", scope=Scope.settings)
    tags = List(help="Tags for this block", scope=Scope.settings)

    @class_lazy
    def _class_tags(cls):  # pylint: disable=no-self-argument
        """
        Collect the tags from all base classes.
        """
        class_tags = set()

        for base in cls.mro()[1:]:  # pylint: disable=no-member
            class_tags.update(getattr(base, '_class_tags', set()))

        return class_tags

    @staticmethod
    def tag(tags):
        """Returns a function that adds the words in `tags` as class tags to this class."""
github raccoongang / edx_xblock_scorm / scormxblock / scormxblock.py View on Github external
)
    success_status = String(
        scope=Scope.user_state,
        default='unknown'
    )
    data_scorm = Dict(
        scope=Scope.user_state,
        default={}
    )
    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
    )
github ibleducation / jupyter-edx-grader-xblock / xblock_jupyter_graded / xblock_jupyter_graded.py View on Github external
log = logging.getLogger(__name__)
loader = ResourceLoader(__name__)


@XBlock.needs("user")
class JupyterGradedXBlock(StudioEditableXBlockMixin, ScorableXBlockMixin,
        XBlock, StudioEditableBlock):

    # Makes LMS icon appear as a problem
    icon_class = "problem"

    # ------- External, Editable Fields -------
    display_name = String(
        display_name="Display Name", 
        default="Graded Jupyter Notebook",
        scope=Scope.settings,
        help="Name of this XBlock" 
    )

    instructions = String(
        help="Instructions displayed to Student",
        scope=Scope.content,
        display_name="Student Instructions",
        multiline_editor=True,
    )

    max_attempts = Integer(
        help="Max number of allowed submissions (0 = unlimited)",
        scope=Scope.settings,
        display_name="Allowed Submissions",
        default=0
    )
github edx / XBlock / xblock / core.py View on Github external
class XBlock(Plugin):
    """Base class for XBlocks.

    Derive from this class to create a new kind of XBlock.  There are no
    required methods, but you will probably need at least one view.

    Don't provide the ``__init__`` method when deriving from this class.

    """

    __metaclass__ = XBlockMetaclass

    entry_point = 'xblock.v1'

    parent = String(help='The id of the parent of this XBlock', default=None, scope=Scope.parent)
    name = String(help="Short name for the block", scope=Scope.settings)
    tags = List(help="Tags for this block", scope=Scope.settings)

    _class_tags = set()

    @classmethod
    def json_handler(cls, func):
        """Wrap a handler to consume and produce JSON.

        Rather than a Request object, the method will now be passed the
        JSON-decoded body of the request.  Any data returned by the function
        will be JSON-encoded and returned as the response.

        """
        @XBlock.handler
        @functools.wraps(func)
        def wrapper(self, request, suffix=''):
github ibleducation / jupyter-edx-viewer-xblock / xblock_jupyter_viewer / xblock_jupyter_viewer.py View on Github external
from django.core.urlresolvers import reverse

from xblock.core import XBlock
from xblock.fields import Scope, String, Integer
from xblock.fragment import Fragment
from xblockutils.studio_editable import StudioEditableXBlockMixin

log = logging.getLogger(__name__)


class JupyterViewerXBlock(XBlock, StudioEditableXBlockMixin):
    """iframe used with endpoint to render full/section of jupyter notebook"""

    display_name = String(
        display_name="Display Name", default="Jupyter Notebook Viewer",
        scope=Scope.settings,
        help="Name of this XBlock" 
    )

    jupyter_url = String(
        help="URL to the .ipynb File",
        scope=Scope.content,
        display_name="Notebook URL",
        default="http://path/to/file.ipynb"
    )

    image_url = String(
        help="(Optional) Absolute URL to images root (http://.../)",
        scope=Scope.content,
        display_name="Image Root URL",
        default=""
    )
github MarCnu / videojsXBlock / videojs / videojs.py View on Github external
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="",
        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.")
github edx / XBlock / xblock / core.py View on Github external
# -- Base Block
class XBlock(XmlSerializationMixin, HierarchyMixin, ScopedStorageMixin, RuntimeServicesMixin, HandlersMixin,
             IndexInfoMixin, ViewsMixin, SharedBlockBase):
    """Base class for XBlocks.

    Derive from this class to create a new kind of XBlock.  There are no
    required methods, but you will probably need at least one view.

    Don't provide the ``__init__`` method when deriving from this class.

    """
    entry_point = 'xblock.v1'

    name = String(help="Short name for the block", scope=Scope.settings)
    tags = List(help="Tags for this block", scope=Scope.settings)

    @class_lazy
    def _class_tags(cls):  # pylint: disable=no-self-argument
        """
        Collect the tags from all base classes.
        """
        class_tags = set()

        for base in cls.mro()[1:]:  # pylint: disable=no-member
            class_tags.update(getattr(base, '_class_tags', set()))

        return class_tags

    @staticmethod
    def tag(tags):
github ibleducation / jupyter-edx-grader-xblock / xblock_jupyter_graded / xblock_jupyter_graded.py View on Github external
help="Max number of allowed submissions (0 = unlimited)",
        scope=Scope.settings,
        display_name="Allowed Submissions",
        default=0
    )

    cell_timeout = Integer(
        help="Max seconds to wait for each cell to execute",
        scope=Scope.settings,
        display_name="Cell Timeout (s)",
        default=15
    )

    max_file_size = Integer(
        help="Max allowable file size of student uploaded file (Bytes)",
        scope=Scope.settings,
        display_name="Max File Size (B)",
        default=None
    )

    allow_network = Boolean (
        help="If True, allows network access from student notebook",
        scope=Scope.settings,
        display_name="Network Allowed",
        default=False
    )

    allow_graded_dl = Boolean (
        help="If True, allows student to download .html version of their autograded notebook",
        scope=Scope.settings,
        display_name="Allow Graded NB Download",
        default=False
github eduNEXT / flow-control-xblock / flow_control / flow.py View on Github external
for element in iterable:
        if element is None:
            return False
    return True


@XBlock.needs("i18n")
@XBlock.needs("user")
# pylint: disable=too-many-ancestors
class FlowCheckPointXblock(StudioEditableXBlockMixin, XBlock):
    """ FlowCheckPointXblock allows to take different
    learning paths based on a certain condition status """

    display_name = String(
        display_name="Display Name",
        scope=Scope.settings,
        default="Flow Control"
    )

    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)
github google / coursebuilder_xblock_module / src / modules / xblock_module / xblock_module.py View on Github external
def __init__(self, db_data):

        authored_data = xblock.field_data.ReadOnlyFieldData(db_data)
        student_data = db_data

        super(StudentFieldData, self).__init__({
            xblock.fields.Scope.content: authored_data,
            xblock.fields.Scope.settings: authored_data,
            xblock.fields.Scope.parent: authored_data,
            xblock.fields.Scope.children: authored_data,
            xblock.fields.Scope.user_state_summary: student_data,
            xblock.fields.Scope.user_state: student_data,
            xblock.fields.Scope.user_info: student_data,
            xblock.fields.Scope.preferences: student_data})