-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoGrader.user.js
More file actions
38 lines (33 loc) · 1.25 KB
/
AutoGrader.user.js
File metadata and controls
38 lines (33 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// ==UserScript==
// @name BlackBoard Automatic Grader
// @namespace Violentmonkey Scripts
// @include https://*.blackboard.com/webapps/bb-selfpeer-*/contentType/marking/evaluation.jsp*
// @grant none
// @version 1.0
// @author inVariabl
// @description Expedites the grading process by automatically filling in the maximum point values for text inputs and checking all checkboxes.
// ==/UserScript==
function getMaxPointsFromLabel(id) {
return parseInt(document.querySelector(`label[for="${id}"]`).innerText.split(" ").at(-1));
}
function setMaxPointsForInput(id, point) {
document.querySelector(`input[id="${id}"]`).value = point;
}
function setCheckboxValue(id, value) {
document.querySelector(`input[id="${id}"]`).checked = value;
}
function givePoints(type) {
const inputElements = Array.from(document.querySelectorAll(`input[type="${type}"]`));
inputElements.forEach((input) => {
const id = input.id;
if (type === "text") {
const point = getMaxPointsFromLabel(id);
setMaxPointsForInput(id, point);
} else if (type === "checkbox") {
setCheckboxValue(id, true);
}
});
}
givePoints("text");
givePoints("checkbox");
document.querySelector("#containerdiv > form > p > input.submit").click(); // submit