Skip to content

Instantly share code, notes, and snippets.

@Matoex
Created December 30, 2021 16:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Matoex/31c34eba5a13c5b5ed7a5c3865253192 to your computer and use it in GitHub Desktop.
Save Matoex/31c34eba5a13c5b5ed7a5c3865253192 to your computer and use it in GitHub Desktop.
Studon Punkte und Prozent berechnen
/*
Berechnet die erreichte und maximale Punktzahl (daraus auch die %) einer Übungsseite in Studon der FAU
Den Code einfach mit F12 im richtigen Tab in die Browserkonsole einfügen und enter drücken, das Ergebnis erscheint in der Konsole.
*/
erreicht = Array.from(document.querySelectorAll(".ilTag")).map(x => x.innerText).map(x=>parseFloat(x.split(" ")[1])).reduce((a,b)=>a+b)
maxSumme = Array.from(document.querySelectorAll(".ilExcAssignmentHead")).filter(x=>x.children[0].alt != "Nicht bewertet").map(x=>parseFloat(x.outerText.split("max. ")[1].split(" ")[0])).reduce((a,b)=>a+b)
console.log(erreicht + "/"+maxSumme+"="+Math.round((erreicht/maxSumme)*1000)/10 + "%")
@quwepiro
Copy link

quwepiro commented Jan 11, 2022

Hi @Matoex
I have made some small changes to your script, as on most sites the "erreicht" array parses some NaN, which are now filtered out.

erreicht = Array.from(document.querySelectorAll(".ilTag")).map(x => x.innerText).map(x => parseFloat(x.split(" ")[1])).filter(value => !Number.isNaN(value)).reduce((a, b) => a + b)

maxSumme = Array.from(document.querySelectorAll(".ilExcAssignmentHead")).filter(x => x.children[0].alt != "Nicht bewertet").map(x => parseFloat(x.outerText.split("max. ")[1].split(" ")[0])).filter(value => !Number.isNaN(value)).reduce((a, b) => a + b)

console.log(erreicht + "/" + maxSumme + " = " + Math.round((erreicht / maxSumme) * 1000) / 10 + "%")

(I know it is not the best solution, but works 😉 )
Edit: As I do not know how to create pull request to Github-Gists, I posted this comment

@quwepiro
Copy link

javascript:(function(){erreicht = Array.from(document.querySelectorAll(".ilTag")).map(x => x.innerText).map(x => parseFloat(x.split(" ")[1])).filter(value => !Number.isNaN(value)).reduce((a, b) => a + b);maxSumme = Array.from(document.querySelectorAll(".ilExcAssignmentHead")).filter(x => x.children[0].alt != "Nicht bewertet").map(x => parseFloat(x.outerText.split("max. ")[1].split(" ")[0])).filter(value => !Number.isNaN(value)).reduce((a, b) => a + b);alert("Erreichte Punkte/Note: " + erreicht +"\nMaximale Punkte/Note: " + maxSumme + "\nIn Prozent: " + (Math.round((erreicht / maxSumme) * 1000) / 10));})();
javascript:(function(){erreicht = Array.from(document.querySelectorAll(".ilTag")).map(x => x.innerText).map(x => parseFloat(x.split(" ")[1])).filter(value => !Number.isNaN(value)).reduce((a, b) => a + b);maxSumme = Array.from(document.querySelectorAll(".ilExcAssignmentHead")).filter(x => x.children[0].alt != "Nicht bewertet").map(x => parseFloat(x.outerText.split("max. ")[1].split(" ")[0])).filter(value => !Number.isNaN(value)).reduce((a, b) => a + b);alert("Note/Punkte:\n" + erreicht + " / " + maxSumme + " = " + Math.round((erreicht / maxSumme) * 1000) / 10 + "%");})();

I created two bookmarklets: Copy one of the two codelines and create a new bookmark. In the URL-field you paste the code.
The next time you are on the studon site click that bookmark and it will display your points and percentage

@quwepiro
Copy link

I moved the scripts to an separate repository: https://gitlab.cs.fau.de/ja06otbo/studon-score as I made some more bugfixes today and it is a lot easier to commit these changes than actually writing a new comment every day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment