diff --git a/runestone/activecode/js/timed_activecode.js b/runestone/activecode/js/timed_activecode.js index 08e454095..3fa2ae16b 100644 --- a/runestone/activecode/js/timed_activecode.js +++ b/runestone/activecode/js/timed_activecode.js @@ -9,6 +9,7 @@ TimedActiveCode.prototype.timedInit = function (opts) { this.init(opts); this.renderTimedIcon(this.containerDiv); this.hideButtons(); + this.needsReinitialization = true; // the run button click listener needs to be reinitialized }; @@ -55,3 +56,9 @@ TimedActiveCode.prototype.processTimedSubmission = function (logFlag) { this.runButton.disabled = true; $(this.codeDiv).addClass("ac-disabled"); }; + +TimedActiveCode.prototype.reinitializeListeners = function () { + // re-attach the run button listener + $(this.runButton).click(this.runProg.bind(this)); + $(this.histButton).click(this.addHistoryScrubber.bind(this)); +}; diff --git a/runestone/assess/js/timed.js b/runestone/assess/js/timed.js index a8855e3ee..41b576ce8 100644 --- a/runestone/assess/js/timed.js +++ b/runestone/assess/js/timed.js @@ -340,6 +340,11 @@ Timed.prototype.randomizeRQA = function () { Timed.prototype.renderTimedQuestion = function () { $(this.switchDiv).replaceWith(this.renderedQuestionArray[this.currentQuestionIndex].containerDiv); this.switchDiv = this.renderedQuestionArray[this.currentQuestionIndex].containerDiv; + // If the timed component has listeners, those need to be reinitialized + // This flag will only be set in the elements that need it--it will be undefined in the others and thus evaluate to false + if (this.renderedQuestionArray[this.currentQuestionIndex].needsReinitialization) { + this.renderedQuestionArray[this.currentQuestionIndex].reinitializeListeners(); + } };