How to use the runestone.common.runestonedirective.RunestoneIdDirective.option_spec function in runestone

To help you get started, we’ve selected a few runestone 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 RunestoneInteractive / RunestoneComponents / runestone / codelens / visualizer.py View on Github external
:breakline: Line to stop on and pop up a question dialog
   :python: either py2 or py3

    x = 0
    for i in range(10):
       x = x + i


config values (conf.py): 

- codelens_div_class - custom CSS class of the component's outermost div
    """

    required_arguments = 1
    optional_arguments = 1
    option_spec = RunestoneIdDirective.option_spec.copy()
    option_spec.update(
        {
            "tracedata": directives.unchanged,
            "caption": directives.unchanged,
            "showoutput": directives.flag,
            "question": directives.unchanged,
            "correct": directives.unchanged,
            "feedback": directives.unchanged,
            "breakline": directives.nonnegative_int,
            "python": directives.unchanged,
        }
    )

    has_content = True

    def run(self):
github RunestoneInteractive / RunestoneComponents / runestone / spreadsheet / spreadsheet.py View on Github external
class SpreadSheet(RunestoneIdDirective):
    """
    .. spreadsheet:: uniqueid
        :fromcsv: path/to/csv/file
        :colwidths: list of column widths
        :coltitles: list of column names
        :mindimensions: mincols, minrows  -- minDimensions:[10,5]

        A1,B1,C1,D1...
        A2,B2,C2,D2...
    """

    required_arguments = 1
    optional_arguments = 5
    has_content = True
    option_spec = RunestoneIdDirective.option_spec.copy()
    option_spec.update(
        {
            "fromcsv": directives.unchanged,
            "colwidths": directives.unchanged,
            "coltitles": directives.unchanged,
            "mindimensions": directives.unchanged,
        }
    )

    def run(self):
        super(SpreadSheet, self).run()
        env = self.state.document.settings.env

        self.options["divid"] = self.arguments[0].strip()

        if "====" in self.content:
github RunestoneInteractive / RunestoneComponents / runestone / external / external.py View on Github external
"""


class ExternalDirective(RunestoneIdDirective):
    """
.. external:: identifier

   Content  Everything here is part of the activity
   Content  Can include links...
    """

    required_arguments = 1
    optional_arguments = 0
    final_argument_whitespace = True
    has_content = True
    option_spec = RunestoneIdDirective.option_spec.copy()
    option_spec.update({"number": directives.positive_int})

    def run(self):
        super(ExternalDirective, self).run()
        addQuestionToDB(self)

        self.assert_has_content()  # make sure activity has something in it

        self.options["name"] = self.arguments[0].strip()

        external_node = ExternalNode(self.options, rawsource=self.block_text)
        external_node.source, external_node.line = self.state_machine.get_source_and_line(
            self.lineno
        )
        self.add_name(external_node)
github RunestoneInteractive / RunestoneComponents / runestone / dragndrop / dragndrop.py View on Github external
:match_1: Draggable element text|||Dropzone to be matched with text
    :match_2: Drag to Answer B|||Answer B
    :match_3: Draggable text|||Text of dropzone
    etc. (up to 20 matches)

    The question goes here.

config values (conf.py): 

- dragndrop_div_class - custom CSS class of the component's outermost div
    """

    required_arguments = 1
    optional_arguments = 0
    has_content = True
    option_spec = RunestoneIdDirective.option_spec.copy()
    option_spec.update(
        {
            "feedback": directives.unchanged,
            "match_1": directives.unchanged,
            "match_2": directives.unchanged,
            "match_3": directives.unchanged,
            "match_4": directives.unchanged,
            "match_5": directives.unchanged,
            "match_6": directives.unchanged,
            "match_7": directives.unchanged,
            "match_8": directives.unchanged,
            "match_9": directives.unchanged,
            "match_10": directives.unchanged,
            "match_11": directives.unchanged,
            "match_12": directives.unchanged,
            "match_13": directives.unchanged,
github RunestoneInteractive / RunestoneComponents / runestone / lp / lp.py View on Github external
..

"""
#
# _LpBuildButtonDirective
# ^^^^^^^^^^^^^^^^^^^^^^^
# This inserts a "save and run" button, along with the HTML/JavaScript which causes the current page to be tested by compiling and running it with its test bench, then reporting the results to the user. It must only be used on pages that are a program and have a test bench associated with them. Only one should appear on a given page.
class _LpBuildButtonDirective(RunestoneIdDirective):
    # The required argument is an id_ for this question.
    required_arguments = 1
    # No optional arguments.
    optional_arguments = 0
    # Per http://docutils.sourceforge.net/docs/howto/rst-directives.html, True if content is allowed. However, this isn't checked or enforced.
    has_content = False
    # Options. Everything but language is currently ignored. This is based on activecode, so in the future similar support would be provided for these options.
    option_spec = RunestoneIdDirective.option_spec.copy()
    option_spec.update(
        {
            "include": directives.unchanged,
            "language": directives.unchanged,
            "timelimit": directives.unchanged,
            "stdin": directives.unchanged,
            "datafile": directives.unchanged,
            "available_files": directives.unchanged,
            "builder": directives.unchanged,
        }
    )

    def run(self):
        super(_LpBuildButtonDirective, self).run()
        _assert_has_no_content(self)
        addQuestionToDB(self)
