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

Commit d8c97a8

Browse files
authored
Merge branch 'master' into rust
2 parents 115c5cf + c6ac4d5 commit d8c97a8

4 files changed

Lines changed: 41 additions & 18 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"license": "ISC",
2020
"devDependencies": {
2121
"copy-webpack-plugin": "^8.0.0",
22+
"compression-webpack-plugin": "^6.0.0",
2223
"css-loader": "^5.0.0",
2324
"css-minimizer-webpack-plugin": "^3.0.0",
2425
"eslint": "^7.0.0",

runestone/common/js/bookfuncs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ function handlePageSetup() {
180180
}
181181
$(document).trigger("runestone:login");
182182
addReadingList();
183-
timedRefresh();
183+
// Avoid the timedRefresh on the grading page.
184+
if (window.location.pathname.indexOf("/admin/grading") == -1) {
185+
timedRefresh();
186+
}
184187
} else {
185188
mess = "Not logged in";
186189
$(document).trigger("runestone:logout");

runestone/common/js/runestonebase.js

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,22 @@ export default class RunestoneBase {
9393
eventInfo.percent = this.percent;
9494
}
9595
if (eBookConfig.useRunestoneServices && eBookConfig.logLevel > 0) {
96-
let request = new Request(eBookConfig.ajaxURL + "hsblog", {
97-
method: "POST",
98-
headers: this.jsonHeaders,
99-
body: JSON.stringify(eventInfo),
100-
});
101-
try {
102-
let response = await fetch(request);
103-
if (!response.ok) {
104-
throw new Error("Failed to save the log entry");
105-
}
106-
post_return = response.json();
107-
} catch (e) {
108-
if (this.isTimed) {
109-
alert(`Error: Your action was not saved! The error was ${e}`);
110-
}
111-
console.log(`Error: ${e}`);
112-
}
96+
post_return = this.postLogMessage(eventInfo)
11397
}
11498
if (!this.isTimed || eBookConfig.debug) {
11599
console.log("logging event " + JSON.stringify(eventInfo));
116100
}
101+
// When selectquestions are part of an assignment especially toggle questions
102+
// we need to count using the selector_id of the select question.
103+
// We also need to log an event for that selector so that we will know
104+
// that interaction has taken place. This is **independent** of how the
105+
// autograder will ultimately grade the question!
106+
if (this.selector_id) {
107+
eventInfo.div_id = this.selector_id.replace("-toggleSelectedQuestion", "");
108+
eventInfo.event = "selectquestion";
109+
eventInfo.act = "interaction"
110+
this.postLogMessage(eventInfo);
111+
}
117112
if (
118113
typeof pageProgressTracker.updateProgress === "function" &&
119114
eventInfo.act != "edit" &&
@@ -124,6 +119,27 @@ export default class RunestoneBase {
124119
return post_return;
125120
}
126121

122+
async postLogMessage(eventInfo) {
123+
var post_return;
124+
let request = new Request(eBookConfig.ajaxURL + "hsblog", {
125+
method: "POST",
126+
headers: this.jsonHeaders,
127+
body: JSON.stringify(eventInfo),
128+
});
129+
try {
130+
let response = await fetch(request);
131+
if (!response.ok) {
132+
throw new Error("Failed to save the log entry");
133+
}
134+
post_return = response.json();
135+
} catch (e) {
136+
if (this.isTimed) {
137+
alert(`Error: Your action was not saved! The error was ${e}`);
138+
}
139+
console.log(`Error: ${e}`);
140+
}
141+
return post_return;
142+
}
127143
// .. _logRunEvent:
128144
//
129145
// logRunEvent

webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const path = require("path");
1010

1111
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
1212
const CopyPlugin = require('copy-webpack-plugin');
13+
const CompressionPlugin = require("compression-webpack-plugin");
1314
const HtmlWebpackPlugin = require('html-webpack-plugin');
1415
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
1516

@@ -90,6 +91,8 @@ module.exports = (env, argv) => {
9091
filename: '[name].css?v=[contenthash]',
9192
chunkFilename: '[id].css',
9293
}),
94+
// Copied from the `webpack docs <https://webpack.js.org/plugins/compression-webpack-plugin>`_. This creates ``.gz`` versions of all files. The webserver in use needs to be configured to send this instead of the uncompressed versions.
95+
new CompressionPlugin(),
9396
],
9497
};
9598
};

0 commit comments

Comments
 (0)