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

Commit 99f8a60

Browse files
committed
remove app prefix when loading .wasm files
1 parent 96274a1 commit 99f8a60

File tree

2 files changed

+40
-25
lines changed

2 files changed

+40
-25
lines changed

runestone/activecode/js/activecode_sql.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class SQLActiveCode extends ActiveCode {
1717
eBookConfig.useRunestoneServices ||
1818
window.location.search.includes("mode=browsing")
1919
) {
20-
bookprefix = `${eBookConfig.app}/books/published/${eBookConfig.basecourse}`;
20+
bookprefix = `/books/published/${eBookConfig.basecourse}`;
2121
fnprefix = bookprefix + "/_static";
2222
} else {
2323
// The else clause handles the case where you are building for a static web browser

runestone/hparsons/js/SQLFeedback.js

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import HParsonsFeedback from "./hparsonsFeedback";
22
import initSqlJs from "sql.js/dist/sql-wasm.js";
33
import Handsontable from "handsontable";
4-
import 'handsontable/dist/handsontable.full.css';
4+
import "handsontable/dist/handsontable.full.css";
55

66
var allDburls = {};
77

88
export default class SQLFeedback extends HParsonsFeedback {
9-
109
createOutput() {
1110
var outDiv = document.createElement("div");
1211
$(outDiv).addClass("hp_output");
@@ -49,7 +48,7 @@ export default class SQLFeedback extends HParsonsFeedback {
4948
eBookConfig.useRunestoneServices ||
5049
window.location.search.includes("mode=browsing")
5150
) {
52-
bookprefix = `${eBookConfig.app}/books/published/${eBookConfig.basecourse}`;
51+
bookprefix = `/books/published/${eBookConfig.basecourse}`;
5352
fnprefix = bookprefix + "/_static";
5453
} else {
5554
// The else clause handles the case where you are building for a static web browser
@@ -156,35 +155,49 @@ export default class SQLFeedback extends HParsonsFeedback {
156155
let executionSuccessFlag = true;
157156
// executing hidden prefix if exist
158157
if (query.prefix) {
159-
this.prefixresults = this.executeIteratedStatements(this.hparsons.db.iterateStatements(query.prefix));
160-
if (this.prefixresults.at(-1).status == 'failure') {
158+
this.prefixresults = this.executeIteratedStatements(
159+
this.hparsons.db.iterateStatements(query.prefix)
160+
);
161+
if (this.prefixresults.at(-1).status == "failure") {
161162
// if error occured in hidden prefix, log and stop executing the rest
162-
this.visualizeResults(respDiv, this.prefixresults, "Error executing hidden code in prefix");
163+
this.visualizeResults(
164+
respDiv,
165+
this.prefixresults,
166+
"Error executing hidden code in prefix"
167+
);
163168
executionSuccessFlag = false;
164169
}
165170
}
166171

167172
// executing student input in micro Parsons
168173
if (executionSuccessFlag) {
169-
this.results = this.executeIteratedStatements(this.hparsons.db.iterateStatements(query.input));
170-
if (this.results.at(-1).status == 'failure') {
171-
// if error occured in student input, stop executing suffix/unitttest
174+
this.results = this.executeIteratedStatements(
175+
this.hparsons.db.iterateStatements(query.input)
176+
);
177+
if (this.results.at(-1).status == "failure") {
178+
// if error occured in student input, stop executing suffix/unitttest
172179
// and visualize the error
173180
this.visualizeResults(respDiv, this.results);
174181
executionSuccessFlag = false;
175182
} else if (!query.suffix) {
176183
this.visualizeResults(respDiv, this.results);
177184
}
178185
}
179-
186+
180187
// executing hidden suffix if exist
181-
// In most cases the suffix is just "select * from x" to
188+
// In most cases the suffix is just "select * from x" to
182189
// get all data from the table to see if the operations the table is correct
183190
if (executionSuccessFlag && query.suffix) {
184-
this.suffixresults = this.executeIteratedStatements(this.hparsons.db.iterateStatements(query.suffix));
185-
if (this.suffixresults.at(-1).status == 'failure') {
191+
this.suffixresults = this.executeIteratedStatements(
192+
this.hparsons.db.iterateStatements(query.suffix)
193+
);
194+
if (this.suffixresults.at(-1).status == "failure") {
186195
// if error occured in hidden suffix, visualize the results
187-
this.visualizeResults(respDiv, this.suffixresults, "Error executing hidden code in suffix");
196+
this.visualizeResults(
197+
respDiv,
198+
this.suffixresults,
199+
"Error executing hidden code in suffix"
200+
);
188201
executionSuccessFlag = false;
189202
} else {
190203
this.visualizeResults(respDiv, this.suffixresults);
@@ -357,15 +370,16 @@ export default class SQLFeedback extends HParsonsFeedback {
357370
}
358371
}
359372
}
360-
373+
361374
// adapted from activecode
362375
async buildProg() {
363376
// assemble code from prefix, suffix, and editor for running.
364377
let prog = {};
365378
if (this.hparsons.hiddenPrefix) {
366379
prog.prefix = this.hparsons.hiddenPrefix;
367380
}
368-
prog.input = this.hparsons.hparsonsInput.getParsonsTextArray().join(' ') + "\n";
381+
prog.input =
382+
this.hparsons.hparsonsInput.getParsonsTextArray().join(" ") + "\n";
369383
if (this.hparsons.hiddenSuffix) {
370384
prog.suffix = this.hparsons.hiddenSuffix;
371385
}
@@ -377,18 +391,18 @@ export default class SQLFeedback extends HParsonsFeedback {
377391
if (this.unit_results) {
378392
let act = {
379393
scheme: "execution",
380-
correct: (this.failed == 0 && this.passed != 0) ? "T" : "F",
394+
correct: this.failed == 0 && this.passed != 0 ? "T" : "F",
381395
answer: this.hparsons.hparsonsInput.getParsonsTextArray(),
382-
percent: this.percent // percent is null if there is execution error
383-
}
396+
percent: this.percent, // percent is null if there is execution error
397+
};
384398
let logData = {
385399
event: "hparsonsAnswer",
386400
div_id: this.hparsons.divid,
387401
act: JSON.stringify(act),
388402
percent: this.percent || 0,
389403
correct: act.correct,
390-
answer: JSON.stringify({"blocks": act.answer}),
391-
}
404+
answer: JSON.stringify({ blocks: act.answer }),
405+
};
392406
await this.hparsons.logBookEvent(logData);
393407
}
394408
}
@@ -424,8 +438,9 @@ export default class SQLFeedback extends HParsonsFeedback {
424438
let pct = (100 * this.passed) / (this.passed + this.failed);
425439
this.percent = pct;
426440
pct = pct.toLocaleString(undefined, { maximumFractionDigits: 2 });
427-
result += `You passed ${this.passed} out of ${this.passed + this.failed
428-
} tests for ${pct}%`;
441+
result += `You passed ${this.passed} out of ${
442+
this.passed + this.failed
443+
} tests for ${pct}%`;
429444
this.unit_results = `percent:${pct}:passed:${this.passed}:failed:${this.failed}`;
430445
return result;
431446
}
@@ -438,7 +453,7 @@ export default class SQLFeedback extends HParsonsFeedback {
438453
try {
439454
actual = result_table.values[row][col];
440455
} catch (e) {
441-
if (expected == 'NO_DATA') {
456+
if (expected == "NO_DATA") {
442457
this.passed++;
443458
output = `Passed: No data in row ${row}, column ${col}`;
444459
return output;

0 commit comments

Comments
 (0)