This repository was archived by the owner on Jun 7, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +25
-8
lines changed
Expand file tree Collapse file tree 6 files changed +25
-8
lines changed Original file line number Diff line number Diff 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' )
Original file line number Diff line number Diff 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" ,
Original file line number Diff line number Diff 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>
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
4343class 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">
Original file line number Diff line number Diff 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" ,
You can’t perform that action at this time.
0 commit comments