How to use the extensions.interactions.base function in extensions

To help you get started, we’ve selected a few extensions 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 oppia / oppia / extensions / interactions / CodeRepl / CodeRepl.py View on Github external
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, softwar
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Python configuration for CodeRepl interaction."""
from __future__ import absolute_import  # pylint: disable=import-only-modules

from extensions.interactions import base


class CodeRepl(base.BaseInteraction):
    """Interaction that allows programs to be input."""

    name = 'Code Editor'
    description = 'Allows learners to enter code and get it evaluated.'
    display_mode = base.DISPLAY_MODE_SUPPLEMENTAL
    is_trainable = True
    _dependency_ids = ['skulpt', 'codemirror']
    answer_type = 'CodeEvaluation'
    instructions = 'Type code in the editor'
    narrow_instructions = 'Go to code editor'
    needs_summary = True
    can_have_solution = True
    show_generic_submit_button = True

    # Language options 'lua', 'scheme', 'coffeescript', 'javascript', and
    # 'ruby' have been removed for possible later re-release.
github oppia / oppia / extensions / interactions / EndConversation / EndConversation.py View on Github external
from extensions.interactions import base


class EndConversation(base.BaseInteraction):
    """Interaction that allows the conversation to end.

    This interaction is unusual in that there is no way for the learner to
    submit an answer, so the exploration effectively terminates at the state
    containing it.
    """

    name = 'End Conversation'
    category = ''
    description = (
        'Suggests recommendations for explorations to try next.')
    display_mode = base.DISPLAY_MODE_SUPPLEMENTAL
    is_terminal = True
    _dependency_ids = []
    _handlers = [{
        'name': 'submit', 'obj_type': 'Null'
    }]

    _customization_arg_specs = [{
        'name': 'recommendedExplorationIds',
        'description': 'IDs of explorations to recommend to the learner.',
        'schema': {
            'type': 'list',
            'items': {
                'type': 'unicode',
            },
            'ui_config': {
                'add_element_text': 'Add exploration ID',
github oppia / oppia / extensions / interactions / MultipleChoiceInput / MultipleChoiceInput.py View on Github external
# See the License for the specific language governing permissions and
# limitations under the License.

"""Python configuration for MultipleChoiceInput interaction."""
from __future__ import absolute_import  # pylint: disable=import-only-modules

from extensions.interactions import base


class MultipleChoiceInput(base.BaseInteraction):
    """Interaction for multiple choice input."""

    name = 'Multiple Choice'
    description = (
        'Allows learners to select one of a list of multiple-choice options.')
    display_mode = base.DISPLAY_MODE_INLINE
    _dependency_ids = []
    answer_type = 'NonnegativeInt'
    instructions = None
    narrow_instructions = None
    needs_summary = False
    # Radio buttons get unselected when specifying a solution. This needs to be
    # fixed before solution feature can support this interaction.
    can_have_solution = False
    show_generic_submit_button = False

    _customization_arg_specs = [{
        'name': 'choices',
        'description': 'Multiple Choice options',
        'schema': {
            'type': 'list',
            'validators': [{
github oppia / oppia / extensions / interactions / ImageClickInput / ImageClickInput.py View on Github external
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Python configuration for ImageClickInput interaction."""
from __future__ import absolute_import  # pylint: disable=import-only-modules

from extensions.interactions import base


class ImageClickInput(base.BaseInteraction):
    """Interaction allowing multiple-choice selection on an image."""

    name = 'Image Region'
    description = 'Allows learners to click on regions of an image.'
    display_mode = base.DISPLAY_MODE_SUPPLEMENTAL
    _dependency_ids = []
    answer_type = 'ClickOnImage'
    instructions = 'Click on the image'
    narrow_instructions = 'View image'
    needs_summary = False
    # It is required to show which region is being clicked on while specifying
    # a solution. Once this issue is fixed, ImageClickInput interaction can be
    # supported by the solution feature.
    can_have_solution = False
    show_generic_submit_button = False

    _customization_arg_specs = [{
        'name': 'imageAndRegions',
        'description': 'Image',
        'schema': {
            'type': 'custom',
github oppia / oppia / extensions / interactions / MultipleChoiceInput / MultipleChoiceInput.py View on Github external
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, softwar
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Python configuration for MultipleChoiceInput interaction."""
from __future__ import absolute_import  # pylint: disable=import-only-modules

from extensions.interactions import base


class MultipleChoiceInput(base.BaseInteraction):
    """Interaction for multiple choice input."""

    name = 'Multiple Choice'
    description = (
        'Allows learners to select one of a list of multiple-choice options.')
    display_mode = base.DISPLAY_MODE_INLINE
    _dependency_ids = []
    answer_type = 'NonnegativeInt'
    instructions = None
    narrow_instructions = None
    needs_summary = False
    # Radio buttons get unselected when specifying a solution. This needs to be
    # fixed before solution feature can support this interaction.
    can_have_solution = False
    show_generic_submit_button = False
github oppia / oppia / extensions / interactions / CodeWithTests / CodeWithTests.py View on Github external
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, softwar
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from extensions.interactions import base


class CodeWithTests(base.BaseInteraction):
    """Interactive widget that allows programs to be input."""

    name = 'Code (learner writes a function)'
    category = 'Programming'
    description = 'Programming code widget with tests.'
    display_mode = base.DISPLAY_MODE_SUPPLEMENTAL
    _dependency_ids = ['jsrepl', 'codemirror']
    _handlers = [{
        'name': 'submit', 'obj_type': 'CodeWithTestResults'}]

    _customization_arg_specs = [{
        'name': 'language',
        'description': 'Programming language to evaluate the code in.',
        'schema': {
            'type': 'unicode',
            'choices': ['python']