+++ /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.saisie
-
-import org.lilie.services.eliot.notes.resultat.SyntheseClasse
-import org.lilie.services.eliot.notes.ResultatClasseSousServicePeriode
-import org.lilie.services.eliot.notes.ResultatClasseServicePeriode
-import org.lilie.services.eliot.notes.ResultatEleveSousServicePeriode
-import org.lilie.services.eliot.notes.ResultatEleveServicePeriode
-import org.lilie.services.eliot.notes.resultat.SyntheseEleve
-import org.lilie.services.eliot.scolarite.Personne
-import org.lilie.services.eliot.scolarite.Service
-import org.lilie.services.eliot.scolarite.SousService
-import grails.converters.JSON
-
-/**
- * Les configs pour la vue Saisie->Synthese
- * @author bper
- */
-class SaisieSyntheseConfig {
-
- static def getCleMoyenneService(def serviceId,def sousServiceId = null) {
- return "moyenneService_${getIdCompose(serviceId,sousServiceId)}"
- }
-
- static def getIdCompose(def serviceId,def sousServiceId = null) {
- return (sousServiceId != null) ? "s${serviceId}ss${sousServiceId}" : "s${serviceId}"
- }
-
-
- /**
- * @author bper
- */
- static void createConfig() {
- JSON.createNamedConfig(SaisieSyntheseConfig.toString()) {cfg ->
-
- // Converteur JSON pour SyntheseClasse
- cfg.registerObjectMarshaller(SyntheseClasse) {SyntheseClasse syntheseClasse ->
- return convertForSyntheseClasse(syntheseClasse)
- }
-
-
- // Converteur JSON pour SyntheseEleve
- cfg.registerObjectMarshaller(SyntheseEleve) {SyntheseEleve syntheseEleve ->
- return convertForSyntheseEleve(syntheseEleve)
- }
-
-
- // Converteur JSON pour Personne
- cfg.registerObjectMarshaller(Personne) {Personne personne ->
- return [nom: personne.nom, prenom:personne.prenom]
- }
- }
- }
-
- private static def convertForSyntheseEleve(SyntheseEleve syntheseEleve) {
-// Recherche les services de la classe qui ne consernent pas cet élève.
- // Les cellules correspondantes seront grisées dans le tableau.
- List<Service> serviceClasses = syntheseEleve.synthese?.syntheseClasse?.services ?: []
- List<Service> serviceEleves = syntheseEleve.services ?: []
- List<Service> serviceClasseNotEleves = serviceClasses.findAll {Service serviceClasse ->
- !serviceEleves.any {Service serviceEleve -> serviceEleve.id == serviceClasse.id}
- }
-
- List colonnesGrisees = []
- serviceClasseNotEleves.each {Service service ->
- colonnesGrisees << getIdCompose(service.id)
- service.sousServices.each {SousService sousService ->
- colonnesGrisees << getIdCompose(service.id, sousService.id)
- }
- }
-
- Map map = [
- personneId: syntheseEleve.eleve?.id,
- id: syntheseEleve.eleve.autorite?.id,
- nomAffichage: syntheseEleve.eleve?.nomAffichage(),
- moyenne: syntheseEleve.resultatElevePeriode?.getValeurAffichage(),
- appreciationGenerale: syntheseEleve.appreciationElevePeriode?.appreciation,
- colonnesGrisees: colonnesGrisees,
- actif: syntheseEleve?.actif,
- ]
-
- def cle = null
-
- // Les moyenne des périodes de notation
- syntheseEleve?.resultatEleveXmestres?.each {
- cle = getCleMoyenneService("periode_${it.periode.id}")
- map.put((cle), it.getValeurAffichage())
- }
-
- syntheseEleve.resultatEleveServicePeriodes.each {
- ResultatEleveServicePeriode resService ->
-
- // Moyennes des service
- cle = getCleMoyenneService(resService.service.id)
- map.put((cle), resService.getValeurAffichage())
-
- // Moyennes des sous-services
- resService.resultatsEleveSousServicePeriode.each {
- ResultatEleveSousServicePeriode resSousService ->
- cle = getCleMoyenneService(resService.service.id, resSousService.sousService.id)
- map.put((cle), resSousService.getValeurAffichage())
- }
- }
- return map
- }
-
- private static def convertForSyntheseClasse(SyntheseClasse syntheseClasse) {
-
- //TOREFACT trouver le moyen d'internationnaliser
-
- // Les moyennes générales
- Map moyenne = [
- nomAffichage: "Moyenne",
- moyenne: syntheseClasse.resultatClassePeriode?.moyenne
- ]
- Map moyenneMax = [
- nomAffichage: "Moyenne Max.",
- moyenne: syntheseClasse.resultatClassePeriode?.moyenneMax]
-
- Map moyenneMin = [
- nomAffichage: "Moyenne Min.",
- moyenne: syntheseClasse.resultatClassePeriode?.moyenneMin
- ]
-
- def cle = null
-
- // Les moyennes de Xmestres
- syntheseClasse.resultatClasseXmestres?.each {
- cle = getCleMoyenneService("periode_${it.periode.id}")
- moyenne.put((cle), it.moyenne)
- moyenneMax.put((cle), it.moyenneMax)
- moyenneMin.put((cle), it.moyenneMin)
- }
-
- syntheseClasse.resultatClasseServicePeriodes.each {ResultatClasseServicePeriode resService ->
-
- // Les moyennes des services
- cle = getCleMoyenneService(resService.service.id)
- moyenne.put((cle), resService.moyenne)
- moyenneMax.put((cle), resService.moyenneMax)
- moyenneMin.put((cle), resService.moyenneMin)
-
- resService.resultatsClasseSousServicePeriode.each {ResultatClasseSousServicePeriode resSousService ->
- // Les moyennes des sous-services
- cle = getCleMoyenneService(resService.service.id, resSousService.sousService.id)
- moyenne.put((cle), resSousService.moyenne)
- moyenneMax.put((cle), resSousService.moyenneMax)
- moyenneMin.put((cle), resSousService.moyenneMin)
- }
- }
- return [moyenne, moyenneMin, moyenneMax]
- }
-
-}