diff --git a/runestone/activecode/activecode.py b/runestone/activecode/activecode.py index 99f4fb8a5..03c1b3799 100644 --- a/runestone/activecode/activecode.py +++ b/runestone/activecode/activecode.py @@ -19,12 +19,10 @@ from docutils import nodes from docutils.parsers.rst import directives -from docutils.parsers.rst import Directive from .textfield import * -from sqlalchemy import create_engine, Table, MetaData, select, delete -from runestone.server import get_dburl +from sqlalchemy import Table from runestone.server.componentdb import addQuestionToDB, addHTMLToDB, engine, meta -from runestone.common.runestonedirective import RunestoneDirective +from runestone.common.runestonedirective import RunestoneDirective, RunestoneNode try: from html import escape # py3 @@ -69,15 +67,15 @@ def setup(app): """ -class ActivcodeNode(nodes.General, nodes.Element): - def __init__(self, content): +class ActivcodeNode(nodes.General, nodes.Element, RunestoneNode): + def __init__(self, content, **kwargs): """ Arguments: - `self`: - `content`: """ - super(ActivcodeNode, self).__init__(name=content['name']) + super(ActivcodeNode, self).__init__(name=content['name'], **kwargs) self.ac_components = content @@ -352,7 +350,8 @@ def run(self): print("This should only affect the grading interface. Everything else should be fine.") - acnode = ActivcodeNode(self.options) + 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: diff --git a/runestone/activecode/test/test_activecode.py b/runestone/activecode/test/test_activecode.py index 9efa88707..da08a2317 100644 --- a/runestone/activecode/test/test_activecode.py +++ b/runestone/activecode/test/test_activecode.py @@ -1,5 +1,8 @@ -from runestone.unittest_base import module_fixture_maker, RunestoneTestCase from selenium.webdriver import ActionChains +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.common.by import By +from runestone.unittest_base import module_fixture_maker, RunestoneTestCase setUpModule, tearDownModule = module_fixture_maker(__file__) @@ -39,6 +42,7 @@ def test_history(self): ta = t1.find_element_by_class_name("cm-s-default") self.assertIsNotNone(ta) self.driver.execute_script("""edList['test1'].editor.setValue("print('GoodBye')")""") + WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "run-button"))) rb.click() output = t1.find_element_by_class_name("ac_output") self.assertEqual(output.text.strip(),"GoodBye") diff --git a/runestone/animation/animation.py b/runestone/animation/animation.py index 07cdbfbcb..13b1b3fcd 100644 --- a/runestone/animation/animation.py +++ b/runestone/animation/animation.py @@ -17,7 +17,7 @@ from docutils import nodes from docutils.parsers.rst import directives -from docutils.parsers.rst import Directive +from runestone.common.runestonedirective import RunestoneDirective def setup(app): @@ -52,7 +52,7 @@ def setup(app): SCRIPTTAG = '''\n''' -class Animation(Directive): +class Animation(RunestoneDirective): required_arguments = 1 optional_arguments = 1 final_argument_whitespace = True @@ -80,7 +80,9 @@ def run(self): res = res + SRC % self.options - return [nodes.raw('',res , format='html')] + rawnode = nodes.raw(self.block_text, res, format='html') + rawnode.source, rawnode.line = self.state_machine.get_source_and_line(self.lineno) + return [rawnode] source = ''' diff --git a/runestone/assess/assess.py b/runestone/assess/assess.py index 9418940c6..ed7b2fb5a 100644 --- a/runestone/assess/assess.py +++ b/runestone/assess/assess.py @@ -17,7 +17,7 @@ from docutils import nodes from docutils.parsers.rst import directives -from docutils.parsers.rst import Directive +from runestone.common.runestonedirective import RunestoneDirective from .assessbase import Assessment from .multiplechoice import * from .timedassessment import * @@ -47,7 +47,7 @@ def setup(app): -class AddButton(Directive): +class AddButton(RunestoneDirective): required_arguments = 1 optional_arguments = 1 final_argument_whitespace = True @@ -79,10 +79,12 @@ def run(self): res = TEMPLATE_START % self.options res += TEMPLATE_END % self.options - return [nodes.raw('', res, format='html')] + rawnode = nodes.raw(self.block_text, res, format='html') + rawnode.source, rawnode.line = self.state_machine.get_source_and_line(self.lineno) + return [rawnode] -class QuestionNumber(Directive): +class QuestionNumber(RunestoneDirective): """Set Parameters for Question Numbering .. qnum:: 'prefix': character prefix before the number diff --git a/runestone/assess/assessbase.py b/runestone/assess/assessbase.py index 662465c20..42d30496b 100644 --- a/runestone/assess/assessbase.py +++ b/runestone/assess/assessbase.py @@ -15,10 +15,7 @@ # __author__ = 'bmiller' -from docutils import nodes -from docutils.parsers.rst import directives -from docutils.parsers.rst import Directive -from runestone.common.runestonedirective import RunestoneDirective +from runestone.common.runestonedirective import RunestoneDirective, RunestoneNode _base_js_escapes = ( ('\\', r'\u005C'), @@ -76,7 +73,7 @@ def getNumber(self): def run(self): self.options['qnumber'] = self.getNumber() - + self.options['divid'] = self.arguments[0] if self.content[0][:2] == '..': # first line is a directive diff --git a/runestone/assess/multiplechoice.py b/runestone/assess/multiplechoice.py index 8c5ddfb19..0aaaefad7 100644 --- a/runestone/assess/multiplechoice.py +++ b/runestone/assess/multiplechoice.py @@ -21,15 +21,15 @@ from runestone.server.componentdb import addQuestionToDB, addHTMLToDB -class MChoiceNode(nodes.General, nodes.Element): - def __init__(self,content): +class MChoiceNode(nodes.General, nodes.Element, RunestoneNode): + def __init__(self, content, **kwargs): """ Arguments: - `self`: - `content`: """ - super(MChoiceNode,self).__init__() + super(MChoiceNode, self).__init__(**kwargs) self.mc_options = content def visit_mc_node(self,node): @@ -194,7 +194,8 @@ def run(self): - mcNode = MChoiceNode(self.options) + mcNode = MChoiceNode(self.options, rawsource=self.block_text) + mcNode.source, mcNode.line = self.state_machine.get_source_and_line(self.lineno) mcNode.template_start = TEMPLATE_START mcNode.template_option = OPTION mcNode.template_end = TEMPLATE_END @@ -277,19 +278,19 @@ def run(self): # Define a bullet_list which contains answers (see the structure_). -class AnswersBulletList(nodes.bullet_list): +class AnswersBulletList(nodes.bullet_list, RunestoneNode): pass # Define a list_item which contains answers (see the structure_). -class AnswerListItem(nodes.list_item): +class AnswerListItem(nodes.list_item, RunestoneNode): pass # Define a bullet_list which contains feedback (see the structure_). -class FeedbackBulletList(nodes.bullet_list): +class FeedbackBulletList(nodes.bullet_list, RunestoneNode): pass # Define a list_item which contains answers (see the structure_). -class FeedbackListItem(nodes.list_item): +class FeedbackListItem(nodes.list_item, RunestoneNode): pass # The ``