From 0b1a55accce1943aaeda38201fcaf4067c58dc87 Mon Sep 17 00:00:00 2001 From: nenadmilutinovic <44362916+nenadmilutinovic@users.noreply.github.com> Date: Fri, 2 Aug 2019 10:02:57 +0200 Subject: [PATCH 01/10] added config for compare button --- runestone/assess/assess.py | 2 +- runestone/assess/js/mchoice.js | 3 ++- runestone/assess/multiplechoice.py | 10 ++++++++-- runestone/common/project_template/conf.tmpl | 2 ++ runestone/fitb/fitb.py | 13 ++++++++++--- runestone/fitb/js/fitb.js | 3 ++- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/runestone/assess/assess.py b/runestone/assess/assess.py index 22d163bc9..1b950e43c 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 fd9407e39..0b867a36d 100644 --- a/runestone/assess/multiplechoice.py +++ b/runestone/assess/multiplechoice.py @@ -179,10 +179,16 @@ def run(self): super(MChoice, self).run() + env = self.state.document.settings.env + if env.config.mchoice_compare_button_show: + self.options['showcomparebutton'] = 'data-showcomparebutton=true' + else: + self.options['showcomparebutton'] = '' + TEMPLATE_START = '''
-