Skip to content

Commit 4fe19f7

Browse files
authored
Merge pull request #3 from sujith-rek/localstorage
Localstorage
2 parents 3f27c97 + b7efcc8 commit 4fe19f7

File tree

59 files changed

+17907
-249319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+17907
-249319
lines changed

runestone/activecode/js/activecode.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ export class ActiveCode extends RunestoneBase {
167167
} else if (edmode === "octave" || edmode === "MATLAB") {
168168
edmode = "text/x-octave";
169169
}
170-
var editor = CodeMirror(codeDiv, {
170+
171+
if(localStorage.getItem(this.divid) !== null)
172+
this.code = localStorage.getItem(this.divid);
173+
174+
var opts = {
171175
value: this.code,
172176
lineNumbers: true,
173177
mode: edmode,
@@ -178,7 +182,9 @@ export class ActiveCode extends RunestoneBase {
178182
Tab: "indentMore",
179183
"Shift-Tab": "indentLess",
180184
},
181-
});
185+
}
186+
var editor = CodeMirror(codeDiv,opts );
187+
182188
// Make the editor resizable
183189
$(editor.getWrapperElement()).resizable({
184190
resize: function () {
@@ -242,7 +248,7 @@ export class ActiveCode extends RunestoneBase {
242248
}
243249

244250
async runButtonHandler() {
245-
// Disable the run button until the run is finished.
251+
// Disable the run button until the run is finished.
246252
this.runButton.disabled = true;
247253
try {
248254
await this.runProg();
@@ -1190,7 +1196,7 @@ Yet another is that there is an internal error. The internal error message is:
11901196
}
11911197

11921198
logCurrentAnswer() {
1193-
this.logRunEvent({
1199+
let data = {
11941200
div_id: this.divid,
11951201
code: this.editor.getValue(),
11961202
lang: this.language,
@@ -1199,7 +1205,11 @@ Yet another is that there is an internal error. The internal error message is:
11991205
prefix: this.pretext,
12001206
suffix: this.suffix,
12011207
partner: this.partner,
1202-
}); // Log the run event
1208+
};
1209+
1210+
localStorage.setItem(this.divid, data['code']);
1211+
1212+
this.logRunEvent(data); // Log the run event
12031213
// If unit tests were run there will be a unit_results
12041214
if (this.unit_results) {
12051215
this.logBookEvent({
@@ -1285,6 +1295,9 @@ Yet another is that there is an internal error. The internal error message is:
12851295
});
12861296
Sk.divid = this.divid;
12871297
Sk.logResults = logResults;
1298+
1299+
localStorage.setItem(this.divid,this.code);
1300+
12881301
if (this.graderactive && this.outerDiv.closest(".loading")) {
12891302
Sk.gradeContainer = this.outerDiv.closest(".loading").id;
12901303
} else {

runestone/dist/node_modules_moment_locale_sync_recursive_-runestone_activecode_js_acfactory_js.bundle.js

Lines changed: 80 additions & 21 deletions
Large diffs are not rendered by default.

runestone/dist/runestone.bundle.js

Lines changed: 323 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)