-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
77 lines (62 loc) · 1.94 KB
/
index.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// hlnajz was here
// 15 hours
const getData = require("./getData.js");
const constants = require("./constants.json");
const makeRequest = require("./req.js");
async function main() {
const originalData = await getData();
const data = JSON.parse(JSON.stringify(originalData)).data;
console.log("Data received");
console.log(originalData);
const units = data.courseMenu.units.filter((unit) =>
constants["unitsToComplete"].includes(unit.unitNumber)
);
const totalTime = 15 * 60 * 60 * 1000; // change 15 to hours you want
const totalLessons = units.reduce(
(total, unit) =>
total +
unit.lessons.reduce((sum, category) => sum + category.paths.length, 0),
0
);
const timePerLesson = Math.floor(totalTime / totalLessons);
let timeSoFar = 0;
units.forEach((unit) => {
unit.lessons.forEach((category) => {
category.paths.forEach(
({
unitIndex,
curriculumLessonIndex,
type,
course,
numChallenges,
timeEstimate,
}) => {
const timeInMilliseconds = timePerLesson + getRndInteger(0, 6000);
const percentCorrect = getRndInteger(89, 100);
const questionsCorrect = Math.ceil(
numChallenges * (percentCorrect / 100)
);
const completed = !!(questionsCorrect == numChallenges) + "";
const timeCompleted = Date.now() + timeSoFar;
timeSoFar += timeInMilliseconds;
makeRequest({
course,
lessonIndex: curriculumLessonIndex,
questionAmount: numChallenges,
questionsCorrect,
unitIndex: unitIndex % 4,
time: timeInMilliseconds,
type,
completed,
timeCompleted,
});
}
);
});
});
console.log("Finished (wait for requests)!!");
}
function getRndInteger(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
main();