From fa5f3f8d3c783ee9200f53b19fb0a683071565ae Mon Sep 17 00:00:00 2001 From: flysaiah Date: Thu, 9 Jun 2016 19:20:23 -0500 Subject: [PATCH 1/2] Fixed timed activecode run bug --- runestone/activecode/js/timed_activecode.js | 6 ++++++ runestone/assess/js/timed.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/runestone/activecode/js/timed_activecode.js b/runestone/activecode/js/timed_activecode.js index 08e454095..912ea2c34 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,8 @@ 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)); +}; diff --git a/runestone/assess/js/timed.js b/runestone/assess/js/timed.js index d2cdcb610..143d6cb40 100644 --- a/runestone/assess/js/timed.js +++ b/runestone/assess/js/timed.js @@ -338,6 +338,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(); + } }; From b7b3ab7d1e316142fbb8eab73350db288c39e41a Mon Sep 17 00:00:00 2001 From: flysaiah Date: Thu, 9 Jun 2016 19:29:17 -0500 Subject: [PATCH 2/2] Fixed history button listening --- runestone/activecode/js/timed_activecode.js | 1 + 1 file changed, 1 insertion(+) diff --git a/runestone/activecode/js/timed_activecode.js b/runestone/activecode/js/timed_activecode.js index 912ea2c34..3fa2ae16b 100644 --- a/runestone/activecode/js/timed_activecode.js +++ b/runestone/activecode/js/timed_activecode.js @@ -60,4 +60,5 @@ TimedActiveCode.prototype.processTimedSubmission = function (logFlag) { TimedActiveCode.prototype.reinitializeListeners = function () { // re-attach the run button listener $(this.runButton).click(this.runProg.bind(this)); + $(this.histButton).click(this.addHistoryScrubber.bind(this)); };