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

Commit 63b712e

Browse files
runestonetestbnmnetp
authored andcommitted
update processing for getassessment
1 parent bcb3eca commit 63b712e

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

runestone/common/js/runestonebase.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import { pageProgressTracker } from "./bookfuncs.js";
2020

2121
export default class RunestoneBase {
2222
constructor(opts) {
23-
this.component_ready_promise = new Promise(resolve => this._component_ready_resolve_fn = resolve)
23+
this.component_ready_promise = new Promise(
24+
(resolve) => (this._component_ready_resolve_fn = resolve)
25+
);
2426
this.optional = false;
2527
if (opts) {
2628
this.sid = opts.sid;
@@ -57,7 +59,7 @@ export default class RunestoneBase {
5759
// is to look for doAssignment in the URL and then grab
5860
// the assignment name from the heading.
5961
if (location.href.indexOf("doAssignment") >= 0) {
60-
this.timedWrapper = $("h1#assignment_name").text()
62+
this.timedWrapper = $("h1#assignment_name").text();
6163
} else {
6264
this.timedWrapper = null;
6365
}
@@ -102,7 +104,9 @@ export default class RunestoneBase {
102104
post_return = response.json();
103105
} catch (e) {
104106
if (this.isTimed) {
105-
alert(`Error: Your action was not saved! The error was ${e}`);
107+
alert(
108+
`Error: Your action was not saved! The error was ${e}`
109+
);
106110
}
107111
console.log(`Error: ${e}`);
108112
}
@@ -192,19 +196,23 @@ export default class RunestoneBase {
192196
data.sid = this.sid;
193197
}
194198
if (!eBookConfig.practice_mode && this.assessmentTaken) {
195-
let request = new Request(
196-
"/assessment/results",
197-
{
198-
method: "POST",
199-
body: JSON.stringify(data),
200-
headers: this.jsonHeaders,
201-
}
202-
);
199+
let request = new Request("/assessment/results", {
200+
method: "POST",
201+
body: JSON.stringify(data),
202+
headers: this.jsonHeaders,
203+
});
203204
try {
204205
let response = await fetch(request);
205-
data = await response.json();
206-
this.repopulateFromStorage(data);
207-
this.csresolver("server");
206+
if (response.ok) {
207+
data = await response.json();
208+
data = data.detail;
209+
this.repopulateFromStorage(data);
210+
this.csresolver("server");
211+
} else {
212+
alert(
213+
`HTTP Error getting results: ${response.statusText}`
214+
);
215+
}
208216
} catch (err) {
209217
try {
210218
this.checkLocalStorage();

0 commit comments

Comments
 (0)