Created
February 10, 2022 17:58
-
-
Save Nicooow/6658ada622236c7c17e4c262cd5ca788 to your computer and use it in GitHub Desktop.
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
var waitForEl = function(selector, callback) { | |
if ($(selector).length) { | |
callback(); | |
} else { | |
setTimeout(function() { | |
waitForEl(selector, callback); | |
}, 100); | |
} | |
}; | |
function init(){ | |
checkDoitOuvrir(); | |
$("#" + $.escapeSelector("topFormMenu:j_id_11")).attr("style", "background-image:linear-gradient(to right, red,orange,yellow,green,blue,indigo,violet);"); | |
$("#mainBilanForm > div").attr("style", "background-image:linear-gradient(to right, red,orange,yellow,green,blue,indigo,violet);"); | |
} | |
function checkDoitOuvrir(){ | |
var selectorButton = '.ui-treetable-toggler.ui-icon-triangle-1-e:not([style^="visibility: hidden"]):not([style^="visibility:hidden"])'; | |
var doitOuvrir = $(selectorButton).length != 0 | |
if(doitOuvrir){ | |
$(selectorButton).click() | |
waitForEl("#"+$.escapeSelector("topFormMenu:j_id_t")+'[style*="display: none;"]', checkDoitOuvrir); | |
}else{ | |
var modeParcours = $(".ui-node-level-4").length != 0 | |
modeParcours = 0; | |
calculMatiere(modeParcours ? 1 : 0); | |
} | |
} | |
function calculMatiere(offset){ | |
$(".ui-node-level-"+(1+offset)).each(function( i2 ) { // pour chaque parcours | |
var sumNoteParcours = 0; | |
var sumCoefParcours = 0; | |
$("[id^="+ $.escapeSelector($(this).attr("id")) +"].ui-node-level-"+(2+offset)).each(function( i2 ) { // pour chaque UE | |
var sumNoteUE = 0; | |
var sumCoefUE = 0; | |
let coefUE = parseFloat($( this ).children("td:nth-child(2)").text()); | |
$("[id^="+ $.escapeSelector($(this).attr("id")) +"].moduleNiv3").each(function( i3 ) { // pour chaque matiere | |
let regex = /\[(.*?)\]\(([0-9]+[.][0-9]+)\)/gm; | |
let coefMatiere = parseFloat($( this ).children("td:nth-child(2)").text()); | |
let str = $( this ).children("td:nth-child(3)").text(); | |
const matches = [...str.matchAll(regex)]; | |
var sumNoteMatiere = 0; | |
var sumCoefMatiere = 0; | |
//console.log("==========="); | |
for (const match of matches) { // pour chaque groupe de note | |
let strMatch = match[1]; | |
let coefMatch = parseFloat(match[2]); | |
let rgxMatch = /([0-9]+[.][0-9]+) \/([0-9]+[.][0-9]+)\(([0-9]+[.][0-9]+)\)/gm; | |
var sumNote = 0; | |
var sumCoef = 0; | |
const notes = [...strMatch.matchAll(rgxMatch)]; | |
for (const note of notes) { // pour chaque note | |
let valeur_note = parseFloat(note[1]); | |
let valeur_note_max = parseFloat(note[2]); | |
let valeur_note_coef = parseFloat(note[3]); | |
//console.log(valeur_note + "/" + valeur_note_max + ", coef : " + valeur_note_coef); | |
sumNote += (valeur_note*20/valeur_note_max)*valeur_note_coef; | |
sumCoef += valeur_note_coef; | |
} | |
var moyenneGroupe = sumNote/sumCoef; | |
sumNoteMatiere += (moyenneGroupe)*coefMatch; | |
sumCoefMatiere += coefMatch; | |
} | |
var moyenneMatiere = sumNoteMatiere/sumCoefMatiere; | |
moyenneMatiere = Math.round(moyenneMatiere*100)/100; | |
//console.log(moyenneMatiere); | |
$( this ).children("td:nth-child(4)").html(moyenneMatiere); | |
if(!isNaN(moyenneMatiere)){ | |
sumNoteUE += moyenneMatiere*coefMatiere | |
sumCoefUE += coefMatiere | |
} | |
}); | |
//console.log("_____________________________"); | |
var moyenneUE = sumNoteUE/sumCoefUE; | |
moyenneUE = Math.round(moyenneUE*100)/100; | |
$( this ).children("td:nth-child(4)").html(moyenneUE); | |
if(!isNaN(moyenneUE)){ | |
sumNoteParcours += moyenneUE*coefUE | |
sumCoefParcours += coefUE | |
} | |
}); | |
var moyenneParcours = sumNoteParcours/sumCoefParcours; | |
moyenneParcours = Math.round(moyenneParcours*100)/100; | |
$( this ).children("td:nth-child(4)").html(moyenneParcours); | |
}); | |
} | |
init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment