+++ /dev/null
-/*
- * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
- * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
- *
- * Lilie is free software. You can redistribute it and/or modify since
- * you respect the terms of either (at least one of the both license) :
- * - under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- * - the CeCILL-C as published by CeCILL-C; either version 1 of the
- * License, or any later version
- *
- * There are special exceptions to the terms and conditions of the
- * licenses as they are applied to this software. View the full text of
- * the exception in file LICENSE.txt in the directory of this software
- * distribution.
- *
- * Lilie is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Licenses for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the CeCILL-C along with Lilie. If not, see :
- * <http://www.gnu.org/licenses/> and
- * <http://www.cecill.info/licences.fr.html>.
- */
-
-package org.lilie.services.eliot.notes.impression.tdn
-
-import org.lilie.services.eliot.scolarite.personne.LocalPersonneService
-import org.lilie.services.eliot.notes.scolarite.NotesTypePeriodeService
-import org.lilie.services.eliot.notes.resultat.CalculationService
-import org.lilie.services.eliot.notes.notes.tableaudenotes.TableauDeNotesLigne
-import org.lilie.services.eliot.notes.notes.tableaudenotes.TableauDeNotes
-import org.lilie.services.eliot.utils.NoteFormateur
-import org.lilie.services.eliot.scolarite.StructureEnseignement
-import org.lilie.services.eliot.impression.donnees.tdn.TableauDeNotesImpression
-import org.lilie.services.eliot.scolarite.TypePeriode
-import org.lilie.services.eliot.scolarite.TypeIntervalleEnum
-import org.lilie.services.eliot.notes.ResultatEleveEnseignementPeriode
-import org.lilie.services.eliot.impression.donnees.tableauimpression.cellules.CelluleTableau
-import org.lilie.services.eliot.impression.donnees.tableauimpression.cellules.CelluleTypePeriode
-import org.lilie.services.eliot.annuaire.SecuriteSession
-import org.lilie.services.eliot.notes.Evaluation
-import org.lilie.services.eliot.scolarite.SousService
-import org.lilie.services.eliot.notes.Note
-import org.lilie.services.eliot.utils.EliotFormatter
-import org.lilie.services.eliot.notes.resultat.NoteInfo
-import org.lilie.services.eliot.impression.donnees.tableauimpression.cellules.CelluleI18n
-import org.lilie.services.eliot.notes.NoteTextuelle
-
-/**
- * Préparation des objets d'impression pour les tableaux de notes
- * @author othe
- */
-class ImpressionTdnService {
-
- static final NoteFormateur NF_PAR_DEFAUT = new NoteFormateur()
- static final NoteFormateur COEFF_NF = new NoteFormateur(new BigDecimal('0.01'), ',', '#.##')
-
- LocalPersonneService localPersonneService
- NotesTypePeriodeService notesTypePeriodeService
- CalculationService calculationService
-
- /**
- * Prépare les données pour un tableau de note sur une année
- * @param securiteSession
- * @param tdn
- * @return
- */
- public TableauDeNotesImpression prepareDonneesAnnee(SecuriteSession securiteSession, TableauDeNotes tdn) {
-
- StructureEnseignement structureEnseignement =
- tdn.enseignement.service.structureEnseignement
-
- NoteFormateur nf = structureEnseignement.etablissement.getNoteFormateur()
-
- TableauDeNotesImpression tab = new TableauDeNotesImpression(
- classe: structureEnseignement.code,
- etablissement: structureEnseignement.etablissement.nomAffichage,
- enseignant: localPersonneService.findPersonneByAutorite(
- tdn.enseignement.enseignant
- ).nomAffichageInitiales(),
- matiere: tdn.enseignement.service?.matiere?.libelleCourt
- )
-
- construitTableauPeriodeAnnee(
- securiteSession,
- tdn,
- tab,
- nf
- )
-
- tab.appreciationGenerale = tdn.allAppreciationClasseEnseignementPeriode ?
- tdn.allAppreciationClasseEnseignementPeriode.first().appreciation : ""
-
- return tab
-
- }
-
- /**
- * Prépare un tableau de donnée pour une période
- * @param securiteSession
- * @param tdn
- * @return
- */
- public TableauDeNotesImpression prepareDonneesAutrePeriode(SecuriteSession securiteSession, TableauDeNotes tdn) {
-
- StructureEnseignement structureEnseignement =
- tdn.enseignement.service.structureEnseignement
-
- NoteFormateur nf = structureEnseignement.etablissement.getNoteFormateur()
-
- TableauDeNotesImpression tab = new TableauDeNotesImpression(
- classe: structureEnseignement.code,
- etablissement: structureEnseignement.etablissement.nomAffichage,
- enseignant: localPersonneService.findPersonneByAutorite(
- tdn.enseignement.enseignant
- ).nomAffichageInitiales(),
- matiere: tdn.enseignement.service?.matiere?.libelleCourt
- )
-
- construitTableauAutrePeriode(
- tdn,
- tab,
- nf
- )
-
- tab.appreciationGenerale = tdn.allAppreciationClasseEnseignementPeriode ?
- tdn.allAppreciationClasseEnseignementPeriode.first().appreciation : ""
-
- return tab
-
- }
-
-
- private void construitTableauAutrePeriode(TableauDeNotes tdn, TableauDeNotesImpression tab, NoteFormateur nf) {
-
- tdn.evaluations.sort()
-
- List<SousService> sousServices =
- tdn.enseignement.service.getSousServices(tdn.typePeriode)
-
- CalculMoyenneEvaluation listeMoyennes = new CalculMoyenneEvaluation(
- tdn,
- calculationService
- )
-
- // Création des lignes du TDN
- tdn.lignes.each {TableauDeNotesLigne ligneTDN ->
- long indexEval = 1
- tdn.evaluations.each {Evaluation evaluation ->
-
- Note note = ligneTDN.notes.find {it.evaluation.id == evaluation.id}
-
- CelluleTableau celluleTableau = new CelluleTableau(
- enteteLigne: ligneTDN.eleve.nomAffichage(),
- entete1: evaluation.titre,
- entete2: evaluation.modaliteMatiere?.libelle,
- entete3: EliotFormatter.format(evaluation.dateEvaluation),
- entete4: COEFF_NF.format(evaluation.noteMaxPossible),
- entete5: COEFF_NF.format(evaluation.coefficient),
- valeur: NF_PAR_DEFAUT.format(note?.valeur),
- finLigne: ligneTDN.appreciation,
- index: indexEval,
- pied1: nf.format(calculationService.calculeMoyenne(listeMoyennes.getNotesEvaluation(evaluation))),
- pied3: NF_PAR_DEFAUT.format(calculationService.calculeMax(listeMoyennes.getNotesEvaluation(evaluation))), // on ne formatte pas les notes
- pied2: NF_PAR_DEFAUT.format(calculationService.calculeMin(listeMoyennes.getNotesEvaluation(evaluation))) // on ne formatte pas les notes
-
- )
- tab.data << celluleTableau
- indexEval++
-
- }
-
- // Les colonnes "Moy. sous-matière"
- List<NoteInfo> moyEleveSousServices = []
-
- long index = 1
-
- sousServices.each {SousService sousService ->
-
- List<Note> notes = ligneTDN.notes.findAll {
- it.evaluation.modaliteMatiere.id == sousService.modaliteMatiere.id
- }
-
- def moySousService = calculationService.calculeMoyenneNotesPonderee(notes)
-
- CelluleI18n celluleSousMatiere = new CelluleI18n(
- enteteLigne: ligneTDN.eleve.nomAffichage(),
- entete1: 'eliot.notes.libelle.moyenneCourt',
- entete2: sousService.modaliteMatiere.code,
- entete3: '',
- entete4: COEFF_NF.format(20),
- entete5: COEFF_NF.format(sousService.coeff),
- valeur: nf.format(moySousService),
- index: 8000 + index,
- finLigne: ligneTDN.appreciation,
- pied1: nf.format(calculationService.calculeMoyenne(listeMoyennes.getNotesSousService(sousService))),
- pied3: nf.format(calculationService.calculeMax(listeMoyennes.getNotesSousService(sousService))),
- pied2: nf.format(calculationService.calculeMin(listeMoyennes.getNotesSousService(sousService)))
- )
-
- index++
-
- tab.data << celluleSousMatiere
-
- moyEleveSousServices << new NoteInfo(
- (moySousService instanceof BigDecimal) ? moySousService : null,
- sousService.coeff,
- false,
- (moySousService instanceof NoteTextuelle) ? moySousService : null
- )
-
- }
-
- tab.data << construitCelluleColonneMoyenne(
- moyEleveSousServices,
- ligneTDN,
- listeMoyennes.getMoyennesEleve(),
- nf
- )
-
- }
- }
-
- /**
- * ajoute une cellule de la colonne moyenne
- * @param moyEleveSousServices : liste des moyennes de sous-services
- * @param ligneTDN : ligne élève où se trouve la cellule
- * @param moyennes : liste des moyennes
- * @param nf : objet de formatage des notes
- * @return une cellule de tableau
- */
- private CelluleI18n construitCelluleColonneMoyenne(List<NoteInfo> moyEleveSousServices,
- TableauDeNotesLigne ligneTDN,
- List<BigDecimal> moyennes,
- NoteFormateur nf) {
-
- // La colonne "Moyenne"
- def moyenne = moyEleveSousServices ?
- calculationService.calculeMoyennePonderee(moyEleveSousServices) :
- calculationService.calculeMoyenneNotesPonderee(ligneTDN.notes)
-
- CelluleI18n celluleMoyenne = new CelluleI18n(
- enteteLigne: ligneTDN.eleve.nomAffichage(),
- entete1: 'eliot.notes.libelle.moyenneCourt',
- entete2: '',
- entete3: '',
- entete4: '',
- entete5: '',
- index: 9999,
- valeur: nf.format(moyenne),
- finLigne: ligneTDN.appreciation,
- pied1: nf.format(calculationService.calculeMoyenne(moyennes)),
- pied3: nf.format(calculationService.calculeMax(moyennes)),
- pied2: nf.format(calculationService.calculeMin(moyennes))
-
- )
-
- return celluleMoyenne
- }
-
-
- private ResultatEleveEnseignementPeriode findResultatElevePeriode(TableauDeNotesLigne ligneTDN, TypePeriode typePeriode) {
-
- return ligneTDN.resultats.find {
- it.periode.typePeriode.id == typePeriode.id ||
- it.periode.typePeriode.intervalle.getIntevalleEquivalent() == typePeriode.intervalle
- }
-
- }
-
- /**
- * Construction du contenu du tableau de note si la période choisit est année
- * @param securiteSession
- * @param tdn
- * @param tab
- * @param nf
- */
- private void construitTableauPeriodeAnnee(SecuriteSession securiteSession, TableauDeNotes tdn, TableauDeNotesImpression tab, NoteFormateur nf) {
-
- List<TypePeriode> typePeriodeXmestres =
- notesTypePeriodeService.findAllXmestreForService(
- securiteSession,
- tdn.enseignement.service,
- TypeIntervalleEnum.TRIMESTRE
- )
-
- CalculMoyennePeriode moyenneParPeriode = new CalculMoyennePeriode(
- typePeriodeXmestres,
- tdn
- )
-
- // Création des lignes du TDN
- tdn.lignes.each {TableauDeNotesLigne ligneTDN ->
-
- // Colonnes "Xmestre"
- long index = 1
-
- typePeriodeXmestres.each {TypePeriode typePeriode ->
-
- ResultatEleveEnseignementPeriode resultatXmestre = findResultatElevePeriode(ligneTDN, typePeriode)
-
- // Les moyennes de tous les élèves pour le type de période Xmestre et
- // un type équivalent
- List<BigDecimal> moyenneXmestres = moyenneParPeriode.get(typePeriode)
-
- CelluleTypePeriode celluleTableau = new CelluleTypePeriode(
- typePeriode: typePeriode,
- enteteLigne: ligneTDN.eleve.nomAffichage(),
- valeur: nf.format(resultatXmestre?.getValeurAffichage()),
- index: index,
- finLigne: ligneTDN.appreciation,
- entete4: COEFF_NF.format(20),
- entete5: COEFF_NF.format(1),
- pied1: nf.format(calculationService.calculeMoyenne(moyenneXmestres)),
- pied2: nf.format(calculationService.calculeMin(moyenneXmestres)),
- pied3: nf.format(calculationService.calculeMax(moyenneXmestres))
-
- )
- index++
-
- tab.data << celluleTableau
- }
- // Les moyenne de tous les élèves pour l'année
- List<BigDecimal> moyenneAnnees = moyenneParPeriode.get(tdn.typePeriode)
-
- CelluleTableau celluleMoyenne = new CelluleTableau(
- entete1: "Moy.",
- enteteLigne: ligneTDN.eleve.nomAffichage(),
- valeur: nf.format(ligneTDN.resultat?.getValeurAffichage()),
- index: 9999,
- finLigne: ligneTDN.appreciation,
- entete4: COEFF_NF.format(20),
- entete5: COEFF_NF.format(1),
- pied1: nf.format(calculationService.calculeMoyenne(moyenneAnnees, true)),
- pied2: nf.format(calculationService.calculeMin(moyenneAnnees)),
- pied3: nf.format(calculationService.calculeMax(moyenneAnnees)),
-
- )
-
- tab.data << celluleMoyenne
- }
-
- }
-
-
-}