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.resultat.Moyenne
-import org.lilie.services.eliot.notes.notes.EtablissementNotesService
+import org.lilie.services.eliot.notes.notes.tableaudenotes.TableauDeNotesService
+import org.lilie.services.eliot.tableau.Tableau
+import org.lilie.services.eliot.tableau.Ligne
+import org.lilie.services.eliot.tableau.Cellule
/**
* Préparation des objets d'impression pour les tableaux de notes
*/
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
- EtablissementNotesService etablissementNotesService
-
- /**
- * 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.etablissementNotes.
- 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
-
- }
+ TableauDeNotesService tableauDeNotesService
/**
- * Prépare un tableau de donnée pour une période
- * @param securiteSession
- * @param tdn
- * @return
+ * Transforme le TableauDeNotes en TableauDeNotesImpression
+ * @author bper
*/
- public TableauDeNotesImpression prepareDonneesAutrePeriode(SecuriteSession securiteSession, TableauDeNotes tdn) {
+ public TableauDeNotesImpression transformeToTableauDeNotesImpression(SecuriteSession securiteSession,
+ TableauDeNotes tdn,
+ OptionsImpressionParams optionsImpressionParams,
+ Closure message = {code -> code}) {
StructureEnseignement structureEnseignement =
- tdn.enseignement.service.structureEnseignement
-
- NoteFormateur nf = structureEnseignement.etablissement.etablissementNotes.
- getNoteFormateur()
+ tdn.enseignement.service.structureEnseignement
TableauDeNotesImpression tab = new TableauDeNotesImpression(
classe: structureEnseignement.code,
matiere: tdn.enseignement.service?.matiere?.libelleCourt
)
- construitTableauAutrePeriode(
- tdn,
- tab,
- nf
- )
-
- tab.appreciationGenerale = tdn.allAppreciationClasseEnseignementPeriode ?
- tdn.allAppreciationClasseEnseignementPeriode.first().appreciation : ""
-
- return tab
-
- }
+ tab.appreciationGenerale = tdn.getAppreciationClasse()
-
- 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(
+ Tableau tableau = tableauDeNotesService.transformeToSimpleTableau(
+ securiteSession,
tdn,
- calculationService
+ optionsImpressionParams.notesEtMoyennes,
+ optionsImpressionParams.appreciations
)
- // Création des lignes du TDN
- tdn.lignes.each {TableauDeNotesLigne ligneTDN ->
- long indexEval = 1
- tdn.evaluations.each {Evaluation evaluation ->
+ tableau.traduisI18n(message)
- Note note = ligneTDN.notes.find {it.evaluation.id == evaluation.id}
+ Boolean isAnnee = tdn?.typePeriode?.isAnnee()
- 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),
- entete6: evaluation.typeActivite.code,
- 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
+ tableau.eachLigneWithIndex {Ligne ligne, Integer rowIndex ->
- )
- tab.data << celluleTableau
- indexEval++
+ List<Integer> allColIndex = ligne.getAllColIndex()
+ Integer colEleveIndex = allColIndex.first()
+ Integer colAppreciationIndex = optionsImpressionParams.appreciations ? allColIndex.last() : null
- }
+ ligne.eachCelluleWithIndex {Cellule cellule, Integer colIndex ->
- // Les colonnes "Moy. sous-matière"
- List<NoteInfo> moyEleveSousServices = []
+ // Eclusion des colonnes "élève" et "appréciation"
+ if (colIndex != colEleveIndex && colIndex != colAppreciationIndex) {
- long index = 1
+ CelluleTableau celluleTableau = new CelluleTableau(
+ enteteLigne: ligne.getCellule(colEleveIndex).valeur,
+ entete1: tableau.getCelluleEntete(1, colIndex).valeur,
+ entete2: !isAnnee ? tableau.getCelluleEntete(2, colIndex).valeur : '',
+ entete3: !isAnnee ? tableau.getCelluleEntete(3, colIndex).valeur : '',
+ entete4: !isAnnee ? tableau.getCelluleEntete(4, colIndex).valeur : '',
+ entete5: !isAnnee ? tableau.getCelluleEntete(5, colIndex).valeur : '',
+ entete6: !isAnnee ? tableau.getCelluleEntete(6, colIndex).valeur : '',
+ valeur: ligne.getCellule(colIndex).valeur,
+ finLigne: colAppreciationIndex ? ligne.getCellule(colAppreciationIndex).valeur : '',
+ index: colIndex,
+ pied1: tableau.getCellulePied(1, colIndex).valeur,
+ pied2: tableau.getCellulePied(2, colIndex).valeur,
+ pied3: tableau.getCellulePied(3, colIndex).valeur
+ )
- sousServices.each {SousService sousService ->
+ tab.data << celluleTableau
- List<Note> notes = ligneTDN.notes.findAll {
- it.evaluation.modaliteMatiere.id == sousService.modaliteMatiere.id
}
-
- Moyenne 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,
- sousService.coeff,
- false
- )
-
}
-
- 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"
- Moyenne 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.resultatsXmestresPrecedents.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
}
+ return tab
}
-
}