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

Commit 5afb856

Browse files
committed
make sql work when browsing
1 parent dede734 commit 5afb856

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

runestone/activecode/js/activecode_sql.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ActiveCode } from "./activecode.js";
22
import Handsontable from "handsontable";
3-
import 'handsontable/dist/handsontable.full.css';
3+
import "handsontable/dist/handsontable.full.css";
44
import initSqlJs from "sql.js/dist/sql-wasm.js";
55

66
var allDburls = {};
@@ -11,10 +11,16 @@ export default class SQLActiveCode extends ActiveCode {
1111
// fnprefix sets the path to load the sql-wasm.wasm file
1212
var bookprefix;
1313
var fnprefix;
14-
if (eBookConfig.useRunestoneServices) {
14+
// Fix: the mode=browsing problem wich disables useRunestoneServices and
15+
// makes it impossible to cororectly load sql-wasm
16+
if (
17+
eBookConfig.useRunestoneServices ||
18+
window.location.search.includes("mode=browsing")
19+
) {
1520
bookprefix = `${eBookConfig.app}/books/published/${eBookConfig.basecourse}`;
1621
fnprefix = bookprefix + "/_static";
1722
} else {
23+
// The else clause handles the case where you are building for a static web browser
1824
bookprefix = "";
1925
fnprefix = "/_static";
2026
}
@@ -299,8 +305,9 @@ export default class SQLActiveCode extends ActiveCode {
299305
}
300306
let pct = (100 * this.passed) / (this.passed + this.failed);
301307
pct = pct.toLocaleString(undefined, { maximumFractionDigits: 2 });
302-
result += `You passed ${this.passed} out of ${this.passed + this.failed
303-
} tests for ${pct}%`;
308+
result += `You passed ${this.passed} out of ${
309+
this.passed + this.failed
310+
} tests for ${pct}%`;
304311
this.unit_results = `percent:${pct}:passed:${this.passed}:failed:${this.failed}`;
305312
return result;
306313
}

0 commit comments

Comments
 (0)