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

Commit 7f705eb

Browse files
committed
Some parts of initialization rely on checkServer being complete
1 parent ed3c560 commit 7f705eb

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

runestone/common/js/runestonebase.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ export default class RunestoneBase {
140140
/* Checking/loading from storage */
141141
async checkServer(eventInfo) {
142142
// Check if the server has stored answer
143+
let self = this;
144+
this.checkServerComplete = new Promise(function (resolve, reject) {
145+
self.csresolver = resolve;
146+
});
143147
if (this.useRunestoneServices || this.graderactive) {
144148
let data = {};
145149
data.div_id = this.divid;
@@ -166,6 +170,7 @@ export default class RunestoneBase {
166170
let response = await fetch(request);
167171
data = await response.json();
168172
this.repopulateFromStorage(data);
173+
this.csresolver("server");
169174
} catch (err) {
170175
try {
171176
this.checkLocalStorage();
@@ -178,6 +183,7 @@ export default class RunestoneBase {
178183
}
179184
} else {
180185
this.checkLocalStorage(); // just go right to local storage
186+
this.csresolver("local");
181187
}
182188
}
183189

runestone/parsons/js/parsons.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2059,8 +2059,9 @@ export default class Parsons extends RunestoneBase {
20592059
$(this.messageDiv).hide();
20602060
}
20612061
// Disable the interface
2062-
disableInteraction() {
2062+
async disableInteraction() {
20632063
// Disable blocks
2064+
await this.checkServerComplete;
20642065
if (this.blocks !== undefined) {
20652066
for (var i = 0; i < this.blocks.length; i++) {
20662067
var block = this.blocks[i];

0 commit comments

Comments
 (0)