Last active
July 22, 2022 04:00
-
-
Save kelvinpalves/129e0f9166ee8a7fc70a30cb8f83d7c3 to your computer and use it in GitHub Desktop.
Calcular média geral UNISC - Serviços Acadêmicos.
This file contains 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
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