/* Module par Seb. L. */
class releveBUT extends HTMLElement {
constructor(){
super();
this.shadow = this.attachShadow({mode: 'open'});
/* Config par defaut */
this.config = {
showURL: true
};
/* Template du module */
this.shadow.innerHTML = this.template();
/* Style du module */
const styles = document.createElement('link');
styles.setAttribute('rel', 'stylesheet');
styles.setAttribute('href', '/ScoDoc/static/css/releve-but.css');
this.shadow.appendChild(styles);
}
listeOnOff() {
this.parentElement.parentElement.classList.toggle("listeOff");
this.parentElement.parentElement.querySelectorAll(".moduleOnOff").forEach(e=>{
e.classList.remove("moduleOnOff")
})
}
moduleOnOff(){
this.parentElement.classList.toggle("moduleOnOff");
}
goTo(){
let module = this.dataset.module;
this.parentElement.parentElement.parentElement.parentElement.querySelector("#Module_" + module).scrollIntoView();
}
set setConfig(config){
this.config.showURL = config.showURL ?? this.config.showURL;
}
set showData(data) {
this.showInformations(data);
this.showSemestre(data);
this.showSynthese(data);
this.showEvaluations(data);
this.setOptions(data.options);
this.shadow.querySelectorAll(".CTA_Liste").forEach(e => {
e.addEventListener("click", this.listeOnOff)
})
this.shadow.querySelectorAll(".ue, .module").forEach(e => {
e.addEventListener("click", this.moduleOnOff)
})
this.shadow.querySelectorAll(".syntheseModule").forEach(e => {
e.addEventListener("click", this.goTo)
})
this.shadow.children[0].classList.add("ready");
}
template(){
return `
`;
} else {
output += ``;
}
output += `
${this.civilite(data.etudiant.civilite)}
${data.etudiant.nom}
${data.etudiant.prenom}`;
if (data.etudiant.date_naissance) {
output += `
né${(data.etudiant.civilite == "F") ? "e" : ""} le ${this.ISOToDate(data.etudiant.date_naissance)}
`;
}
output += `
Numéro étudiant : ${data.etudiant.code_nip} -
Code INE : ${data.etudiant.code_ine}
${data.formation.titre}
`;
if(this.config.showURL){
output += ``;
} else {
output += `
`;
}
this.shadow.querySelector(".infoEtudiant").innerHTML = output;
}
/*******************************/
/* Information sur le semestre */
/*******************************/
showSemestre(data) {
this.shadow.querySelector("h2").innerHTML += data.semestre.numero;
this.shadow.querySelector(".dateInscription").innerHTML += this.ISOToDate(data.semestre.inscription);
let output = `
Moyenne
${data.semestre.notes.value}
Rang :
${data.semestre.rang.value} / ${data.semestre.rang.total}
Max. promo. :
${data.semestre.notes.max}
Moy. promo. :
${data.semestre.notes.moy}
Min. promo. :
${data.semestre.notes.min}
`;
/*${data.semestre.groupes.map(groupe => {
return `
Groupe
${groupe.nom}
Rang :
${groupe.rang.value} / ${groupe.rang.total}
Max. groupe :
${groupe.notes.max}
Moy. groupe :
${groupe.notes.min}
Min. groupe :
${groupe.notes.min}
`;
}).join("")
}*/
this.shadow.querySelector(".infoSemestre").innerHTML = output;
this.shadow.querySelector(".decision").innerHTML = data.semestre.decision.code;
}
/*******************************/
/* Synthèse */
/*******************************/
showSynthese(data) {
let output = ``;
Object.entries(data.ues).forEach(([ue, dataUE]) => {
output += `
${(dataUE.competence) ? dataUE.competence + " - " : ""}${ue}
Moyenne : ${dataUE.moyenne?.value || "-"}
Bonus : ${dataUE.bonus || 0} -
Malus : ${dataUE.malus || 0}
-
ECTS : ${dataUE.ECTS.acquis} / ${dataUE.ECTS.total}
Abs N.J.
${dataUE.absences?.injustifie || 0}
Total
${dataUE.absences?.total || 0}
${this.synthese(data, dataUE.ressources)}
${this.synthese(data, dataUE.saes)}
`;
});
this.shadow.querySelector(".synthese").innerHTML = output;
}
synthese(data, modules) {
let output = "";
Object.entries(modules).forEach(([module, dataModule]) => {
let titre = data.ressources[module]?.titre || data.saes[module]?.titre;
let url = data.ressources[module]?.url || data.saes[module]?.url;
output += `
${module} - ${titre}
${dataModule.moyenne}
Coef. ${dataModule.coef}
`;
})
return output;
}
/*******************************/
/* Evaluations */
/*******************************/
showEvaluations(data) {
this.shadow.querySelector(".evaluations").innerHTML = this.module(data.ressources);
this.shadow.querySelector(".sae").innerHTML += this.module(data.saes);
}
module(module) {
let output = "";
Object.entries(module).forEach(([numero, content]) => {
output += `
${this.URL(content.url, `${numero} - ${content.titre}`)}
Moyenne indicative : ${content.moyenne.value}
Classe : ${content.moyenne.moy} -
Max : ${content.moyenne.max} -
Min : ${content.moyenne.min}
Abs inj.
${content.absences?.injustifie || 0}
Total
${content.absences?.total || 0}
${this.evaluation(content.evaluations)}
`;
})
return output;
}
evaluation(evaluations) {
let output = "";
evaluations.forEach((evaluation) => {
output += `
${this.URL(evaluation.url, evaluation.description)}
${evaluation.note.value}
Coef. ${evaluation.coef}
Coef
${evaluation.coef}
Max. promo.
${evaluation.note.max}
Moy. promo.
${evaluation.note.moy}
Min. promo.
${evaluation.note.min}
${Object.entries(evaluation.poids).map(([UE, poids]) => {
return `
Poids ${UE}
${poids}
`;
}).join("")}
`;
})
return output;
}
/********************/
/* Options */
/********************/
setOptions(options) {
Object.entries(options).forEach(([option, value]) => {
if (value === false) {
document.body.classList.add(option.replace("show", "hide"))
}
})
}
/********************/
/* Fonctions d'aide */
/********************/
URL(href, content){
if(this.config.showURL){
return `