Last active
December 2, 2024 16:03
-
-
Save Greenscreener/2460bb8a8330e6bba875bb4641840f1d to your computer and use it in GitHub Desktop.
Just paste the JS file into your console while having your "exam results" window open and then run the python script on the resulting JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
subjects = json.load(open("znamky.json")) | |
subjects = [subject for subject in subjects if subject["finished"]] | |
subjects = [ | |
{**subject, "marked_attempts": [attempt for attempt in subject["attempts"] if attempt["outcome"].isnumeric()]} | |
for subject in subjects | |
] | |
subjects = [ | |
{**subject, "last_attempt": subject["marked_attempts"][-1]} | |
for subject in subjects | |
if len(subject["marked_attempts"]) > 0 | |
] | |
weighted_last = sum(int(subject["last_attempt"]["outcome"]) * subject["credits"] for subject in subjects) / sum(subject["credits"] for subject in subjects) | |
unweighted_all = sum(int(a["outcome"]) for subject in subjects for a in subject["marked_attempts"]) / sum(len(subject["marked_attempts"]) for subject in subjects) | |
unweighted_last = sum(int(subject["last_attempt"]["outcome"]) for subject in subjects) / len(subjects) | |
print(f"{weighted_last = }, {unweighted_all = }, {unweighted_last = },") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = [...document.querySelectorAll(".row1, .row2")].map(e => { | |
const attempts_numbers = e.children[5].innerText.split("\n").map(i => parseInt(i)) | |
const attempts_outcomes = e.children[6].innerText.split("\n") | |
const attempts_dates = e.children[7].innerText.split("\n") | |
const attempts_examiners = e.children[8].innerText.split("\n") | |
return { | |
year: e.parentElement.children[0].innerText, | |
semester: e.children[0].children.length > 0 ? "Z" : "L", | |
code: e.children[2].innerText, | |
name: e.children[3].innerText, | |
exam_type: e.children[4].innerText, | |
attempts: [...attempts_numbers.keys().map(i => ({ | |
number: attempts_numbers[i], | |
outcome: attempts_outcomes[i], | |
date: attempts_dates[i], | |
examiner: attempts_examiners[i] | |
}))], | |
requiredness: e.children[9].innerText, | |
credits: parseInt(e.children[10].innerText), | |
finished_for_semester: e.children[11].innerText === "Splněno", | |
finished: e.children[12].innerText === "Splněno", | |
} | |
}) | |
const hiddenElement = document.createElement('a'); | |
const blob = new Blob([JSON.stringify(data)], {type: "application/json"}) | |
hiddenElement.href = window.URL.createObjectURL(blob) | |
hiddenElement.download = 'znamky.json'; | |
hiddenElement.click(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment