Skip to content

Commit c698fa0

Browse files
authored
Merge pull request #4 from sujith-rek/localstorage
reset button for ac
2 parents 4fe19f7 + b90d351 commit c698fa0

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

runestone/activecode/js/activecode.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class ActiveCode extends RunestoneBase {
7070
this.runButton = null;
7171
this.enabledownload = $(orig).data("enabledownload");
7272
this.downloadButton = null;
73+
this.resetButton = null;
7374
this.saveButton = null;
7475
this.loadButton = null;
7576
this.outerDiv = null;
@@ -278,6 +279,8 @@ export class ActiveCode extends RunestoneBase {
278279
this.runButton.onclick = this.runButtonHandler.bind(this);
279280
$(butt).attr("type", "button");
280281

282+
this.addResetButton(ctrlDiv);
283+
281284
if (this.enabledownload || eBookConfig.downloadsEnabled) {
282285
this.addDownloadButton(ctrlDiv);
283286
}
@@ -354,6 +357,16 @@ export class ActiveCode extends RunestoneBase {
354357
$(butt).attr("type", "button");
355358
}
356359

360+
addResetButton(ctrlDiv) {
361+
let butt = document.createElement("button");
362+
$(butt).text("Reset");
363+
$(butt).addClass("btn btn-default");
364+
$(butt).attr("type", "button");
365+
ctrlDiv.appendChild(butt);
366+
this.resetButton = butt;
367+
$(butt).click(this.resetCode.bind(this));
368+
}
369+
357370
enableHideShow(ctrlDiv) {
358371
$(this.runButton).attr("disabled", "disabled");
359372
let butt = document.createElement("button");
@@ -763,6 +776,11 @@ export class ActiveCode extends RunestoneBase {
763776
}
764777
}
765778

779+
resetCode() {
780+
localStorage.removeItem(this.divid);
781+
window.location.reload();
782+
}
783+
766784
async createGradeSummary() {
767785
// get grade and comments for this assignment
768786
// get summary of all grades for this student

runestone/dist/node_modules_moment_locale_sync_recursive_-runestone_activecode_js_acfactory_js.bundle.js

Lines changed: 19 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)