diff --git a/.gitignore b/.gitignore
index 460e6c953..4c327e8ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,6 +48,7 @@ build_info
# IDEs
.vscode/
+.vs/
**/sphinx-enki-info.txt
# Mac stuff
.DS_Store
diff --git a/runestone/__init__.py b/runestone/__init__.py
index a145ba1ee..0da19aaec 100644
--- a/runestone/__init__.py
+++ b/runestone/__init__.py
@@ -70,7 +70,11 @@ def runestone_extensions():
if os.path.exists("{}/__init__.py".format(os.path.join(basedir, x)))
]
# Place ``runestone.common`` first, so it can run init code needed by all other modules. This assumes that the first module in the list is run first. An alternative to this to guarantee this ordering is to call ``app.setup_extension('runestone.common')`` in every extension.
- modules.insert(0, modules.pop(modules.index("runestone.common")))
+ modules.insert(0, modules.pop(modules.index('runestone.common')))
+ # ``runestone.updateConfig`` is reserved for testing and will only be included if ``test`` is the second to last element of tha path
+ if 'test' != os.path.split(os.getcwd())[-1]:
+ modules.remove('runestone.updateConfig')
+
return modules
diff --git a/runestone/assess/assess.py b/runestone/assess/assess.py
index de7563cca..634975b6f 100644
--- a/runestone/assess/assess.py
+++ b/runestone/assess/assess.py
@@ -33,7 +33,7 @@ def setup(app):
app.add_directive("timed", TimedDirective)
app.add_config_value("mchoice_div_class", "runestone alert alert-warning", "html")
-
+ app.add_config_value("mchoice_compare_button_show", True, "html")
app.add_autoversioned_javascript("mchoice.js")
app.add_autoversioned_javascript("timedmc.js")
app.add_autoversioned_javascript("timed.js")
diff --git a/runestone/assess/js/mchoice.js b/runestone/assess/js/mchoice.js
index c5516661a..869b17938 100644
--- a/runestone/assess/js/mchoice.js
+++ b/runestone/assess/js/mchoice.js
@@ -35,6 +35,7 @@ MultipleChoice.prototype.init = function (opts) {
this.multipleanswers = false;
this.divid = orig.id;
this.caption = 'Multiple Choice'
+ this.showcomparebutton = $(orig).data('showcomparebutton');
if ($(this.origElem).data("multipleanswers") === true) {
this.multipleanswers = true;
@@ -233,7 +234,7 @@ MultipleChoice.prototype.renderMCFormButtons = function () {
this.optsForm.appendChild(this.submitButton);
// Create compare button
- if (this.useRunestoneServices) {
+ if (this.useRunestoneServices && this.showcomparebutton) {
this.compareButton = document.createElement("button");
$(this.compareButton).attr({
"class": "btn btn-default",
diff --git a/runestone/assess/multiplechoice.py b/runestone/assess/multiplechoice.py
index c243c3908..5601f4fe2 100644
--- a/runestone/assess/multiplechoice.py
+++ b/runestone/assess/multiplechoice.py
@@ -149,6 +149,7 @@ class MChoice(Assessment):
config values (conf.py):
- mchoice_div_class - custom CSS class of the component's outermost div
+ - mchoice_compare_button_show - if False, hide the 'Compare me' button (default True)
"""
required_arguments = 1
@@ -184,10 +185,16 @@ def run(self):
super(MChoice, self).run()
- TEMPLATE_START = """
+ env = self.state.document.settings.env
+ if env.config.mchoice_compare_button_show:
+ self.options['showcomparebutton'] = 'data-showcomparebutton=true'
+ else:
+ self.options['showcomparebutton'] = 'data-showcomparebutton=false'
+
+ TEMPLATE_START = '''
-
- """
+
+ '''
OPTION = """
%(atext)s
%(feedtext)s
diff --git a/runestone/common/project_template/conf.tmpl b/runestone/common/project_template/conf.tmpl
index 1a348d1a7..27b9ae2dc 100644
--- a/runestone/common/project_template/conf.tmpl
+++ b/runestone/common/project_template/conf.tmpl
@@ -297,3 +297,7 @@ htmlhelp_basename = 'PythonCoursewareProjectdoc'
#shortanswer_optional_div_class = 'journal alert alert-success'
#showeval_div_class = 'runestone explainer alert alert-warning'
#tabbed_div_class = 'alert alert-warning'
+#mchoice_compare_button_show - if False, hide the 'Compare me' button (default True)
+#mchoice_compare_button_show = True
+#fitb_compare_button_show - if False, hide the 'Compare me' button (default True)
+#fitb_compare_button_show = True
\ No newline at end of file
diff --git a/runestone/fitb/fitb.py b/runestone/fitb/fitb.py
index 98fc45927..8c146dd66 100644
--- a/runestone/fitb/fitb.py
+++ b/runestone/fitb/fitb.py
@@ -40,6 +40,7 @@ def setup(app):
FITBFeedbackNode, html=(visit_fitb_feedback_node, depart_fitb_feedback_node)
)
app.add_config_value("fitb_div_class", "runestone", "html")
+ app.add_config_value("fitb_compare_button_show", True, "html")
class FITBNode(nodes.General, nodes.Element, RunestoneNode):
@@ -126,6 +127,7 @@ class FillInTheBlank(RunestoneIdDirective):
config values (conf.py):
- fitb_div_class - custom CSS class of the component's outermost div
+ - fitb_compare_button_show - if False, hide the 'Compare me' button (default True)
"""
required_arguments = 1
@@ -150,9 +152,15 @@ def run(self):
super(FillInTheBlank, self).run()
+ env = self.state.document.settings.env
+ if env.config.fitb_compare_button_show:
+ self.options['showcomparebutton'] = 'data-showcomparebutton=true'
+ else:
+ self.options['showcomparebutton'] = 'data-showcomparebutton=false'
+
TEMPLATE_START = """
-
+
"""
TEMPLATE_END = """
diff --git a/runestone/fitb/js/fitb.js b/runestone/fitb/js/fitb.js
index 63205da36..976d39964 100644
--- a/runestone/fitb/js/fitb.js
+++ b/runestone/fitb/js/fitb.js
@@ -34,6 +34,7 @@ FITB.prototype.init = function (opts) {
this.origElem = orig;
this.divid = orig.id;
this.correct = null;
+ this.showcomparebutton = $(orig).data('showcomparebutton');
// See comments in fitb.py for the format of ``feedbackArray`` (which is identical in both files).
//
// Find the script tag containing JSON and parse it. See `SO `_. If this parses to ``false``, then no feedback is available; server-side grading will be performed.
@@ -97,7 +98,7 @@ FITB.prototype.renderFITBButtons = function () {
this.containerDiv.appendChild(document.createElement("br"));
this.containerDiv.appendChild(document.createElement("br"));
this.containerDiv.appendChild(this.submitButton);
- if (this.useRunestoneServices) {
+ if (this.useRunestoneServices && this.showcomparebutton) {
this.compareButton = document.createElement("button");
$(this.compareButton).attr({
"class": "btn btn-default",
diff --git a/runestone/unittest_base.py b/runestone/unittest_base.py
index 90a01538d..157f78ebe 100644
--- a/runestone/unittest_base.py
+++ b/runestone/unittest_base.py
@@ -155,7 +155,7 @@ def setUpModule(self):
options = Options()
options.add_argument("--window-size=1200,800")
options.add_argument("--no-sandbox")
- self.driver = webdriver.Chrome(chrome_options=options) # good for development.
+ self.driver = webdriver.Chrome(options=options) # good for development.
# Make this accessible
global mf
diff --git a/runestone/updateConfig/__init__.py b/runestone/updateConfig/__init__.py
new file mode 100644
index 000000000..5bd4ea95f
--- /dev/null
+++ b/runestone/updateConfig/__init__.py
@@ -0,0 +1,2 @@
+
+from .update import *
diff --git a/runestone/updateConfig/test/_sources/index.rst b/runestone/updateConfig/test/_sources/index.rst
new file mode 100644
index 000000000..ed8f76c9a
--- /dev/null
+++ b/runestone/updateConfig/test/_sources/index.rst
@@ -0,0 +1,119 @@
+==============================
+Testing update-config direcive
+==============================
+
+
+Multiple Choice
+---------------
+
+.. mchoice:: question1
+ :multiple_answers:
+ :correct: a,b,d
+ :answer_a: red
+ :answer_b: yellow
+ :answer_c: black
+ :answer_d: green
+ :feedback_a: Red is a definitely on of the colors.
+ :feedback_b: Yes, yellow is correct.
+ :feedback_c: Remember the acronym...ROY G BIV. B stands for blue.
+ :feedback_d: Yes, green is one of the colors.
+
+ Which colors might be found in a rainbow? (choose all that are correct)
+
+
+
+
+
+Fill in the Blank
+-----------------
+.. fillintheblank:: fill1
+
+ Fill in the blanks to make the following sentence: "The red car drove away."
+
+ The |blank| car drove |blank|.
+
+ - :red: Correct.
+ :x: Incorrect. Try 'red'.
+ - :away: Correct.
+ :x: Incorrect. Try 'away'.
+
+
+
+
+.. update-config::
+ :set_config_option: mchoice_compare_button_show False
+.. update-config::
+ :set_config_option: fitb_compare_button_show False
+
+
+Multiple Choice
+---------------
+
+.. mchoice:: question2
+ :multiple_answers:
+ :correct: a,b,d
+ :answer_a: red
+ :answer_b: yellow
+ :answer_c: black
+ :answer_d: green
+ :feedback_a: Red is a definitely on of the colors.
+ :feedback_b: Yes, yellow is correct.
+ :feedback_c: Remember the acronym...ROY G BIV. B stands for blue.
+ :feedback_d: Yes, green is one of the colors.
+
+ Which colors might be found in a rainbow? (choose all that are correct)
+
+
+
+Fill in the Blank
+-----------------
+.. fillintheblank:: fill2
+
+ Fill in the blanks to make the following sentence: "The red car drove away."
+
+ The |blank| car drove |blank|.
+
+ - :red: Correct.
+ :x: Incorrect. Try 'red'.
+ - :away: Correct.
+ :x: Incorrect. Try 'away'.
+
+
+.. update-config::
+ :set_config_option: mchoice_compare_button_show True
+
+
+Multiple Choice
+---------------
+
+.. mchoice:: question3
+ :multiple_answers:
+ :correct: a,b,d
+ :answer_a: red
+ :answer_b: yellow
+ :answer_c: black
+ :answer_d: green
+ :feedback_a: Red is a definitely on of the colors.
+ :feedback_b: Yes, yellow is correct.
+ :feedback_c: Remember the acronym...ROY G BIV. B stands for blue.
+ :feedback_d: Yes, green is one of the colors.
+
+
+.. update-config::
+ :set_config_option: fitb_compare_button_show True
+
+Fill in the Blank
+-----------------
+.. fillintheblank:: fill3
+
+ Fill in the blanks to make the following sentence: "The red car drove away."
+
+ The |blank| car drove |blank|.
+
+ - :red: Correct.
+ :x: Incorrect. Try 'red'.
+ - :away: Correct.
+ :x: Incorrect. Try 'away'.
+
+
+
diff --git a/runestone/updateConfig/test/conf.py b/runestone/updateConfig/test/conf.py
new file mode 100644
index 000000000..824e41fa7
--- /dev/null
+++ b/runestone/updateConfig/test/conf.py
@@ -0,0 +1,301 @@
+# -*- coding: utf-8 -*-
+#
+# Problem Solving with Algorithms and Data Structures documentation build configuration file, created by
+# sphinx-quickstart on Thu Oct 27 08:17:45 2011.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('../modules'))
+
+from runestone import runestone_static_dirs, runestone_extensions
+import pkg_resources
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.mathjax'] + runestone_extensions()
+
+#,'runestone.video','runestone.reveal','runestone.poll','runestone.tabbedStuff','runestone.disqus','runestone.codelens','runestone.activecode', 'runestone.assess', 'runestone.animation','runestone.meta', 'runestone.parsons', 'runestone.blockly', 'runestone.livecode','runestone.accessibility']
+
+# This sets up your project to use the defaults. If you want to create a custom set of templates
+# for your own project you can over ride them by creating your own _templates folder
+templates_path = [pkg_resources.resource_filename('runestone', 'common/project_template/_templates')]
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = 'Runestone Interactive Overview'
+copyright = '2017 Petlja'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.0.1'
+# The full version, including alpha/beta/rc tags.
+release = '0.0'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = []
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# `keep_warnings `_:
+# If true, keep warnings as “system message” paragraphs in the built documents.
+# Regardless of this setting, warnings are always written to the standard error
+# stream when sphinx-build is run.
+keep_warnings = True
+
+# `rst_prolog `_:
+# A string of reStructuredText that will be included at the beginning of every
+# source file that is read.
+rst_prolog = (
+# For fill-in-the-blank questions, provide a convenient means to indicate a blank.
+"""
+
+.. |blank| replace:: :blank:`x`
+"""
+
+# For literate programming files, provide a convenient way to refer to a source file's name. See `runestone.lp.lp._docname_role`.
+""".. |docname| replace:: :docname:`name`
+"""
+)
+
+# Select whether to use server-side grading where possible. Server-side grading
+# requires **all** the following:
+#
+# - The use of Runestone services (``eBookConfig.useRunestoneServices === true``)
+# - Logging enabled (``eBookConfig.logLevel > 0``)
+#
+# The first two conditions cause the ``RunestoneBase.logBookEvent`` in ``runestonebase.js`` to post a student response to the server. The last conditions ensures that ``hsblog`` in ``ajax.py`` on the server will return a response containing grading information.
+runestone_server_side_grading = False
+
+# Extensions
+# ==========
+# CodeChat
+# --------
+# **CodeChat note:** A dict of {glob_, lexer_alias}, which uses lexer_alias
+# (e.g. a lexer's `short name `_) to analyze
+# any file wihch matches the given `glob
+# `_.
+CodeChat_lexer_for_glob = {
+ # Otherwise, Pygments picks the wrong lexer for CSS...
+ '*.css': 'CSS',
+ # ... and for JavaScript.
+ '*.js': 'JavaScript',
+}
+#
+# **CodeChat note::** This is a list of exclude_patterns_ which applies only to
+# source documents; exclude_patterns_ will exclude the given files from all of
+# Sphinx (for example, files here won't be included even if they're mentioned in
+# html_static_path_.
+CodeChat_excludes = []
+#
+# Inline syntax highlight
+# -----------------------
+# `inline_highlight_respect_highlight `_:
+# Use the language specified by the ``highlight`` directive to syntax highlight ``code`` role contents.
+inline_highlight_respect_highlight = True
+inline_highlight_literals = False
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'sphinx_bootstrap'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {'nosidebar': 'true'}
+html_theme_options = {
+ # Navigation bar title. (Default: ``project`` value)
+ 'navbar_title': "Runestone Default",
+
+ # Tab name for entire site. (Default: "Site")
+ 'navbar_site_name': "Chapters",
+
+ # Global TOC depth for "site" navbar tab. (Default: 1)
+ # Switching to -1 shows all levels.
+ 'globaltoc_depth': 1,
+
+ # Include hidden TOCs in Site navbar?
+ #
+ # Note: If this is "false", you cannot have mixed ``:hidden:`` and
+ # non-hidden ``toctree`` directives in the same page, or else the build
+ # will break.
+ #
+ # Values: "true" (default) or "false"
+ 'globaltoc_includehidden': "true",
+
+ # HTML navbar class (Default: "navbar") to attach to
element.
+ # For black navbar, do "navbar navbar-inverse"
+ 'navbar_class': "navbar",
+
+ # Fix navigation bar to top of page?
+ # Values: "true" (default) or "false"
+ 'navbar_fixed_top': "true",
+
+ # Location of link to source.
+ # Options are "nav" (default), "footer" or anything else to exclude.
+ 'source_link_position': "nav",
+
+ # Bootswatch (http://bootswatch.com/) theme.
+ #
+ # Options are nothing with "" (default) or the name of a valid theme
+ # such as "amelia" or "cosmo".
+ #
+ # Note that this is served off CDN, so won't be available offline.
+ #'bootswatch_theme': "slate",
+}
+
+#html_style = "style.css"
+
+# This is set up to use the default runestone themes, you can override them by
+# creating your own folder and modifying this path.
+# Add any paths that contain custom themes here, relative to this directory.
+html_theme_path = [pkg_resources.resource_filename('runestone', 'common/project_template/_templates/plugin_layouts')]
+
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# " v documentation".
+html_title = 'Runestone Interactive Overview'
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+html_short_title ='Runestone Interactive Overview'
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+
+# logo is included in layout file
+#html_logo = "../source/_static/logo_small.png"
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+
+html_static_path = runestone_static_dirs()
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+html_show_sourcelink = False
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'PythonCoursewareProjectdoc'
+
+# 'accessibility_style' config value is defined in the 'accessibility' extension.
+# By this config value you can select what accessibility stylesheet
+# you want to add ('normal', 'light', 'darkest' or 'none')
+#accessibility_style = 'normal'
+
+# Config values for specific Runestone components
+#
+#activecode_div_class = 'runestone explainer ac_section alert alert-warning'
+#activecode_hide_load_history = False
+#mchoice_div_class = 'runestone alert alert-warning'
+#clickable_div_class = 'runestone alert alert-warning'
+#codelens_div_class = 'alert alert-warning cd_section'
+#dragndrop_div_class = 'runestone'
+#fitb_div_class = 'runestone'
+#parsons_div_class = 'runestone'
+#poll_div_class = 'alert alert-warning'
+#shortanswer_div_class = 'journal alert alert-warning'
+#shortanswer_optional_div_class = 'journal alert alert-success'
+#showeval_div_class = 'runestone explainer alert alert-warning'
+#tabbed_div_class = 'alert alert-warning'
+#mchoice_compare_button_show = True
+#fitb_compare_button_show = True
\ No newline at end of file
diff --git a/runestone/updateConfig/test/pavement.py b/runestone/updateConfig/test/pavement.py
new file mode 100644
index 000000000..edb8e3cb3
--- /dev/null
+++ b/runestone/updateConfig/test/pavement.py
@@ -0,0 +1,70 @@
+import os
+import sys
+import pkg_resources
+from socket import gethostname
+
+from paver.easy import options, Bunch
+import paver.setuputils
+
+from runestone import get_master_url
+from runestone import build # NOQA: F401 -- build is called implicitly by the paver driver.
+from runestone.server import get_dburl
+
+paver.setuputils.install_distutils_tasks()
+sys.path.append(os.getcwd())
+
+# The project name, for use below.
+project_name = 'updateTest'
+
+master_url = 'http://127.0.0.1:8000'
+if not master_url:
+ master_url = get_master_url()
+
+# The root directory for ``runestone serve``.
+serving_dir = "./build/" + project_name
+# The destination directory for ``runestone deploy``.
+dest = "../../static"
+
+options(
+ sphinx=Bunch(docroot=".",),
+
+ build=Bunch(
+ builddir=serving_dir,
+ sourcedir="_sources",
+ outdir=serving_dir,
+ confdir=".",
+ template_args={
+ 'login_required': 'false',
+ 'loglevel': 0,
+ 'course_title': project_name,
+ 'python3': 'false',
+ 'dburl': '',
+ 'default_ac_lang': 'python',
+ 'jobe_server': 'http://jobe2.cosc.canterbury.ac.nz',
+ 'proxy_uri_runs': '/jobe/index.php/restapi/runs/',
+ 'proxy_uri_files': '/jobe/index.php/restapi/files/',
+ 'downloads_enabled': 'false',
+ 'enable_chatcodes': 'false',
+ 'allow_pairs': 'false',
+ 'dynamic_pages': False,
+ 'use_services': 'true',
+ 'basecourse': project_name,
+ 'course_id': project_name,
+ # These are used for non-dynamic books.
+ 'appname': 'runestone',
+ 'course_url': master_url,
+ }
+ )
+)
+
+# if we are on runestone-deploy then use the proxy server not canterbury
+if gethostname() == 'runestone-deploy':
+ del options.build.template_args['jobe_server']
+ del options.build.template_args['proxy_uri_runs']
+ del options.build.template_args['proxy_uri_files']
+
+version = pkg_resources.require("runestone")[0].version
+options.build.template_args['runestone_version'] = version
+
+# If DBURL is in the environment override dburl
+options.build.template_args['dburl'] = get_dburl(outer=locals())
diff --git a/runestone/updateConfig/test/test_update.py b/runestone/updateConfig/test/test_update.py
new file mode 100644
index 000000000..f52a7b2d3
--- /dev/null
+++ b/runestone/updateConfig/test/test_update.py
@@ -0,0 +1,65 @@
+from selenium.webdriver import ActionChains
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.support.ui import WebDriverWait
+from selenium.common.exceptions import NoSuchElementException
+from selenium.webdriver.common.by import By
+import time
+from runestone.unittest_base import module_fixture_maker, RunestoneTestCase
+
+setUpModule, tearDownModule = module_fixture_maker(__file__)
+class UpdateConfigTests(RunestoneTestCase):
+ def find_fitb(self, elem_id):
+ self.driver.get(self.host + "/index.html")
+ wait = WebDriverWait(self.driver, 10)
+ try:
+ wait.until(
+ EC.presence_of_element_located((By.ID, elem_id))
+ )
+ except:
+ text = self.driver.page_source
+ print(text[:300])
+
+ self.fitb = self.driver.find_element_by_id(elem_id)
+ return self.fitb
+
+ def test_updateconfig_fitb(self):
+ self.driver.get(self.host + "/index.html")
+
+ self.find_fitb("fill1")
+ button_before_config_update = self.driver.find_element_by_id("question1_bcomp")
+
+ self.find_fitb("fill2")
+ assert not is_element_present_by_id(self,"question2_bcomp")
+
+
+ self.find_fitb("fill3")
+ button_after_second_config_update = self.driver.find_element_by_id("question3_bcomp")
+
+
+ self.assertIsNotNone(button_before_config_update)
+ self.assertIsNotNone(button_after_second_config_update)
+
+ def test_updateconfig_multiplechoice(self):
+ self.driver.get(self.host + "/index.html")
+
+ self.find_fitb("question1")
+ button_before_config_update = self.driver.find_element_by_id("fill1_bcomp")
+
+ self.find_fitb("question2")
+ assert not is_element_present_by_id(self,"fill2_bcomp")
+
+ self.find_fitb("question3")
+ button_after_second_config_update = self.driver.find_element_by_id("fill3_bcomp")
+
+
+ self.assertIsNotNone(button_before_config_update)
+ self.assertIsNotNone(button_after_second_config_update)
+
+def is_element_present_by_id(self, id):
+ try:
+ self.driver.find_element_by_id(id)
+ return True
+ except NoSuchElementException:
+ return False
+
+
\ No newline at end of file
diff --git a/runestone/updateConfig/update.py b/runestone/updateConfig/update.py
new file mode 100644
index 000000000..d90a9f0df
--- /dev/null
+++ b/runestone/updateConfig/update.py
@@ -0,0 +1,41 @@
+__author__ = 'petlja'
+from ast import literal_eval
+from docutils import nodes
+from docutils.parsers.rst import Directive
+from docutils.parsers.rst import directives
+from runestone.common.runestonedirective import RunestoneNode
+
+
+def setup(app):
+ app.add_directive('update-config', UpdateConfig)
+
+class UpdateConfig(Directive):
+ """
+ The syntax for a update config is:
+ .. update-config::
+ :set_config_option: configuration new_value
+
+ .. update-config::
+ :set_config_option: mchoice_compare_button_show False
+ """
+ required_arguments = 0
+ optional_arguments = 0
+ has_content = False
+ option_spec ={
+ 'set_config_option': directives.unchanged,
+ }
+
+
+ def run(self):
+ env = self.state.document.settings.env
+
+ if 'set_config_option' in self.options:
+ config_opt , value = self.options['set_config_option'].split(" ", 1)
+ #It is possible to crash the Python interpreter with a sufficiently large/complex string due to stack depth limitations in Python’s AST compiler.
+ if len(value)>1000:
+ self.error("Length of configuration option value exceeded")
+
+ env.config[config_opt]= literal_eval(value)
+
+
+ return []