From 616b16ae2981cb9a0c2c6fe91b410c1ba1311b0f Mon Sep 17 00:00:00 2001 From: andrymodeste Date: Wed, 19 Nov 2025 23:11:04 +0100 Subject: [PATCH] =?UTF-8?q?r=C3=A9ectification=20de=20moyenne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/components/ReleverNotes.jsx | 58 ++++++++++++------- .../function/PDFEditorCertificate.js | 16 ++--- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/src/renderer/src/components/ReleverNotes.jsx b/src/renderer/src/components/ReleverNotes.jsx index e525797..2d0757e 100644 --- a/src/renderer/src/components/ReleverNotes.jsx +++ b/src/renderer/src/components/ReleverNotes.jsx @@ -416,32 +416,46 @@ const ReleverNotes = ({ id, anneescolaire, niveau, sessionType = 'ensemble', ref } // MODIFICATION: Fonction totalNotes mise à jour pour utiliser les nouvelles classes - const totalNotes = () => { - let totalNotesNormale = document.querySelectorAll('.moyenneUENormale') - let totalNotesRattrapage = document.querySelectorAll('.moyenneUERattrapage') - - let TotalNoteNumber = 0 - let TotalNoteNumberRepech = 0 - - totalNotesNormale.forEach((notes) => { - TotalNoteNumber += Number(notes.textContent) / totalNotesNormale.length + // Remplacer la fonction totalNotes() dans ReleverNotes.jsx par celle-ci : + +const totalNotes = () => { + // Calculer la moyenne pondérée par les crédits selon le type de session + let totalNotesPonderees = 0 + let totalCredits = 0 + + if (sessionType === 'normale') { + // Utiliser uniquement les notes normales + matiereWithSemestre.forEach((matiere) => { + if (matiere.note != null && !isNaN(matiere.note)) { + totalNotesPonderees += matiere.note * matiere.credit + totalCredits += matiere.credit + } }) - - totalNotesRattrapage.forEach((notes) => { - TotalNoteNumberRepech += Number(notes.textContent) / totalNotesRattrapage.length + } else if (sessionType === 'rattrapage') { + // Utiliser uniquement les notes de rattrapage + matiereWithSemestre.forEach((matiere) => { + if (matiere.noterepech != null && !isNaN(matiere.noterepech)) { + totalNotesPonderees += matiere.noterepech * matiere.credit + totalCredits += matiere.credit + } + }) + } else { + // Pour 'ensemble', prendre la meilleure note entre normale et rattrapage pour chaque matière + matiereWithSemestre.forEach((matiere) => { + const noteNormale = matiere.note != null && !isNaN(matiere.note) ? matiere.note : 0 + const noteRattrapage = matiere.noterepech != null && !isNaN(matiere.noterepech) ? matiere.noterepech : 0 + const bestNote = Math.max(noteNormale, noteRattrapage) + + if (bestNote > 0) { + totalNotesPonderees += bestNote * matiere.credit + totalCredits += matiere.credit + } }) - - // Retourner la note selon le type de session - if (sessionType === 'normale') { - return TotalNoteNumber - } else if (sessionType === 'rattrapage') { - return TotalNoteNumberRepech - } else { - // Pour 'ensemble', prendre la meilleure note - return Math.max(TotalNoteNumber, TotalNoteNumberRepech) - } } + return totalCredits > 0 ? totalNotesPonderees / totalCredits : 0 +} + const [note, setNote] = useState(0) useEffect(() => { diff --git a/src/renderer/src/components/function/PDFEditorCertificate.js b/src/renderer/src/components/function/PDFEditorCertificate.js index a0fbbc8..089e46d 100644 --- a/src/renderer/src/components/function/PDFEditorCertificate.js +++ b/src/renderer/src/components/function/PDFEditorCertificate.js @@ -14,14 +14,14 @@ const PDFEditorCertificat = async (data) => { function writeniveau(niveaus) { const niveauxMap = { - L1: '1e année de licences', - L2: '2e année de licences', - L3: '3e année de licences', - M1: '1e année de master', - M2: '2e année de master', - D1: '1e année en doctorat', - D2: '2e année en doctorat', - D3: '3e année en doctorat' + L1: '1er année de licence', + L2: '2ème année de licence', + L3: '3ème année de licence', + M1: '1er année de master', + M2: '2ème année de master', + D1: '1er année en doctorat', + D2: '2ème année en doctorat', + D3: '3ème année en doctorat' } return niveauxMap[niveaus] || 'Niveau inconnu' }