diff --git a/runestone/accessibility/css/accessibility.css b/runestone/accessibility/css/accessibility.css index 3e39702c8..a6de32c09 100644 --- a/runestone/accessibility/css/accessibility.css +++ b/runestone/accessibility/css/accessibility.css @@ -152,4 +152,18 @@ button.btn.btn-link:focus { button.btn.btn-link { color:#1a6a83 !important; background-color:#FFFFFF !important; +} + +/*Reset Button*/ +button.btn.btn-reset:active { + color:#d78080!important; + background-color:#FFFFFF !important; +} +button.btn.btn-reset:focus { + color:#d78080 !important; + background-color:#FFFFFF !important; +} +button.btn.btn-reset{ + color:#FFFFFF !important; + background-color:#d78080 !important; } \ No newline at end of file diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index ac06765e0..68541d0f6 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -81,6 +81,7 @@ export class ActiveCode extends RunestoneBase { this.saveButton = null; this.loadButton = null; this.outerDiv = null; + this.resetButt = null; this.partner = ""; this.runCount = 0; this.logResults = true; @@ -308,13 +309,16 @@ export class ActiveCode extends RunestoneBase { if (eBookConfig.isInstructor) { this.enableInstructorSharing(ctrlDiv); } + + this.addReset(ctrlDiv); + if (this.enablePartner) { this.setupPartner(ctrlDiv); } if (this.chatcodes && eBookConfig.enable_chatcodes) { this.enableChatCodes(ctrlDiv); } - + $(this.outerDiv).prepend(ctrlDiv); if (this.question) { if ($(this.question).html().match(/^\s+$/)) { @@ -467,6 +471,26 @@ export class ActiveCode extends RunestoneBase { ); } + addReset(ctrlDiv){ + let butt = document.createElement("button"); + $(butt).text("Reset"); + ctrlDiv.appendChild(butt); + $(butt).addClass("btn btn-reset"); + $(butt).css("margin-right", "10px"); + $(butt).attr("type", "button"); + $(butt).attr("target", "_blank"); + this.resetButt = butt + $(butt).click( + function(){ + this.history = [this.history[0]]; + this.editor.setValue(this.history[0]); + $(this.historyScrubber).slider("value", 0) + $(this.timestampP).text(`${this.timestamps[0]} - 1 of 1`); + $(this.historyScrubber).slider("disable"); + }.bind(this) + ) + } + setupPartner(ctrlDiv) { var checkPartner = document.createElement("input"); checkPartner.type = "checkbox"; @@ -639,7 +663,7 @@ export class ActiveCode extends RunestoneBase { "max-width": "300px", }); var scrubber = document.createElement("div"); - this.timestampP = document.createElement("span"); + this.timestampP = document.createElement("span"); this.slideit = function () { this.editor.setValue(this.history[$(scrubber).slider("value")]); var curVal = this.timestamps[$(scrubber).slider("value")]; @@ -1176,6 +1200,9 @@ Yet another is that there is an internal error. The internal error message is: if (this.historyScrubber === null && !this.autorun) { await this.addHistoryScrubber(); } + if (this.history.length > 0){ + $(this.historyScrubber).slider("enable"); + } if ( this.historyScrubber && this.history[$(this.historyScrubber).slider("value")] !=