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

Commit bea64c4

Browse files
authored
Merge pull request #1309 from bjones1/fitb-fix
Fix: Correctly handle the non-server-side case in fitb.js
2 parents a77e1ca + 6ad4341 commit bea64c4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

runestone/fitb/js/fitb.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,24 +223,25 @@ export default class FITB extends RunestoneBase {
223223
if (typeof sid !== "undefined") {
224224
data.sid = sid;
225225
feedback = false;
226-
};
226+
}
227+
// Per `logBookEvent <logBookEvent>`, the result is undefined if there's no server. Otherwise, the server provides the endpoint-specific results in ``data.details``; see `make_json_response`.
227228
data = await this.logBookEvent(data);
228-
data = data.detail;
229+
let detail = data && data.detail;
229230
if (!feedback) return;
230231
if (!this.feedbackArray) {
231232
// On success, update the feedback from the server's grade.
232233
this.setLocalStorage({
233234
answer: answer,
234-
timestamp: data.timestamp,
235+
timestamp: detail.timestamp,
235236
});
236-
this.correct = data.correct;
237-
this.displayFeed = data.displayFeed;
238-
this.isCorrectArray = data.isCorrectArray;
237+
this.correct = detail.correct;
238+
this.displayFeed = detail.displayFeed;
239+
this.isCorrectArray = detail.isCorrectArray;
239240
if (!this.isTimed) {
240241
this.renderFeedback();
241242
}
242243
}
243-
return data;
244+
return detail;
244245
}
245246

246247
/*==============================
@@ -343,7 +344,7 @@ export default class FITB extends RunestoneBase {
343344
}
344345
this.feedBackDiv.innerHTML = feedback_html;
345346
if (typeof MathJax !== "undefined") {
346-
this.queueMathJax(document.body)
347+
this.queueMathJax(document.body);
347348
}
348349
}
349350

0 commit comments

Comments
 (0)