How to use the runestone.activecode.activecode.ActiveCode 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 / activecode / activecode.py View on Github external
def setup(app):
    app.add_directive("activecode", ActiveCode)
    app.add_directive("actex", ActiveExercise)
    app.add_role("textfield", textfield_role)
    app.add_config_value(
        "activecode_div_class",
        "runestone explainer ac_section alert alert-warning",
        "html",
    )
    app.add_config_value("activecode_hide_load_history", False, "html")

    app.add_autoversioned_stylesheet("activecode.css")

    app.add_autoversioned_javascript("jquery.highlight.js")
    app.add_autoversioned_javascript("bookfuncs.js")
    add_codemirror_css_and_js(
        app, "xml", "css", "python", "htmlmixed", "javascript", "sql"
    )
github RunestoneInteractive / RunestoneComponents / runestone / activecode / activecode.py View on Github external
env = self.state.document.settings.env
        # keep track of how many activecodes we have.... could be used to automatically make a unique id for them.
        if not hasattr(env, 'activecodecounter'):
            env.activecodecounter = 0
        env.activecodecounter += 1

        self.options['divid'] = self.arguments[0]

        source = "\n".join(self.content)
        self.options['initialcode'] = source

        return [ActivcodeNode(self.options)]


if __name__ == '__main__':
    a = ActiveCode()
github RunestoneInteractive / RunestoneComponents / runestone / activecode / activecode.py View on Github external
print("")
                print(
                    "This should only affect the grading interface. Everything else should be fine."
                )

        acnode = ActivcodeNode(self.options, rawsource=self.block_text)
        acnode.source, acnode.line = self.state_machine.get_source_and_line(self.lineno)
        self.add_name(acnode)  # make this divid available as a target for :ref:

        if explain_text:
            self.state.nested_parse(explain_text, self.content_offset, acnode)

        return [acnode]


class ActiveExercise(ActiveCode):
    required_arguments = 1
    optional_arguments = 0
    has_content = True

    def run(self):
        self.options["hidecode"] = "data-hidecode=true"
        self.options["gradebutton"] = "data-gradebutton=true"
        self.options["coach"] = "data-coach=true"
        return super(ActiveExercise, self).run()


if __name__ == "__main__":
    a = ActiveCode()
github RunestoneInteractive / RunestoneComponents / runestone / activecode / activecode.py View on Github external
class ActiveExercise(ActiveCode):
    required_arguments = 1
    optional_arguments = 0
    has_content = True

    def run(self):
        self.options["hidecode"] = "data-hidecode=true"
        self.options["gradebutton"] = "data-gradebutton=true"
        self.options["coach"] = "data-coach=true"
        return super(ActiveExercise, self).run()


if __name__ == "__main__":
    a = ActiveCode()
github RunestoneInteractive / RunestoneComponents / runestone / activecode / activecode.py View on Github external
def setup(app):
    app.add_directive('activecode', ActiveCode)
    app.add_stylesheet('activecode.css')

    app.add_javascript('skulpt.min.js')
    app.add_javascript('skulpt-stdlib.js')
    app.add_javascript('codemirror.js')
    app.add_javascript('python.js')
    app.add_javascript('activecode.js')

    app.add_role('textfield', textfield_role)

    app.add_node(ActivcodeNode, html=(visit_ac_node, depart_ac_node))

    app.connect('doctree-resolved', process_activcode_nodes)
    app.connect('env-purge-doc', purge_activecodes)
github RunestoneInteractive / RunestoneComponents / runestone / activecode / activecode.py View on Github external
def run(self):
        super(ActiveCode, self).run()

        addQuestionToDB(self)

        env = self.state.document.settings.env
        # keep track of how many activecodes we have....
        # could be used to automatically make a unique id for them.
        if not hasattr(env, "activecodecounter"):
            env.activecodecounter = 0
        env.activecodecounter += 1
        self.options["name"] = self.arguments[0].strip()

        explain_text = None
        if self.content:
            if "~~~~" in self.content:
                idx = self.content.index("~~~~")
                explain_text = self.content[:idx]