Skip to content

Instantly share code, notes, and snippets.

@thvd
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thvd/9598768 to your computer and use it in GitHub Desktop.
Save thvd/9598768 to your computer and use it in GitHub Desktop.
Educator calculate unweighted or weighted average mark
var x = Array.prototype.slice.call(document.querySelectorAll('.datatable > tbody > tr > td:nth-child(4n)'), 0)
.filter(function(elem) {return elem.textContent != ''; })
.map(function(elem) {return parseFloat(elem.textContent); });
var total = x.reduce(function(a, b) {return a+b;})
console.info(total/x.length)
var x = Array.prototype.slice.call(document.querySelectorAll('.datatable > tbody > tr > td:nth-child(4n),.datatable > tbody > tr > td:nth-child(6n)', 0));
var y = [];
for (var i = 0; i < x.length; i+=2)
if (x[i].textContent != '' && x[i + 1] && x[i + 1].textContent)
y.push(parseFloat(x[i].textContent) * parseFloat(x[i + 1].textContent));
var gotEc = parseInt(document.getElementById("id47").textContent.split("er ")[1].split(" behaald.")[0])
var total = y.reduce(function(a, b) {return a+b;})
console.info(total/gotEc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment