+++ /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.domaine
-
-import grails.converters.JSON
-import org.lilie.services.eliot.scolarite.StructureEnseignement
-import org.lilie.services.eliot.notes.scolarite.NotesStructureEnseignementService
-import org.lilie.services.eliot.notes.AbstractNotesController
-import org.lilie.services.eliot.notes.ActionEnum
-import org.lilie.services.eliot.notes.NotesDroitService
-import org.lilie.services.eliot.scolarite.PeriodeService
-import org.lilie.services.eliot.scolarite.TypePeriode
-import org.lilie.services.eliot.notes.NotesFonction
-
-/**
- * La classe contient toutes les actions communes qui concernent à
- * structure enseignement.
- * @author ywan
- * @author bper
- */
-class StructureEnseignementController extends AbstractNotesController {
-
- NotesDroitService notesDroitService
- NotesStructureEnseignementService notesStructureEnseignementService
- PeriodeService periodeService
-
- /**
- * Retourne la liste des classe auxquelles l'utilisateur a l'accès
- */
- def listeClasses = {
- Map result = tryCatch {
- notesDroitService.verifieAutorisationByEtablissement(
- securiteSession,
- etablissementCourant(),
- ActionEnum.CONSULTATION,
- (List) (NotesFonction.ENSEIGNANT_ASSIMILE +
- NotesFonction.DIRECTION_ASSIMILE
- )
- )
-
- List<StructureEnseignement> classes = notesStructureEnseignementService.
- findAllClasseForUtilisateur(
- securiteSession,
- etablissementCourant(),
- ActionEnum.CONSULTATION)
-
- // crée les périodes si pas encore crées. Il nous faut typeIntervalle pour
- // l'affichage
- classes.each { StructureEnseignement classe ->
- if (classe.typeIntervalle == null) {
- periodeService.creePeriodesNotationPourStructureEnseignement(classe)
- }
- }
-
- classes.sort {a, b -> cc.compare(a.code, b.code)}
-
- return [listeStructureEnseignements: classes.collect {
- [
- id: it.id,
- code: it.code,
- typeIntervalle: it.typeIntervalle]
- }]
- }
-
- render result as JSON
- }
-
- /**
- * Retourne la liste des Maps contenant les id et les codes d'une classe
- * et de tous ses groupes
- * @return liste de classes/groupes au format JSON contient ['id','code']
- * @author bper
- */
- def listeClasseEtSesGroupes = {
- Map result = getResultIfNullParams(['idClasse'])
- if (!result) {
- result = tryCatch {
- notesDroitService.verifieAutorisationByEtablissement(
- securiteSession,
- etablissementCourant(),
- ActionEnum.CONSULTATION,
- NotesFonction.DIRECTION_ASSIMILE
- )
-
- Long idClasse = Long.valueOf(params.idClasse)
- List<StructureEnseignement> structureEnseignements =
- notesStructureEnseignementService.findAllGroupeByClasse(
- StructureEnseignement.get(idClasse),
- [sort: "code", order: "asc"]
- )
- structureEnseignements.add(0, StructureEnseignement.get(idClasse))
-
- structureEnseignements.sort {a, b -> cc.compare(a.code, b.code)}
-
- [listeStructureEnseignements:
- structureEnseignements.collect {[id: it.id, code: it.code]}]
- }
- }
-
- render result as JSON
- }
-
- /**
- * Liste des classes sur lesquelles ont peut applique le paramétrage
- * @param classeId
- * @author bper
- */
- def listeClassesReportParametrage = {
- Map result = tryCatch {
- notesDroitService.verifieAutorisationByEtablissement(
- securiteSession,
- etablissementCourant(),
- ActionEnum.CONSULTATION,
- NotesFonction.DIRECTION_ASSIMILE
- )
-
- Long classeId = Long.valueOf(params.classeId)
- StructureEnseignement classeSource = StructureEnseignement.get(classeId)
- List<StructureEnseignement> classes = notesStructureEnseignementService.
- findAllClasseReportParamApplicable(securiteSession, classeSource)
-
- classes.sort {a, b -> cc.compare(a.code, b.code)}
-
- [classes: classes]
- }
-
- render result as JSON
- }
-
- def listeClassesParTypePeriode = {
- Map result = tryCatch {
- notesDroitService.verifieAutorisationByEtablissement(
- securiteSession,
- etablissementCourant(),
- ActionEnum.CONSULTATION,
- NotesFonction.DIRECTION_ASSIMILE
- )
-
- String typePeriodeIdStr = params.periodeId // en réalité c'est typePeriodeId, pas periodeId
- if (typePeriodeIdStr == null) {
- throw new IllegalArgumentException('periodeId est null')
- }
-
- Long typePeriodeId = Long.valueOf(typePeriodeIdStr)
- TypePeriode typePeriode = TypePeriode.get(typePeriodeId)
-
- List<StructureEnseignement> classes =
- notesStructureEnseignementService.internalFindAllClasse(typePeriode, etablissementCourant())
-
- classes.sort {a, b -> cc.compare(a.code, b.code)}
-
- List classesList = classes.collect {
- [id: it.id, libelle: it.code]
- }
-
- return [classes: classesList]
- }
-
- render result as JSON
- }
-
-}