Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit a733e82

Browse files
committed
More testing of new async code
1 parent a840956 commit a733e82

3 files changed

Lines changed: 26 additions & 18 deletions

File tree

runestone/activecode/js/livecode.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ export default class LiveCode extends ActiveCode {
107107
return;
108108
}
109109

110-
var __ret = this.manage_scrubber(scrubber_dfd, history_dfd, saveCode);
110+
var __ret = await this.manage_scrubber(
111+
scrubber_dfd,
112+
history_dfd,
113+
saveCode
114+
);
111115
history_dfd = __ret.history_dfd;
112116
saveCode = __ret.saveCode;
113117

runestone/common/js/runestonebase.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,25 @@ export default class RunestoneBase {
141141
data.sid = this.sid;
142142
}
143143
if (!eBookConfig.practice_mode && this.assessmentTaken) {
144-
jQuery
145-
.getJSON(
146-
eBookConfig.ajaxURL + "getAssessResults",
147-
data,
148-
// defined in in RunestoneBase
149-
this.repopulateFromStorage.bind(this)
150-
)
151-
.fail(
152-
function () {
153-
try {
154-
this.checkLocalStorage();
155-
} catch (err) {
156-
console.log(err);
157-
}
158-
}.bind(this)
159-
);
144+
let request = new Request(
145+
eBookConfig.ajaxURL + "getAssessResults",
146+
{
147+
method: "POST",
148+
body: JSON.stringify(data),
149+
headers: this.jsonHeaders,
150+
}
151+
);
152+
try {
153+
let response = await fetch(request);
154+
let data = await response.json();
155+
this.repopulateFromStorage(data);
156+
} catch (err) {
157+
try {
158+
this.checkLocalStorage();
159+
} catch (err) {
160+
console.log(err);
161+
}
162+
}
160163
} else {
161164
this.loadData({});
162165
}
@@ -180,7 +183,7 @@ export default class RunestoneBase {
180183
* @param {*} status - the http status
181184
* @param {*} whatever - ignored
182185
*/
183-
repopulateFromStorage(data, status, whatever) {
186+
repopulateFromStorage(data) {
184187
// decide whether to use the server's answer (if there is one) or to load from storage
185188
if (data !== null && this.shouldUseServer(data)) {
186189
this.restoreAnswers(data);

runestone/common/js/user-highlights.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ function processPageState(completionFlag) {
286286
};
287287
$(document).ajaxError(function (e, jqhxr, settings, exception) {
288288
console.log("Request Failed for " + settings.url);
289+
console.log(e);
289290
});
290291
jQuery.ajax({
291292
url: eBookConfig.ajaxURL + "updatelastpage",

0 commit comments

Comments
 (0)