Skip to content

Instantly share code, notes, and snippets.

@kelvinpalves
Last active July 22, 2022 04:00
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 kelvinpalves/129e0f9166ee8a7fc70a30cb8f83d7c3 to your computer and use it in GitHub Desktop.
Save kelvinpalves/129e0f9166ee8a7fc70a30cb8f83d7c3 to your computer and use it in GitHub Desktop.
Calcular média geral UNISC - Serviços Acadêmicos.
function calcularMedia() {
var linhas = document.getElementById('disciplina-cursada-grid').getElementsByTagName('tbody')[0].rows;
var retorno = { totalDisciplinas: 0, totalNotas: 0, mediaFinal: 0, maiorQue8: 0 };
for (var i = 0; i < linhas.length; i++) {
if (linhas[i].cells.length > 4) {
if (linhas[i].cells[11].innerText != 'Reprovada') {
retorno.totalDisciplinas++;
console.log('Nota: ' + parseFloat(linhas[i].cells[8].innerText.replace(",", ".")));
if (parseFloat(linhas[i].cells[8].innerText.replace(",", ".")) > 9) {
retorno.maiorQue8++;
}
retorno.totalNotas += parseFloat(linhas[i].cells[8].innerText.replace(",", "."));
}
}
}
retorno.mediaFinal = parseFloat((retorno.totalNotas / retorno.totalDisciplinas).toFixed(2));
delete retorno.totalNotas;
console.table(retorno);
}
calcularMedia();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment