Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions runestone/activecode/activecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,15 +67,15 @@ def setup(app):
</div>
"""

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


Expand Down Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion runestone/activecode/test/test_activecode.py
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the problem here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some animation that takes places after manually clicking the "Run" button. Perhaps this needs to finish before the Run button is clickable again? Adding the wait makes this pass on Windows.

======================================================================
ERROR: test_history (runestone.activecode.test.test_activecode.ActiveCodeTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "E:\Runestone\RunestoneComponents\runestone\activecode\test\test_activecode.py", line 42, in test_history
    rb.click()
  File "E:\Downloads\Python36-64\lib\site-packages\selenium\webdriver\remote\webelement.py", line 77, in click
    self._execute(Command.CLICK_ELEMENT)
  File "E:\Downloads\Python36-64\lib\site-packages\selenium\webdriver\remote\webelement.py", line 493, in _execute
    return self._parent.execute(command, params)
  File "E:\Downloads\Python36-64\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 256, in execute
    self.error_handler.check_response(response)
  File "E:\Downloads\Python36-64\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <button class="btn btn-success run-button" disabled="disabled">...</button> is not clickable at point (331, 173). Other element would receive the click: <div class="ac_actions col-md-12">...</div>
  (Session info: chrome=59.0.3071.115)
  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 10.0.15063 x86_64)


----------------------------------------------------------------------
Ran 43 tests in 394.236s

FAILED (errors=1)


setUpModule, tearDownModule = module_fixture_maker(__file__)

Expand Down Expand Up @@ -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")
Expand Down
8 changes: 5 additions & 3 deletions runestone/animation/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -52,7 +52,7 @@ def setup(app):

SCRIPTTAG = '''<script type="text/javascript" src="../_static/%s"></script>\n'''

class Animation(Directive):
class Animation(RunestoneDirective):
required_arguments = 1
optional_arguments = 1
final_argument_whitespace = True
Expand Down Expand Up @@ -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 = '''
Expand Down
10 changes: 6 additions & 4 deletions runestone/assess/assess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -47,7 +47,7 @@ def setup(app):



class AddButton(Directive):
class AddButton(RunestoneDirective):
required_arguments = 1
optional_arguments = 1
final_argument_whitespace = True
Expand Down Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions runestone/assess/assessbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions runestone/assess/multiplechoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ``<ul>`` tag will be generated already -- don't output it.
Expand Down
13 changes: 7 additions & 6 deletions runestone/assess/timedassessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

from docutils import nodes
from docutils.parsers.rst import directives
from docutils.parsers.rst import Directive
from runestone.common.runestonedirective import RunestoneDirective, RunestoneNode

#add directives/javascript/css


class TimedNode(nodes.General, nodes.Element):
class TimedNode(nodes.General, nodes.Element, RunestoneNode):
def __init__(self,content):
super(TimedNode,self).__init__()
self.timed_options = content
Expand All @@ -42,12 +42,12 @@ def visit_timed_node(self, node):
node.timed_options['nofeedback'] = 'data-no-feedback'
else:
node.timed_options['nofeedback'] = ''

if 'notimer' in node.timed_options:
node.timed_options['notimer'] = 'data-no-timer'
else:
node.timed_options['notimer'] = ''

if 'fullwidth' in node.timed_options:
node.timed_options['fullwidth'] = 'data-fullwidth'
else:
Expand All @@ -69,7 +69,7 @@ def depart_timed_node(self,node):

TEMPLATE_END = '''</ul>
'''
class TimedDirective(Directive):
class TimedDirective(RunestoneDirective):
"""
.. timed:: identifier
:timelimit: Number of minutes student has to take the timed assessment--if not provided, no time limit
Expand Down Expand Up @@ -106,7 +106,8 @@ def run(self):

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

timed_node = TimedNode(self.options)
timed_node = TimedNode(self.options, rawsource=self.block_text)
timed_node.source, timed_node.line = self.state_machine.get_source_and_line(self.lineno)

self.state.nested_parse(self.content, self.content_offset, timed_node)

Expand Down
13 changes: 7 additions & 6 deletions runestone/assignment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@

from docutils import nodes
from docutils.parsers.rst import directives
from docutils.parsers.rst import Directive
from runestone.server.componentdb import addAssignmentToDB, addAssignmentQuestionToDB, getCourseID, getOrCreateAssignmentType, getQuestionID, get_HTML_from_DB
from runestone.common.runestonedirective import RunestoneDirective
from runestone.common.runestonedirective import RunestoneDirective, RunestoneNode
from datetime import datetime

def setup(app):
Expand All @@ -31,15 +30,15 @@ def setup(app):
app.connect('doctree-resolved',process_nodes)
app.connect('env-purge-doc', purge)

class AssignmentNode(nodes.General, nodes.Element):
def __init__(self, content):
class AssignmentNode(nodes.General, nodes.Element, RunestoneNode):
def __init__(self, content, **kwargs):
"""

Arguments:
- `self`:
- `content`:
"""
super(AssignmentNode, self).__init__(name=content['name'])
super(AssignmentNode, self).__init__(name=content['name'], **kwargs)
self.a_components = content


Expand Down Expand Up @@ -157,6 +156,8 @@ def run(self):
self.options['question_ids'] = question_names

if 'generate_html' in self.options:
return [AssignmentNode(self.options)]
assignment_node = AssignmentNode(self.options, rawsource=self.block_text)
assignment_node.source, assignment_node.line = self.state_machine.get_source_and_line(self.lineno)
return [assignment_node]
else:
return []
Loading