Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 0b1a55a

Browse files
nenadmilutinovicmaric993
authored andcommitted
added config for compare button
1 parent 152cf8a commit 0b1a55a

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

runestone/assess/assess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def setup(app):
3333
app.add_directive('timed', TimedDirective)
3434

3535
app.add_config_value('mchoice_div_class', 'runestone alert alert-warning', 'html')
36-
36+
app.add_config_value('mchoice_compare_button_show', True, 'html');
3737
app.add_autoversioned_javascript('mchoice.js')
3838
app.add_autoversioned_javascript('timedmc.js')
3939
app.add_autoversioned_javascript('timed.js')

runestone/assess/js/mchoice.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ MultipleChoice.prototype.init = function (opts) {
3535
this.multipleanswers = false;
3636
this.divid = orig.id;
3737
this.caption = 'Multiple Choice'
38+
this.showcomparebutton = $(orig).data('showcomparebutton');
3839

3940
if ($(this.origElem).data("multipleanswers") === true) {
4041
this.multipleanswers = true;
@@ -233,7 +234,7 @@ MultipleChoice.prototype.renderMCFormButtons = function () {
233234
this.optsForm.appendChild(this.submitButton);
234235

235236
// Create compare button
236-
if (this.useRunestoneServices) {
237+
if (this.useRunestoneServices && this.showcomparebutton) {
237238
this.compareButton = document.createElement("button");
238239
$(this.compareButton).attr({
239240
"class": "btn btn-default",

runestone/assess/multiplechoice.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,16 @@ def run(self):
179179

180180
super(MChoice, self).run()
181181

182+
env = self.state.document.settings.env
183+
if env.config.mchoice_compare_button_show:
184+
self.options['showcomparebutton'] = 'data-showcomparebutton=true'
185+
else:
186+
self.options['showcomparebutton'] = ''
187+
182188
TEMPLATE_START = '''
183189
<div class="%(divclass)s">
184-
<ul data-component="multiplechoice" data-multipleanswers="%(multipleAnswers)s" %(random)s id="%(divid)s">
185-
'''
190+
<ul data-component="multiplechoice" data-multipleanswers="%(multipleAnswers)s" %(random)s %(showcomparebutton)s id="%(divid)s">
191+
'''
186192

187193
OPTION = '''
188194
<li data-component="answer" %(is_correct)s id="%(divid)s_opt_%(alabel)s">%(atext)s</li><li data-component="feedback">%(feedtext)s</li>

runestone/common/project_template/conf.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,5 @@ htmlhelp_basename = 'PythonCoursewareProjectdoc'
297297
#shortanswer_optional_div_class = 'journal alert alert-success'
298298
#showeval_div_class = 'runestone explainer alert alert-warning'
299299
#tabbed_div_class = 'alert alert-warning'
300+
#mchoice_compare_button_show = True
301+
#fitb_compare_button_show = True

runestone/fitb/fitb.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def setup(app):
3838
app.add_node(BlankNode, html=(visit_blank_node, depart_blank_node))
3939
app.add_node(FITBFeedbackNode, html=(visit_fitb_feedback_node, depart_fitb_feedback_node))
4040
app.add_config_value('fitb_div_class', 'runestone', 'html')
41-
41+
app.add_config_value('fitb_compare_button_show', True, 'html');
4242

4343
class FITBNode(nodes.General, nodes.Element, RunestoneNode):
4444
def __init__(self, content, **kwargs):
@@ -136,10 +136,17 @@ def run(self):
136136

137137
super(FillInTheBlank, self).run()
138138

139+
env = self.state.document.settings.env
140+
if env.config.fitb_compare_button_show:
141+
self.options['showcomparebutton'] = 'data-showcomparebutton=true'
142+
else:
143+
self.options['showcomparebutton'] = ''
144+
139145
TEMPLATE_START = '''
140146
<div class="%(divclass)s">
141-
<div data-component="fillintheblank" id="%(divid)s">
142-
'''
147+
148+
<div data-component="fillintheblank" id="%(divid)s" %(showcomparebutton)s>
149+
'''
143150

144151
TEMPLATE_END = '''
145152
<script type="application/json">

runestone/fitb/js/fitb.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ FITB.prototype.init = function (opts) {
3434
this.origElem = orig;
3535
this.divid = orig.id;
3636
this.correct = null;
37+
this.showcomparebutton = $(orig).data('showcomparebutton');
3738
// See comments in fitb.py for the format of ``feedbackArray`` (which is identical in both files).
3839
//
3940
// Find the script tag containing JSON and parse it. See `SO <https://stackoverflow.com/questions/9320427/best-practice-for-embedding-arbitrary-json-in-the-dom>`_. If this parses to ``false``, then no feedback is available; server-side grading will be performed.
@@ -97,7 +98,7 @@ FITB.prototype.renderFITBButtons = function () {
9798
this.containerDiv.appendChild(document.createElement("br"));
9899
this.containerDiv.appendChild(document.createElement("br"));
99100
this.containerDiv.appendChild(this.submitButton);
100-
if (this.useRunestoneServices) {
101+
if (this.useRunestoneServices && this.showcomparebutton) {
101102
this.compareButton = document.createElement("button");
102103
$(this.compareButton).attr({
103104
"class": "btn btn-default",

0 commit comments

Comments
 (0)