2020-09-26 16:19:37 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2023-12-31 23:04:06 +01:00
|
|
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program 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
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Gestion des ensembles de semestres:
|
|
|
|
|
|
|
|
class SemSet: un ensemble de semestres d'un département, à exporter ves Apogée. En principe de la meme annee scolaire.
|
2023-12-31 23:04:06 +01:00
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
SemSet.annees_scolaires() : les annees scolaires. e.g. [ 2015, 2016 ], ou le plus souvent, une seule: [2016]
|
|
|
|
SemSet.list_etapes(): listes des étapes apogee et vdi des semestres (instances de ApoEtapeVDI)
|
|
|
|
|
|
|
|
SemSet.add(sem): ajoute un semestre à l'ensemble
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
sem_set_list()
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
2021-08-01 10:16:16 +02:00
|
|
|
import flask
|
2024-08-24 14:39:19 +02:00
|
|
|
from flask import g, render_template, url_for
|
2021-08-01 10:16:16 +02:00
|
|
|
|
2023-07-11 06:57:38 +02:00
|
|
|
from app import db, log
|
2022-02-13 23:53:11 +01:00
|
|
|
from app.comp import res_sem
|
2022-03-27 22:25:00 +02:00
|
|
|
from app.comp.res_compat import NotesTableCompat
|
2022-02-13 23:53:11 +01:00
|
|
|
from app.models import FormSemestre
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_etape_apogee
|
|
|
|
from app.scodoc import sco_formsemestre
|
|
|
|
from app.scodoc import sco_formsemestre_status
|
|
|
|
from app.scodoc import sco_preferences
|
|
|
|
from app.scodoc.gen_tables import GenTable
|
|
|
|
from app.scodoc.sco_etape_bilan import EtapeBilan
|
|
|
|
from app.scodoc.sco_exceptions import ScoValueError
|
2021-07-10 13:55:35 +02:00
|
|
|
from app.scodoc.sco_vdi import ApoEtapeVDI
|
2021-06-19 23:21:37 +02:00
|
|
|
import app.scodoc.notesdb as ndb
|
|
|
|
import app.scodoc.sco_utils as scu
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2021-02-03 22:00:41 +01:00
|
|
|
_semset_editor = ndb.EditableTable(
|
2021-08-13 00:34:58 +02:00
|
|
|
"notes_semset",
|
|
|
|
"semset_id",
|
|
|
|
("semset_id", "title", "annee_scolaire", "sem_id"),
|
|
|
|
filter_dept=True,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
semset_create = _semset_editor.create
|
|
|
|
semset_edit = _semset_editor.edit
|
|
|
|
semset_list = _semset_editor.list
|
|
|
|
semset_delete = _semset_editor.delete
|
|
|
|
|
|
|
|
|
|
|
|
class SemSet(dict):
|
2021-08-21 00:24:51 +02:00
|
|
|
def __init__(self, semset_id=None, title="", annee_scolaire="", sem_id=""):
|
2021-01-01 18:40:47 +01:00
|
|
|
"""Load and init, or, if semset_id is not specified, create"""
|
2022-11-13 14:55:18 +01:00
|
|
|
super().__init__()
|
2020-09-26 16:19:37 +02:00
|
|
|
if not annee_scolaire and not semset_id:
|
|
|
|
# on autorise annee_scolaire null si sem_id pour pouvoir lire les anciens semsets
|
|
|
|
# mal construits...
|
|
|
|
raise ScoValueError("Année scolaire invalide !")
|
|
|
|
self.semset_id = semset_id
|
|
|
|
self["semset_id"] = semset_id
|
|
|
|
self.sems = []
|
2023-05-11 14:01:23 +02:00
|
|
|
self.formsemestres = [] # modernisation en cours...
|
|
|
|
self.is_apc = False
|
|
|
|
self.formsemestre_ids = set()
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2020-09-26 16:19:37 +02:00
|
|
|
if semset_id: # read existing set
|
2023-04-19 11:51:58 +02:00
|
|
|
semsets = semset_list(cnx, args={"semset_id": semset_id})
|
|
|
|
if not semsets:
|
2022-03-11 13:39:08 +01:00
|
|
|
raise ScoValueError(f"Ensemble inexistant ! (semset {semset_id})")
|
2023-04-19 11:51:58 +02:00
|
|
|
self["title"] = semsets[0]["title"]
|
|
|
|
self["annee_scolaire"] = semsets[0]["annee_scolaire"]
|
|
|
|
self["sem_id"] = semsets[0]["sem_id"]
|
2021-02-03 22:00:41 +01:00
|
|
|
r = ndb.SimpleDictFetch(
|
2020-09-26 16:19:37 +02:00
|
|
|
"SELECT formsemestre_id FROM notes_semset_formsemestre WHERE semset_id = %(semset_id)s",
|
|
|
|
{"semset_id": semset_id},
|
|
|
|
)
|
|
|
|
if r:
|
|
|
|
self.formsemestre_ids = {x["formsemestre_id"] for x in r} # a set
|
|
|
|
else: # create a new empty set
|
|
|
|
self.semset_id = semset_create(
|
|
|
|
cnx,
|
|
|
|
{"title": title, "annee_scolaire": annee_scolaire, "sem_id": sem_id},
|
|
|
|
)
|
2022-11-09 12:50:10 +01:00
|
|
|
log(f"created new semset_id={self.semset_id}")
|
2020-09-26 16:19:37 +02:00
|
|
|
self.load_sems()
|
2022-11-09 12:50:10 +01:00
|
|
|
# Analyse des semestres pour construire le bilan par semestre et par étape
|
2021-08-21 00:24:51 +02:00
|
|
|
self.bilan = EtapeBilan()
|
2020-09-26 16:19:37 +02:00
|
|
|
for sem in self.sems:
|
|
|
|
self.bilan.add_sem(sem)
|
|
|
|
|
|
|
|
def delete(self):
|
|
|
|
"""delete"""
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2020-09-26 16:19:37 +02:00
|
|
|
semset_delete(cnx, self.semset_id)
|
|
|
|
|
|
|
|
def edit(self, args):
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2020-09-26 16:19:37 +02:00
|
|
|
semset_edit(cnx, args)
|
|
|
|
|
|
|
|
def load_sems(self):
|
|
|
|
"""Load formsemestres"""
|
|
|
|
self.sems = []
|
2023-05-11 14:01:23 +02:00
|
|
|
self.formsemestres = []
|
2020-09-26 16:19:37 +02:00
|
|
|
for formsemestre_id in self.formsemestre_ids:
|
2023-07-11 06:57:38 +02:00
|
|
|
formsemestre: FormSemestre = db.session.get(FormSemestre, formsemestre_id)
|
2023-05-11 14:01:23 +02:00
|
|
|
self.formsemestres.append(formsemestre)
|
|
|
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
|
|
|
self.sems.append(sem)
|
|
|
|
self["is_apc"] = formsemestre.formation.is_apc()
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if self.sems:
|
|
|
|
self["date_debut"] = min([sem["date_debut_iso"] for sem in self.sems])
|
|
|
|
self["date_fin"] = max([sem["date_fin_iso"] for sem in self.sems])
|
|
|
|
else:
|
|
|
|
self["date_debut"] = ""
|
|
|
|
self["date_fin"] = ""
|
|
|
|
|
|
|
|
self["etapes"] = self.list_etapes()
|
|
|
|
self["semtitles"] = [sem["titre_num"] for sem in self.sems]
|
|
|
|
|
|
|
|
# Construction du ou des lien(s) vers le semestre
|
2023-04-18 02:20:32 +02:00
|
|
|
self["semlinks"] = [
|
2023-06-18 09:37:13 +02:00
|
|
|
formsemestre.html_link_status() for formsemestre in self.formsemestres
|
2023-04-18 02:20:32 +02:00
|
|
|
]
|
|
|
|
|
2022-10-02 23:43:29 +02:00
|
|
|
self["semtitles_str"] = "<br>".join(self["semlinks"])
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
def fill_formsemestres(self):
|
2020-09-26 16:19:37 +02:00
|
|
|
for sem in self.sems:
|
2021-07-29 16:31:15 +02:00
|
|
|
sco_formsemestre_status.fill_formsemestre(sem)
|
2021-08-21 00:24:51 +02:00
|
|
|
ets = sco_etape_apogee.apo_get_sem_etapes(sem)
|
2020-09-26 16:19:37 +02:00
|
|
|
sem["etapes_apo_str"] = sco_formsemestre.etapes_apo_str(sorted(list(ets)))
|
|
|
|
|
|
|
|
def add(self, formsemestre_id):
|
2022-11-09 12:50:10 +01:00
|
|
|
"Ajoute ce semestre à l'ensemble"
|
2023-04-18 11:47:10 +02:00
|
|
|
# check for valid formsemestre_id
|
2024-10-29 19:18:36 +01:00
|
|
|
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
# check
|
|
|
|
if formsemestre_id in self.formsemestre_ids:
|
|
|
|
return # already there
|
|
|
|
if formsemestre_id not in [
|
|
|
|
sem["formsemestre_id"] for sem in self.list_possible_sems()
|
|
|
|
]:
|
|
|
|
raise ValueError(
|
2022-11-09 12:50:10 +01:00
|
|
|
f"can't add {formsemestre_id} to set {self.semset_id}: incompatible sem_id"
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
2023-05-11 14:01:23 +02:00
|
|
|
if self.formsemestre_ids and formsemestre.formation.is_apc() != self["is_apc"]:
|
|
|
|
raise ScoValueError(
|
|
|
|
"""On ne peut pas mélanger des semestres BUT/APC
|
|
|
|
avec des semestres ordinaires dans le même export.""",
|
|
|
|
dest_url=url_for(
|
|
|
|
"notes.apo_semset_maq_status",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
semset_id=self.semset_id,
|
|
|
|
),
|
|
|
|
)
|
2023-04-18 11:47:10 +02:00
|
|
|
|
2021-02-03 22:00:41 +01:00
|
|
|
ndb.SimpleQuery(
|
2022-11-09 12:50:10 +01:00
|
|
|
"""INSERT INTO notes_semset_formsemestre
|
|
|
|
(formsemestre_id, semset_id)
|
2021-09-08 23:10:28 +02:00
|
|
|
VALUES (%(formsemestre_id)s, %(semset_id)s)
|
2021-08-13 00:34:58 +02:00
|
|
|
""",
|
|
|
|
{
|
|
|
|
"formsemestre_id": formsemestre_id,
|
|
|
|
"semset_id": self.semset_id,
|
|
|
|
},
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
self.load_sems() # update our list
|
|
|
|
|
|
|
|
def remove(self, formsemestre_id):
|
2021-02-03 22:00:41 +01:00
|
|
|
ndb.SimpleQuery(
|
2021-08-13 00:34:58 +02:00
|
|
|
"""DELETE FROM notes_semset_formsemestre
|
2023-12-31 23:04:06 +01:00
|
|
|
WHERE semset_id=%(semset_id)s
|
2021-08-13 00:34:58 +02:00
|
|
|
AND formsemestre_id=%(formsemestre_id)s
|
|
|
|
""",
|
2020-09-26 16:19:37 +02:00
|
|
|
{"formsemestre_id": formsemestre_id, "semset_id": self.semset_id},
|
|
|
|
)
|
|
|
|
self.load_sems() # update our list
|
|
|
|
|
|
|
|
def annees_scolaires(self):
|
|
|
|
"""Les annees scolaires. e.g. [ 2015, 2016 ], ou le plus souvent, une seule: [2016]
|
|
|
|
L'année scolaire est l'année de début du semestre (2015 pour 2015-2016)
|
|
|
|
"""
|
|
|
|
annees = list(set([int(s["annee_debut"]) for s in self.sems]))
|
|
|
|
annees.sort()
|
|
|
|
return annees
|
|
|
|
|
|
|
|
def list_etapes(self):
|
|
|
|
"""Listes triée des étapes Apogée des semestres (instances de ApoEtapeVDI).
|
|
|
|
Chaque étape apparait une seule fois, dans sa forme la plus générale.
|
|
|
|
Si on a [ 'V1RT', 'V1RT!111' ], le résultat sera [ 'V1RT' ]
|
|
|
|
Si on a [ 'V1RT!111', 'V1RT!112' ], le résultat sera [ 'V1RT!111', 'V1RT!112' ]
|
|
|
|
"""
|
|
|
|
D = {} # { etape : { versions vdi } }
|
|
|
|
for s in self.sems:
|
|
|
|
for et in s["etapes"]:
|
|
|
|
if et:
|
|
|
|
if et.etape in D:
|
|
|
|
D[et.etape].add(et.vdi)
|
|
|
|
else:
|
|
|
|
D[et.etape] = {et.vdi}
|
|
|
|
# enlève les versions excédentaires:
|
|
|
|
for etape in D:
|
|
|
|
if "" in D[etape]:
|
|
|
|
D[etape] = [""]
|
|
|
|
# forme liste triée d'instances:
|
|
|
|
etapes = []
|
|
|
|
for etape in D:
|
|
|
|
for vdi in D[etape]:
|
|
|
|
etapes.append(ApoEtapeVDI(etape=etape, vdi=vdi))
|
|
|
|
etapes.sort()
|
|
|
|
return etapes
|
|
|
|
|
|
|
|
def list_possible_sems(self):
|
2021-01-01 18:40:47 +01:00
|
|
|
"""List sems that can be added to this set"""
|
2021-08-21 00:24:51 +02:00
|
|
|
sems = sco_formsemestre.do_formsemestre_list()
|
2020-09-26 16:19:37 +02:00
|
|
|
# remove sems already here:
|
|
|
|
sems = [
|
|
|
|
sem for sem in sems if sem["formsemestre_id"] not in self.formsemestre_ids
|
|
|
|
]
|
|
|
|
# filter annee, sem_id:
|
|
|
|
# Remplacement du filtre de proposition des semestres potentiels
|
|
|
|
# au lieu de la parité (sem 1 et 3 / sem 2 et 4) on filtre sur la date de
|
|
|
|
# debut du semestre: ceci permet d'ajouter les semestres décalés
|
|
|
|
if self["annee_scolaire"]:
|
|
|
|
sems = [
|
|
|
|
sem
|
|
|
|
for sem in sems
|
|
|
|
if sco_formsemestre.sem_in_semestre_scolaire(
|
|
|
|
sem,
|
|
|
|
year=self["annee_scolaire"],
|
2022-11-09 19:25:27 +01:00
|
|
|
# Indiquer ici les valeur des dates pivots année et période
|
|
|
|
periode=self["sem_id"],
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
]
|
|
|
|
return sems
|
|
|
|
|
|
|
|
def load_etuds(self):
|
|
|
|
self["etuds_without_nip"] = set() # etudids
|
|
|
|
self["jury_ok"] = True
|
2023-04-18 11:47:10 +02:00
|
|
|
self["jury_nb_missing"] = 0
|
|
|
|
is_apc = None
|
2020-09-26 16:19:37 +02:00
|
|
|
for sem in self.sems:
|
2024-10-29 19:18:36 +01:00
|
|
|
formsemestre = FormSemestre.get_or_404(sem["formsemestre_id"])
|
2022-02-13 23:53:11 +01:00
|
|
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
2023-04-18 11:47:10 +02:00
|
|
|
if is_apc is not None and is_apc != nt.is_apc:
|
|
|
|
raise ScoValueError(
|
|
|
|
"Incohérence: semestre APC (BUT) et ordinaires mélangés !"
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
is_apc = nt.is_apc
|
2021-07-09 17:47:06 +02:00
|
|
|
sem["etuds"] = list(nt.identdict.values())
|
2020-09-26 16:19:37 +02:00
|
|
|
sem["nips"] = {e["code_nip"] for e in sem["etuds"] if e["code_nip"]}
|
|
|
|
sem["etuds_without_nip"] = {
|
|
|
|
e["etudid"] for e in sem["etuds"] if not e["code_nip"]
|
|
|
|
}
|
|
|
|
self["etuds_without_nip"] |= sem["etuds_without_nip"]
|
2023-04-18 11:47:10 +02:00
|
|
|
sem["etudids_no_jury"] = nt.etudids_without_decisions()
|
|
|
|
sem["jury_ok"] = not sem["etudids_no_jury"]
|
2020-09-26 16:19:37 +02:00
|
|
|
self["jury_ok"] &= sem["jury_ok"]
|
2023-04-18 11:47:10 +02:00
|
|
|
self["jury_nb_missing"] += len(sem["etudids_no_jury"])
|
|
|
|
self["is_apc"] = bool(is_apc)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
def html_descr(self):
|
2021-01-01 18:40:47 +01:00
|
|
|
"""Short HTML description"""
|
2020-09-26 16:19:37 +02:00
|
|
|
H = [
|
|
|
|
"""<span class="box_title">Ensemble de semestres %(title)s</span>""" % self
|
|
|
|
]
|
|
|
|
if self["annee_scolaire"]:
|
|
|
|
H.append("<p>Année scolaire: %(annee_scolaire)s</p>" % self)
|
|
|
|
else:
|
|
|
|
H.append(
|
|
|
|
"<p>Année(s) scolaire(s) présentes: %s"
|
|
|
|
% ", ".join([str(x) for x in self.annees_scolaires()])
|
|
|
|
)
|
|
|
|
if len(self.annees_scolaires()) > 1:
|
|
|
|
H.append(
|
|
|
|
' <span class="redboldtext">(attention, plusieurs années !)</span>'
|
|
|
|
)
|
|
|
|
H.append("</p>")
|
2023-04-16 05:32:21 +02:00
|
|
|
|
2023-04-18 11:47:10 +02:00
|
|
|
if self["sem_id"] == 1:
|
2023-09-10 19:40:18 +02:00
|
|
|
periode = "1re période (S1, S3, S5)"
|
2023-04-19 11:51:58 +02:00
|
|
|
elif self["sem_id"] == 2:
|
2023-09-10 19:40:18 +02:00
|
|
|
periode = "2de période (S2, S4, S6)"
|
2023-04-18 11:47:10 +02:00
|
|
|
else:
|
|
|
|
periode = "non semestrialisée (LP, ...). Incompatible avec BUT."
|
2023-04-16 05:32:21 +02:00
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append(
|
2023-04-18 11:47:10 +02:00
|
|
|
f"""
|
|
|
|
<p>Période: <b>{periode}</b></p>
|
|
|
|
<p>Etapes: <tt>{sco_formsemestre.etapes_apo_str(self.list_etapes())}</tt></p>
|
|
|
|
|
|
|
|
<h4>Semestres de l'ensemble:</h4><ul class="semset_listsems">
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
for sem in self.sems:
|
|
|
|
H.append(
|
2023-04-16 05:32:21 +02:00
|
|
|
"""<li><a class="stdlink" href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titre_num)s</a> %(mois_debut)s - %(mois_fin)s"""
|
2020-09-26 16:19:37 +02:00
|
|
|
% sem
|
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
' <a class="stdlink" href="do_semset_remove_sem?semset_id=%s&formsemestre_id=%s">(retirer)</a>'
|
|
|
|
% (self["semset_id"], sem["formsemestre_id"])
|
|
|
|
)
|
|
|
|
H.append(
|
2022-10-02 23:43:29 +02:00
|
|
|
"<br>Etapes: <tt>%(etapes_apo_str)s</tt>, %(nbinscrits)s inscrits" % sem
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2022-10-02 23:43:29 +02:00
|
|
|
H.append("<br>Elément Apogée année: ")
|
2020-09-26 16:19:37 +02:00
|
|
|
if sem["elt_annee_apo"]:
|
|
|
|
H.append("<tt>%(elt_annee_apo)s</tt>" % sem)
|
|
|
|
else:
|
|
|
|
H.append('<span style="color: red;">manquant</span>')
|
|
|
|
|
2022-10-02 23:43:29 +02:00
|
|
|
H.append("<br>Elément Apogée semestre: ")
|
2020-09-26 16:19:37 +02:00
|
|
|
if sem["elt_sem_apo"]:
|
|
|
|
H.append("<tt>%(elt_sem_apo)s</tt>" % sem)
|
|
|
|
else:
|
|
|
|
H.append('<span style="color: red;">manquant</span>')
|
|
|
|
|
|
|
|
H.append("</br><em>vérifier les semestres antécédents !</em>")
|
|
|
|
H.append("</li>")
|
|
|
|
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
def html_form_sems(self):
|
|
|
|
"""HTML form to manage sems"""
|
|
|
|
H = []
|
|
|
|
possible_sems = self.list_possible_sems()
|
|
|
|
if possible_sems:
|
|
|
|
menu_sem = """<select name="formsemestre_id">
|
|
|
|
<option value="" selected>(semestre)</option>"""
|
|
|
|
for sem in possible_sems:
|
|
|
|
menu_sem += (
|
|
|
|
"""<option value="%(formsemestre_id)s">%(titreannee)s</option>\n"""
|
|
|
|
% sem
|
|
|
|
)
|
|
|
|
menu_sem += """</select>"""
|
|
|
|
H.append(
|
|
|
|
'<form action="do_semset_add_sem" method="post">Ajouter un semestre:'
|
|
|
|
)
|
|
|
|
H.append(menu_sem)
|
|
|
|
H.append(
|
|
|
|
'<input type="hidden" name="semset_id" value="%s"/>' % self.semset_id
|
|
|
|
)
|
|
|
|
H.append('<input type="submit" value="Ajouter"/>')
|
|
|
|
H.append("</form>")
|
|
|
|
else:
|
|
|
|
H.append("<em>pas de semestres à ajouter</em>")
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
def html_diagnostic(self):
|
|
|
|
"""Affichage de la partie Effectifs et Liste des étudiants
|
2024-05-22 00:06:30 +02:00
|
|
|
(actif seulement si un portail est configuré)
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2024-05-22 00:06:30 +02:00
|
|
|
return self.bilan.html_diagnostic()
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def get_semsets_list():
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Liste de tous les semsets
|
|
|
|
Trié par date_debut, le plus récent d'abord
|
|
|
|
"""
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2020-09-26 16:19:37 +02:00
|
|
|
L = []
|
|
|
|
for s in semset_list(cnx):
|
2021-08-21 00:24:51 +02:00
|
|
|
L.append(SemSet(semset_id=s["semset_id"]))
|
2020-09-26 16:19:37 +02:00
|
|
|
L.sort(key=lambda s: s["date_debut"], reverse=True)
|
|
|
|
return L
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def do_semset_create(title="", annee_scolaire=None, sem_id=None):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Create new setset"""
|
|
|
|
log(
|
|
|
|
"do_semset_create(title=%s, annee_scolaire=%s, sem_id=%s)"
|
|
|
|
% (title, annee_scolaire, sem_id)
|
|
|
|
)
|
2021-08-21 00:24:51 +02:00
|
|
|
SemSet(title=title, annee_scolaire=annee_scolaire, sem_id=sem_id)
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect("semset_page")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def do_semset_delete(semset_id, dialog_confirmed=False):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Delete a semset"""
|
|
|
|
if not semset_id:
|
|
|
|
raise ScoValueError("empty semset_id")
|
2021-08-21 00:24:51 +02:00
|
|
|
s = SemSet(semset_id=semset_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
if not dialog_confirmed:
|
2021-06-02 22:40:34 +02:00
|
|
|
return scu.confirm_dialog(
|
2024-08-24 14:39:19 +02:00
|
|
|
f"<h2>Suppression de l'ensemble {s['title']} ?</h2>",
|
2020-09-26 16:19:37 +02:00
|
|
|
dest_url="",
|
|
|
|
parameters={"semset_id": semset_id},
|
|
|
|
cancel_url="semset_page",
|
|
|
|
)
|
|
|
|
s.delete()
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect("semset_page")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2024-08-24 14:39:19 +02:00
|
|
|
def edit_semset_set_title(oid=None, value=None):
|
2021-01-01 18:40:47 +01:00
|
|
|
"""Change title of semset"""
|
2020-09-26 16:19:37 +02:00
|
|
|
title = value.strip()
|
2024-08-24 14:39:19 +02:00
|
|
|
if not oid:
|
2020-09-26 16:19:37 +02:00
|
|
|
raise ScoValueError("empty semset_id")
|
2024-08-24 14:39:19 +02:00
|
|
|
SemSet(semset_id=oid)
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2024-08-24 14:39:19 +02:00
|
|
|
semset_edit(cnx, {"semset_id": oid, "title": title})
|
2020-09-26 16:19:37 +02:00
|
|
|
return title
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def do_semset_add_sem(semset_id, formsemestre_id):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Add a sem to a semset"""
|
|
|
|
if not semset_id:
|
|
|
|
raise ScoValueError("empty semset_id")
|
2022-01-07 17:58:34 +01:00
|
|
|
if formsemestre_id == "":
|
|
|
|
raise ScoValueError("pas de semestre choisi !")
|
2023-04-18 11:47:10 +02:00
|
|
|
semset = SemSet(semset_id=semset_id)
|
2023-04-19 11:51:58 +02:00
|
|
|
semset.add(formsemestre_id)
|
|
|
|
return flask.redirect(
|
|
|
|
url_for(
|
|
|
|
"notes.apo_semset_maq_status",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
semset_id=semset_id,
|
|
|
|
)
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def do_semset_remove_sem(semset_id, formsemestre_id):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Add a sem to a semset"""
|
|
|
|
if not semset_id:
|
|
|
|
raise ScoValueError("empty semset_id")
|
2021-08-21 00:24:51 +02:00
|
|
|
s = SemSet(semset_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
s.remove(formsemestre_id)
|
|
|
|
|
2021-07-31 18:01:10 +02:00
|
|
|
return flask.redirect("apo_semset_maq_status?semset_id=%s" % semset_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------
|
|
|
|
|
|
|
|
|
2023-09-21 10:20:19 +02:00
|
|
|
def semset_page(fmt="html"):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Page avec liste semsets:
|
|
|
|
Table avec : date_debut date_fin titre liste des semestres
|
|
|
|
"""
|
2021-08-21 00:24:51 +02:00
|
|
|
semsets = get_semsets_list()
|
2020-09-26 16:19:37 +02:00
|
|
|
for s in semsets:
|
2021-02-04 20:02:44 +01:00
|
|
|
s["suppress"] = scu.icontag(
|
2020-09-26 16:19:37 +02:00
|
|
|
"delete_small_img", border="0", alt="supprimer", title="Supprimer"
|
|
|
|
)
|
|
|
|
s["_suppress_target"] = "do_semset_delete?semset_id=%s" % (s["semset_id"])
|
|
|
|
s["export_link"] = "Export Apogée"
|
|
|
|
s["_export_link_target"] = "apo_semset_maq_status?semset_id=%s" % s.semset_id
|
|
|
|
s["_export_link_link_class"] = "stdlink"
|
|
|
|
# Le lien associé au nom de semestre redirigeait vers le semset
|
|
|
|
# (remplacé par n liens vers chacun des semestres)
|
|
|
|
# s['_semtitles_str_target'] = s['_export_link_target']
|
|
|
|
# Experimental:
|
2024-05-22 00:06:30 +02:00
|
|
|
s["_title_td_attrs"] = (
|
|
|
|
'class="inplace_edit" data-url="edit_semset_set_title" id="%s"'
|
|
|
|
% (s["semset_id"])
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
tab = GenTable(
|
|
|
|
rows=semsets,
|
|
|
|
titles={
|
|
|
|
"annee_scolaire": "Année scolaire",
|
|
|
|
"sem_id": "P",
|
|
|
|
"date_debut": "Début",
|
|
|
|
"date_fin": "Fin",
|
|
|
|
"title": "Titre",
|
|
|
|
"export_link": "",
|
|
|
|
"semtitles_str": "semestres",
|
|
|
|
},
|
|
|
|
columns_ids=[
|
|
|
|
"suppress",
|
|
|
|
"annee_scolaire",
|
|
|
|
"sem_id",
|
|
|
|
"date_debut",
|
|
|
|
"date_fin",
|
|
|
|
"title",
|
|
|
|
"export_link",
|
|
|
|
"semtitles_str",
|
|
|
|
],
|
|
|
|
html_sortable=True,
|
|
|
|
html_class="table_leftalign",
|
|
|
|
filename="semsets",
|
2021-07-28 17:03:54 +02:00
|
|
|
preferences=sco_preferences.SemPreferences(),
|
2024-05-22 00:06:30 +02:00
|
|
|
table_id="table-semsets",
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2023-09-21 10:20:19 +02:00
|
|
|
if fmt != "html":
|
|
|
|
return tab.make_page(fmt=fmt)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
page_title = "Ensembles de semestres"
|
|
|
|
H = [
|
|
|
|
"""<script>$(function() {
|
|
|
|
$('.inplace_edit').jinplace();
|
|
|
|
});
|
|
|
|
</script>""",
|
2024-08-24 14:39:19 +02:00
|
|
|
f"<h2>{page_title}</h2>",
|
2020-09-26 16:19:37 +02:00
|
|
|
]
|
|
|
|
H.append(tab.html())
|
|
|
|
|
2022-11-13 14:55:18 +01:00
|
|
|
annee_courante = int(scu.annee_scolaire())
|
2020-09-26 16:19:37 +02:00
|
|
|
menu_annee = "\n".join(
|
|
|
|
[
|
2024-08-24 14:39:19 +02:00
|
|
|
f"""<option value="{i}">{i}</option>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
for i in range(2014, annee_courante + 1)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
H.append(
|
|
|
|
"""
|
|
|
|
<div style="margin-top:20px;">
|
|
|
|
<h4>Création nouvel ensemble</h4>
|
|
|
|
<form method="POST" action="do_semset_create">
|
|
|
|
<select name="annee_scolaire">
|
|
|
|
<option value="" selected>(année scolaire)</option>"""
|
|
|
|
)
|
|
|
|
H.append(menu_annee)
|
|
|
|
H.append(
|
|
|
|
"""</select>
|
|
|
|
<select name="sem_id">
|
|
|
|
<option value="1">1re période (S1, S3)</option>
|
|
|
|
<option value="2">2de période (S2, S4)</option>
|
2023-04-18 11:47:10 +02:00
|
|
|
<option value="0">non semestrialisée (LP, ... mais pas pour le BUT !)</option>
|
2020-09-26 16:19:37 +02:00
|
|
|
</select>
|
|
|
|
<input type="text" name="title" size="32"/>
|
|
|
|
<input type="submit" value="Créer"/>
|
|
|
|
</form></div>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
H.append(
|
|
|
|
"""
|
2024-08-24 14:39:19 +02:00
|
|
|
<div class="scobox space-before-24">
|
|
|
|
<div class="scobox-title">Autres opérations :</div>
|
2020-09-26 16:19:37 +02:00
|
|
|
<ul>
|
|
|
|
<li><a class="stdlink" href="scodoc_table_results">
|
|
|
|
Table des résultats de tous les semestres
|
|
|
|
</a></li>
|
|
|
|
<li><a class="stdlink" href="apo_compare_csv_form">
|
|
|
|
Comparaison de deux maquettes Apogée
|
|
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
2024-08-24 14:39:19 +02:00
|
|
|
return render_template(
|
|
|
|
"sco_page_dept.j2",
|
|
|
|
title=page_title,
|
|
|
|
javascripts=["libjs/jinplace-1.2.1.min.js"],
|
|
|
|
content="\n".join(H),
|
|
|
|
)
|