--- /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.resultat.synthese
+
+import org.lilie.services.eliot.scolarite.Periode
+import org.lilie.services.eliot.annuaire.SecuriteSession
+import org.lilie.services.eliot.scolarite.StructureEnseignement
+import org.lilie.services.eliot.notes.NotesDroitService
+import org.lilie.services.eliot.notes.ActionEnum
+import org.lilie.services.eliot.scolarite.Service
+import org.lilie.services.eliot.notes.scolarite.NotesServiceService
+import org.lilie.services.eliot.notes.NotesFonction
+import org.lilie.services.eliot.notes.resultat.synthese.Synthese
+import org.lilie.services.eliot.notes.resultat.synthese.SyntheseClasse
+import org.lilie.services.eliot.notes.resultat.synthese.SyntheseClasseService
+import org.lilie.services.eliot.notes.resultat.synthese.SyntheseEleve
+import org.lilie.services.eliot.notes.resultat.synthese.SyntheseEleveService
+import org.lilie.services.eliot.notes.resultat.MoyenneService
+import org.lilie.services.eliot.notes.resultat.CalcMoyennesInfo
+
+/**
+ * @author bper
+ */
+class SyntheseService {
+
+ NotesDroitService notesDroitService
+ NotesServiceService notesServiceService
+ MoyenneService moyenneService
+ SyntheseEleveService syntheseEleveService
+ SyntheseClasseService syntheseClasseService
+
+ static transactional = true
+
+ /**
+ * Contruit la synthese d'une classe pour une période.
+ * @author bper
+ */
+ Synthese construisSynthese(SecuriteSession securiteSession,
+ StructureEnseignement classe,
+ Periode periode) {
+
+ notesDroitService.verifieAutorisationByClasse(
+ securiteSession,
+ classe,
+ ActionEnum.CONSULTATION,
+ (List) (NotesFonction.ENSEIGNANT_ASSIMILE +
+ NotesFonction.DIRECTION_ASSIMILE
+ )
+ )
+
+ // Les services et tous ses groupes et de regroupements
+ List<Service> services = notesServiceService.findAllServiceByClasseAndPeriodes(
+ securiteSession,
+ classe,
+ [periode],
+ true)
+
+ // Trie les services dans l'ordre defini pour la période donnée
+ notesServiceService.trieServices(services, periode)
+
+ CalcMoyennesInfo calcInfo = moyenneService.internalVerifieMoyennesAjour(classe)
+
+ // Synthèses (les moyennes et l'appréciation) des élèves
+ List<SyntheseEleve> syntheseEleves = syntheseEleveService.
+ construisAllSyntheseEleveForClasse(
+ securiteSession,
+ classe,
+ services,
+ periode)
+
+ // Synthèse de la classe
+ SyntheseClasse syntheseClasse = syntheseClasseService.
+ internalConstruisSyntheseClasse(
+ classe,
+ services,
+ periode)
+
+ Synthese synthese = new Synthese()
+ synthese.classe = classe
+ synthese.periode = periode
+ synthese.syntheseClasse = syntheseClasse
+ syntheseEleves*.synthese = synthese
+ synthese.syntheseEleves = syntheseEleves
+ synthese.moyennesAjour = calcInfo.moyennesAjour
+ synthese.dateDernierCalculMoyennes = calcInfo.dateDernierCalculMoyennes
+
+ return synthese
+ }
+}