github RunestoneInteractive / RunestoneComponents / runestone / activecode / activecode.py View on Github external
the line containing four tilde ~
    ~~~~
    print("hello world")
    ====
    print("Hidden code, such as unit tests come after the four = signs")

config values (conf.py):

- activecode_div_class - custom CSS class of the component's outermost div
- activecode_hide_load_history - if True, hide the load history button
    """

    required_arguments = 1
    optional_arguments = 1
    has_content = True
    option_spec = RunestoneIdDirective.option_spec.copy()
    option_spec.update(
        {
            "nocanvas": directives.flag,
            "nopre": directives.flag,
            "above": directives.flag,  # put the canvas above the code
            "autorun": directives.flag,
            "caption": directives.unchanged,
            "include": directives.unchanged,
            "hidecode": directives.flag,
            "language": directives.unchanged,
            "chatcodes": directives.flag,
            "tour_1": directives.unchanged,
            "tour_2": directives.unchanged,
            "tour_3": directives.unchanged,
            "tour_4": directives.unchanged,
            "tour_5": directives.unchanged,
github RunestoneInteractive / RunestoneComponents / runestone / datafile / __init__.py View on Github external
class DataFile(RunestoneIdDirective):
    """
.. datafile:: identifier
   :edit: Option that makes the datafile editable
   :cols: If editable, number of columns--default is 20
   :rows: If editable, number of rows--default is 40
   :hide: Flag that sets a non-editable datafile to be hidden
   :fromfile: path to file that contains the data
   """

    required_arguments = 1
    optional_arguments = 0
    has_content = True
    option_spec = RunestoneIdDirective.option_spec.copy()
    option_spec.update(
        {
            "hide": directives.flag,
            "edit": directives.flag,
            "rows": directives.positive_int,
            "cols": directives.positive_int,
            "fromfile": directives.unchanged,
        }
    )

    def run(self):
        """
            process the multiplechoice directive and generate html for output.
            :param self:
            :return:
            .. datafile:: identifier
github RunestoneInteractive / RunestoneComponents / runestone / question / question.py View on Github external
class QuestionDirective(RunestoneIdDirective):
    """
.. question:: identifier
   :number: Force a number for this question

   Content  everything here is part of the question
   Content  It can be a lot...
    """

    required_arguments = 1
    optional_arguments = 0
    final_argument_whitespace = True
    has_content = True
    option_spec = RunestoneIdDirective.option_spec.copy()
    option_spec.update({"number": directives.positive_int})

    def run(self):
        super(QuestionDirective, self).run()
        self.assert_has_content()  # make sure question has something in it

        self.options["name"] = self.arguments[0].strip()

        question_node = QuestionNode(self.options, rawsource=self.block_text)
        question_node.source, question_node.line = self.state_machine.get_source_and_line(
            self.lineno
        )
        self.add_name(question_node)

        self.state.nested_parse(self.content, self.content_offset, question_node)
github RunestoneInteractive / RunestoneComponents / runestone / reveal / reveal.py View on Github external
.. reveal:: identifier
   :showtitle: Text on the 'show' button--default is "Show"
   :hidetitle: Text on the 'hide' button--default is "Hide"
   :modal: Boolean--if included, revealed display will be a modal
   :modaltitle: Title of modal dialog window--default is "Message from the author"
   :instructoronly: Only show button and contents to instructors

   Content  everything here will be hidden until revealed
   Content  It can be a lot...
    """

    required_arguments = 1
    optional_arguments = 0
    final_argument_whitespace = True
    has_content = True
    option_spec = RunestoneIdDirective.option_spec.copy()
    option_spec.update(
        {
            "showtitle": directives.unchanged,
            "hidetitle": directives.unchanged,
            "modal": directives.flag,
            "modaltitle": directives.unchanged,
            "instructoronly": directives.flag,
        }
    )

    def run(self):
        """
            process the reveal directive and generate html for output.
            :param self:
            :return:
            .. reveal:: identifier
github RunestoneInteractive / RunestoneComponents / runestone / clickableArea / clickable.py View on Github external
with the first number being the row and the second number being the column--use a column number of 0 to make the whole row correct (ex: 1,2;3,0 makes the 2nd data cell in the first row correct as well as the entire 3rd row)
    :incorrect: An array of the indices of the incorrect elements--same format as the correct elements.

    --Content--


config values (conf.py): 

- clickable_div_class - custom CSS class of the component's outermost div
    """

    required_arguments = 1
    optional_arguments = 0
    has_content = True
    final_argument_whitespace = True
    option_spec = RunestoneIdDirective.option_spec.copy()
    option_spec.update(
        {
            "question": directives.unchanged,
            "feedback": directives.unchanged,
            "iscode": directives.flag,
            "correct": directives.unchanged,
            "incorrect": directives.unchanged,
            "table": directives.flag,
        }
    )

    def run(self):
        """
            process the clickablearea directive and generate html for output.
            :param self:
            :return: