2020-09-26 16:19:37 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2023-01-02 13:16:27 +01:00
|
|
|
# Copyright (c) 1999 - 2023 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
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Form. pour inscription rapide des etudiants d'un semestre dans un autre
|
|
|
|
Utilise les autorisations d'inscription délivrées en jury.
|
|
|
|
"""
|
2021-02-04 20:02:44 +01:00
|
|
|
import datetime
|
2021-07-09 23:19:30 +02:00
|
|
|
from operator import itemgetter
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-09-18 10:10:02 +02:00
|
|
|
from flask import url_for, g, request
|
2021-07-11 17:37:12 +02:00
|
|
|
|
2021-06-19 23:21:37 +02:00
|
|
|
import app.scodoc.notesdb as ndb
|
|
|
|
import app.scodoc.sco_utils as scu
|
2023-07-11 06:57:38 +02:00
|
|
|
from app import db, log
|
2023-07-05 19:15:33 +02:00
|
|
|
from app.models import Formation, FormSemestre, GroupDescr
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc.gen_tables import GenTable
|
|
|
|
from app.scodoc import html_sco_header
|
2023-01-26 18:29:16 +01:00
|
|
|
from app.scodoc import sco_cache
|
2023-02-12 13:36:47 +01:00
|
|
|
from app.scodoc import codes_cursus
|
2023-01-26 18:29:16 +01:00
|
|
|
from app.scodoc import sco_etud
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_formsemestre
|
|
|
|
from app.scodoc import sco_formsemestre_inscriptions
|
|
|
|
from app.scodoc import sco_groups
|
2023-01-26 18:29:16 +01:00
|
|
|
from app.scodoc import sco_preferences
|
2023-02-19 15:45:27 +01:00
|
|
|
from app.scodoc import sco_pv_dict
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc.sco_exceptions import ScoValueError
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2022-01-18 22:01:30 +01:00
|
|
|
def list_authorized_etuds_by_sem(sem, delai=274, ignore_jury=False):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Liste des etudiants autorisés à s'inscrire dans sem.
|
|
|
|
delai = nb de jours max entre la date de l'autorisation et celle de debut du semestre cible.
|
2023-01-26 18:29:16 +01:00
|
|
|
ignore_jury: si vrai, considère tous les étudiants comme autorisés, même
|
2022-01-18 22:01:30 +01:00
|
|
|
s'ils n'ont pas de décision de jury.
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2021-08-21 00:24:51 +02:00
|
|
|
src_sems = list_source_sems(sem, delai=delai)
|
|
|
|
inscrits = list_inscrits(sem["formsemestre_id"])
|
2020-09-26 16:19:37 +02:00
|
|
|
r = {}
|
|
|
|
candidats = {} # etudid : etud (tous les etudiants candidats)
|
|
|
|
nb = 0 # debug
|
|
|
|
for src in src_sems:
|
2022-01-18 22:01:30 +01:00
|
|
|
if ignore_jury:
|
|
|
|
# liste de tous les inscrits au semestre (sans dems)
|
|
|
|
liste = list_inscrits(src["formsemestre_id"]).values()
|
|
|
|
else:
|
|
|
|
# liste des étudiants autorisés par le jury à s'inscrire ici
|
|
|
|
liste = list_etuds_from_sem(src, sem)
|
2020-09-26 16:19:37 +02:00
|
|
|
liste_filtree = []
|
|
|
|
for e in liste:
|
|
|
|
# Filtre ceux qui se sont déjà inscrit dans un semestre APRES le semestre src
|
|
|
|
auth_used = False # autorisation deja utilisée ?
|
2021-06-19 23:21:37 +02:00
|
|
|
etud = sco_etud.get_etud_info(etudid=e["etudid"], filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
for isem in etud["sems"]:
|
2021-02-03 22:00:41 +01:00
|
|
|
if ndb.DateDMYtoISO(isem["date_debut"]) >= ndb.DateDMYtoISO(
|
|
|
|
src["date_fin"]
|
|
|
|
):
|
2020-09-26 16:19:37 +02:00
|
|
|
auth_used = True
|
|
|
|
if not auth_used:
|
|
|
|
candidats[e["etudid"]] = etud
|
|
|
|
liste_filtree.append(e)
|
|
|
|
nb += 1
|
|
|
|
r[src["formsemestre_id"]] = {
|
|
|
|
"etuds": liste_filtree,
|
|
|
|
"infos": {
|
|
|
|
"id": src["formsemestre_id"],
|
|
|
|
"title": src["titreannee"],
|
|
|
|
"title_target": "formsemestre_status?formsemestre_id=%s"
|
|
|
|
% src["formsemestre_id"],
|
2021-09-25 10:43:06 +02:00
|
|
|
"filename": "etud_autorises",
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
# ajoute attribut inscrit qui indique si l'étudiant est déjà inscrit dans le semestre dest.
|
|
|
|
for e in r[src["formsemestre_id"]]["etuds"]:
|
2021-07-09 17:47:06 +02:00
|
|
|
e["inscrit"] = e["etudid"] in inscrits
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Ajoute liste des etudiants actuellement inscrits
|
|
|
|
for e in inscrits.values():
|
|
|
|
e["inscrit"] = True
|
|
|
|
r[sem["formsemestre_id"]] = {
|
2021-07-09 17:47:06 +02:00
|
|
|
"etuds": list(inscrits.values()),
|
2020-09-26 16:19:37 +02:00
|
|
|
"infos": {
|
|
|
|
"id": sem["formsemestre_id"],
|
|
|
|
"title": "Semestre cible: " + sem["titreannee"],
|
|
|
|
"title_target": "formsemestre_status?formsemestre_id=%s"
|
|
|
|
% sem["formsemestre_id"],
|
|
|
|
"comment": " actuellement inscrits dans ce semestre",
|
|
|
|
"help": "Ces étudiants sont actuellement inscrits dans ce semestre. Si vous les décochez, il seront désinscrits.",
|
2021-09-25 10:43:06 +02:00
|
|
|
"filename": "etud_inscrits",
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return r, inscrits, candidats
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def list_inscrits(formsemestre_id, with_dems=False):
|
2022-09-03 11:41:56 +02:00
|
|
|
"""Étudiants déjà inscrits à ce semestre
|
2020-09-26 16:19:37 +02:00
|
|
|
{ etudid : etud }
|
|
|
|
"""
|
|
|
|
if not with_dems:
|
2021-06-21 10:17:16 +02:00
|
|
|
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
|
2021-08-19 10:28:35 +02:00
|
|
|
formsemestre_id
|
2020-09-26 16:19:37 +02:00
|
|
|
) # optimized
|
|
|
|
else:
|
|
|
|
args = {"formsemestre_id": formsemestre_id}
|
2021-08-19 10:28:35 +02:00
|
|
|
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(args=args)
|
2020-09-26 16:19:37 +02:00
|
|
|
inscr = {}
|
|
|
|
for i in ins:
|
|
|
|
etudid = i["etudid"]
|
2021-06-19 23:21:37 +02:00
|
|
|
inscr[etudid] = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
return inscr
|
|
|
|
|
|
|
|
|
2022-01-18 22:01:30 +01:00
|
|
|
def list_etuds_from_sem(src, dst) -> list[dict]:
|
2020-12-02 01:00:23 +01:00
|
|
|
"""Liste des etudiants du semestre src qui sont autorisés à passer dans le semestre dst."""
|
2020-09-26 16:19:37 +02:00
|
|
|
target = dst["semestre_id"]
|
2023-02-19 15:45:27 +01:00
|
|
|
dpv = sco_pv_dict.dict_pvjury(src["formsemestre_id"])
|
2020-09-26 16:19:37 +02:00
|
|
|
if not dpv:
|
|
|
|
return []
|
|
|
|
etuds = [
|
|
|
|
x["identite"]
|
|
|
|
for x in dpv["decisions"]
|
|
|
|
if target in [a["semestre_id"] for a in x["autorisations"]]
|
|
|
|
]
|
|
|
|
return etuds
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def list_inscrits_date(sem):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Liste les etudiants inscrits dans n'importe quel semestre
|
2021-09-13 22:10:01 +02:00
|
|
|
du même département
|
2020-09-26 16:19:37 +02:00
|
|
|
SAUF sem à la date de début de sem.
|
|
|
|
"""
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-02-03 22:00:41 +01:00
|
|
|
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
|
|
|
sem["date_debut_iso"] = ndb.DateDMYtoISO(sem["date_debut"])
|
2020-09-26 16:19:37 +02:00
|
|
|
cursor.execute(
|
2021-09-15 00:54:18 +02:00
|
|
|
"""SELECT ins.etudid
|
|
|
|
FROM
|
|
|
|
notes_formsemestre_inscription ins,
|
2021-09-15 15:19:08 +02:00
|
|
|
notes_formsemestre S
|
2021-09-13 22:10:01 +02:00
|
|
|
WHERE ins.formsemestre_id = S.id
|
2021-08-21 15:17:14 +02:00
|
|
|
AND S.id != %(formsemestre_id)s
|
|
|
|
AND S.date_debut <= %(date_debut_iso)s
|
|
|
|
AND S.date_fin >= %(date_debut_iso)s
|
2021-09-15 00:54:18 +02:00
|
|
|
AND S.dept_id = %(dept_id)s
|
2021-08-21 15:17:14 +02:00
|
|
|
""",
|
2020-09-26 16:19:37 +02:00
|
|
|
sem,
|
|
|
|
)
|
|
|
|
return [x[0] for x in cursor.fetchall()]
|
|
|
|
|
|
|
|
|
2021-09-02 18:05:22 +02:00
|
|
|
def do_inscrit(sem, etudids, inscrit_groupes=False):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Inscrit ces etudiants dans ce semestre
|
|
|
|
(la liste doit avoir été vérifiée au préalable)
|
|
|
|
En option: inscrit aux mêmes groupes que dans le semestre origine
|
|
|
|
"""
|
2023-07-05 19:15:33 +02:00
|
|
|
# TODO à ré-écrire pour utiliser le smodèle, notamment GroupDescr
|
2023-07-11 06:57:38 +02:00
|
|
|
formsemestre: FormSemestre = db.session.get(FormSemestre, sem["formsemestre_id"])
|
2023-01-24 00:35:15 +01:00
|
|
|
formsemestre.setup_parcours_groups()
|
2022-09-30 22:43:39 +02:00
|
|
|
log(f"do_inscrit (inscrit_groupes={inscrit_groupes}): {etudids}")
|
2020-09-26 16:19:37 +02:00
|
|
|
for etudid in etudids:
|
|
|
|
sco_formsemestre_inscriptions.do_formsemestre_inscription_with_modules(
|
|
|
|
sem["formsemestre_id"],
|
|
|
|
etudid,
|
2022-09-30 22:43:39 +02:00
|
|
|
etat=scu.INSCRIT,
|
2020-09-26 16:19:37 +02:00
|
|
|
method="formsemestre_inscr_passage",
|
|
|
|
)
|
|
|
|
if inscrit_groupes:
|
|
|
|
# Inscription dans les mêmes groupes que ceux du semestre d'origine,
|
|
|
|
# s'ils existent.
|
|
|
|
# (mise en correspondance à partir du nom du groupe, sans tenir compte
|
|
|
|
# du nom de la partition: évidemment, cela ne marche pas si on a les
|
|
|
|
# même noms de groupes dans des partitions différentes)
|
2021-06-19 23:21:37 +02:00
|
|
|
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# recherche le semestre origine (il serait plus propre de l'avoir conservé!)
|
|
|
|
if len(etud["sems"]) < 2:
|
|
|
|
continue
|
|
|
|
prev_formsemestre = etud["sems"][1]
|
2022-03-05 12:47:08 +01:00
|
|
|
sco_groups.etud_add_group_infos(
|
|
|
|
etud,
|
|
|
|
prev_formsemestre["formsemestre_id"] if prev_formsemestre else None,
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2023-01-24 00:35:15 +01:00
|
|
|
cursem_groups_by_name = {
|
|
|
|
g["group_name"]: g
|
|
|
|
for g in sco_groups.get_sem_groups(sem["formsemestre_id"])
|
|
|
|
if g["group_name"]
|
|
|
|
}
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# forme la liste des groupes présents dans les deux semestres:
|
|
|
|
partition_groups = [] # [ partition+group ] (ds nouveau sem.)
|
|
|
|
for partition_id in etud["partitions"]:
|
|
|
|
prev_group_name = etud["partitions"][partition_id]["group_name"]
|
|
|
|
if prev_group_name in cursem_groups_by_name:
|
|
|
|
new_group = cursem_groups_by_name[prev_group_name]
|
|
|
|
partition_groups.append(new_group)
|
|
|
|
|
2023-01-24 00:35:15 +01:00
|
|
|
# Inscrit aux groupes
|
2020-09-26 16:19:37 +02:00
|
|
|
for partition_group in partition_groups:
|
2023-07-11 06:57:38 +02:00
|
|
|
group: GroupDescr = db.session.get(
|
|
|
|
GroupDescr, partition_group["group_id"]
|
|
|
|
)
|
2023-07-05 19:15:33 +02:00
|
|
|
sco_groups.change_etud_group_in_partition(etudid, group)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2021-09-02 18:05:22 +02:00
|
|
|
def do_desinscrit(sem, etudids):
|
2020-09-26 16:19:37 +02:00
|
|
|
log("do_desinscrit: %s" % etudids)
|
|
|
|
for etudid in etudids:
|
2021-06-21 10:17:16 +02:00
|
|
|
sco_formsemestre_inscriptions.do_formsemestre_desinscription(
|
2021-09-02 18:05:22 +02:00
|
|
|
etudid, sem["formsemestre_id"]
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-01-18 22:01:30 +01:00
|
|
|
def list_source_sems(sem, delai=None) -> list[dict]:
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Liste des semestres sources
|
|
|
|
sem est le semestre destination
|
|
|
|
"""
|
|
|
|
# liste des semestres débutant a moins
|
|
|
|
# de delai (en jours) de la date de fin du semestre d'origine.
|
2021-08-19 10:28:35 +02:00
|
|
|
sems = sco_formsemestre.do_formsemestre_list()
|
2020-09-26 16:19:37 +02:00
|
|
|
othersems = []
|
|
|
|
d, m, y = [int(x) for x in sem["date_debut"].split("/")]
|
|
|
|
date_debut_dst = datetime.date(y, m, d)
|
|
|
|
|
|
|
|
delais = datetime.timedelta(delai)
|
|
|
|
for s in sems:
|
|
|
|
if s["formsemestre_id"] == sem["formsemestre_id"]:
|
|
|
|
continue # saute le semestre destination
|
|
|
|
if s["date_fin"]:
|
|
|
|
d, m, y = [int(x) for x in s["date_fin"].split("/")]
|
|
|
|
date_fin = datetime.date(y, m, d)
|
|
|
|
if date_debut_dst - date_fin > delais:
|
|
|
|
continue # semestre trop ancien
|
|
|
|
if date_fin > date_debut_dst:
|
|
|
|
continue # semestre trop récent
|
|
|
|
# Elimine les semestres de formations speciales (sans parcours)
|
2023-02-12 13:36:47 +01:00
|
|
|
if s["semestre_id"] == codes_cursus.NO_SEMESTRE_ID:
|
2020-09-26 16:19:37 +02:00
|
|
|
continue
|
|
|
|
#
|
2023-02-20 21:04:29 +01:00
|
|
|
formation: Formation = Formation.query.get_or_404(s["formation_id"])
|
|
|
|
parcours = codes_cursus.get_cursus_from_code(formation.type_parcours)
|
2020-09-26 16:19:37 +02:00
|
|
|
if not parcours.ALLOW_SEM_SKIP:
|
|
|
|
if s["semestre_id"] < (sem["semestre_id"] - 1):
|
|
|
|
continue
|
|
|
|
othersems.append(s)
|
|
|
|
return othersems
|
|
|
|
|
|
|
|
|
|
|
|
def formsemestre_inscr_passage(
|
|
|
|
formsemestre_id,
|
|
|
|
etuds=[],
|
|
|
|
inscrit_groupes=False,
|
|
|
|
submitted=False,
|
|
|
|
dialog_confirmed=False,
|
2022-01-18 22:01:30 +01:00
|
|
|
ignore_jury=False,
|
2023-01-26 18:29:16 +01:00
|
|
|
) -> str:
|
|
|
|
"""Page Form. pour inscription des etudiants d'un semestre dans un autre
|
2020-09-26 16:19:37 +02:00
|
|
|
(donné par formsemestre_id).
|
|
|
|
Permet de selectionner parmi les etudiants autorisés à s'inscrire.
|
|
|
|
Principe:
|
|
|
|
- trouver liste d'etud, par semestre
|
|
|
|
- afficher chaque semestre "boites" avec cases à cocher
|
|
|
|
- si l'étudiant est déjà inscrit, le signaler (gras, nom de groupes): il peut être désinscrit
|
|
|
|
- on peut choisir les groupes TD, TP, TA
|
2023-01-26 18:29:16 +01:00
|
|
|
- seuls les étudiants non inscrits changent (de groupe)
|
|
|
|
- les étudiants inscrit qui se trouvent décochés sont désinscrits
|
2020-12-02 01:00:23 +01:00
|
|
|
- Confirmation: indiquer les étudiants inscrits et ceux désinscrits, le total courant.
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
inscrit_groupes = int(inscrit_groupes)
|
2022-01-18 22:01:30 +01:00
|
|
|
ignore_jury = int(ignore_jury)
|
2021-08-19 10:28:35 +02:00
|
|
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
# -- check lock
|
2021-08-10 12:57:38 +02:00
|
|
|
if not sem["etat"]:
|
2020-09-26 16:19:37 +02:00
|
|
|
raise ScoValueError("opération impossible: semestre verrouille")
|
2021-07-29 16:31:15 +02:00
|
|
|
header = html_sco_header.sco_header(page_title="Passage des étudiants")
|
2021-07-29 10:19:00 +02:00
|
|
|
footer = html_sco_header.sco_footer()
|
2020-09-26 16:19:37 +02:00
|
|
|
H = [header]
|
2021-09-27 13:43:11 +02:00
|
|
|
if isinstance(etuds, str):
|
2021-11-27 18:55:47 +01:00
|
|
|
# list de strings, vient du form de confirmation
|
|
|
|
etuds = [int(x) for x in etuds.split(",") if x]
|
2021-09-27 13:43:11 +02:00
|
|
|
elif isinstance(etuds, int):
|
|
|
|
etuds = [etuds]
|
2022-01-07 18:38:32 +01:00
|
|
|
elif etuds and isinstance(etuds[0], str):
|
|
|
|
etuds = [int(x) for x in etuds]
|
2021-11-27 18:55:47 +01:00
|
|
|
|
2022-01-18 22:01:30 +01:00
|
|
|
auth_etuds_by_sem, inscrits, candidats = list_authorized_etuds_by_sem(
|
|
|
|
sem, ignore_jury=ignore_jury
|
|
|
|
)
|
2020-12-02 01:00:23 +01:00
|
|
|
etuds_set = set(etuds)
|
|
|
|
candidats_set = set(candidats)
|
|
|
|
inscrits_set = set(inscrits)
|
2020-09-26 16:19:37 +02:00
|
|
|
candidats_non_inscrits = candidats_set - inscrits_set
|
2021-08-21 00:24:51 +02:00
|
|
|
inscrits_ailleurs = set(list_inscrits_date(sem))
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
def set_to_sorted_etud_list(etudset):
|
|
|
|
etuds = [candidats[etudid] for etudid in etudset]
|
2021-07-09 23:19:30 +02:00
|
|
|
etuds.sort(key=itemgetter("nom"))
|
2020-09-26 16:19:37 +02:00
|
|
|
return etuds
|
|
|
|
|
|
|
|
if submitted:
|
|
|
|
a_inscrire = etuds_set.intersection(candidats_set) - inscrits_set
|
|
|
|
a_desinscrire = inscrits_set - etuds_set
|
|
|
|
else:
|
|
|
|
a_inscrire = a_desinscrire = []
|
|
|
|
|
|
|
|
if not submitted:
|
2023-01-26 18:29:16 +01:00
|
|
|
H += _build_page(
|
2020-09-26 16:19:37 +02:00
|
|
|
sem,
|
|
|
|
auth_etuds_by_sem,
|
|
|
|
inscrits,
|
|
|
|
candidats_non_inscrits,
|
|
|
|
inscrits_ailleurs,
|
|
|
|
inscrit_groupes=inscrit_groupes,
|
2022-01-18 22:01:30 +01:00
|
|
|
ignore_jury=ignore_jury,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
if not dialog_confirmed:
|
|
|
|
# Confirmation
|
|
|
|
if a_inscrire:
|
2023-01-26 18:29:16 +01:00
|
|
|
H.append("<h3>Étudiants à inscrire</h3><ol>")
|
2020-09-26 16:19:37 +02:00
|
|
|
for etud in set_to_sorted_etud_list(a_inscrire):
|
|
|
|
H.append("<li>%(nomprenom)s</li>" % etud)
|
|
|
|
H.append("</ol>")
|
|
|
|
a_inscrire_en_double = inscrits_ailleurs.intersection(a_inscrire)
|
|
|
|
if a_inscrire_en_double:
|
|
|
|
H.append("<h3>dont étudiants déjà inscrits:</h3><ul>")
|
|
|
|
for etud in set_to_sorted_etud_list(a_inscrire_en_double):
|
|
|
|
H.append('<li class="inscrailleurs">%(nomprenom)s</li>' % etud)
|
|
|
|
H.append("</ul>")
|
|
|
|
if a_desinscrire:
|
2023-01-26 18:29:16 +01:00
|
|
|
H.append("<h3>Étudiants à désinscrire</h3><ol>")
|
2020-09-26 16:19:37 +02:00
|
|
|
for etudid in a_desinscrire:
|
|
|
|
H.append(
|
|
|
|
'<li class="desinscription">%(nomprenom)s</li>'
|
|
|
|
% inscrits[etudid]
|
|
|
|
)
|
|
|
|
H.append("</ol>")
|
2021-09-27 22:54:58 +02:00
|
|
|
todo = a_inscrire or a_desinscrire
|
|
|
|
if not todo:
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("""<h3>Il n'y a rien à modifier !</h3>""")
|
|
|
|
H.append(
|
2021-06-02 22:40:34 +02:00
|
|
|
scu.confirm_dialog(
|
2021-09-27 22:54:58 +02:00
|
|
|
dest_url="formsemestre_inscr_passage"
|
|
|
|
if todo
|
|
|
|
else "formsemestre_status",
|
|
|
|
message="<p>Confirmer ?</p>" if todo else "",
|
2020-09-26 16:19:37 +02:00
|
|
|
add_headers=False,
|
|
|
|
cancel_url="formsemestre_inscr_passage?formsemestre_id="
|
2021-08-10 17:12:10 +02:00
|
|
|
+ str(formsemestre_id),
|
2021-09-27 22:54:58 +02:00
|
|
|
OK="Effectuer l'opération" if todo else "",
|
2020-09-26 16:19:37 +02:00
|
|
|
parameters={
|
|
|
|
"formsemestre_id": formsemestre_id,
|
2021-09-27 16:42:14 +02:00
|
|
|
"etuds": ",".join([str(x) for x in etuds]),
|
2020-09-26 16:19:37 +02:00
|
|
|
"inscrit_groupes": inscrit_groupes,
|
2022-01-18 22:55:33 +01:00
|
|
|
"ignore_jury": ignore_jury,
|
2020-09-26 16:19:37 +02:00
|
|
|
"submitted": 1,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
2023-01-26 18:29:16 +01:00
|
|
|
with sco_cache.DeferredSemCacheManager():
|
|
|
|
# Inscription des étudiants au nouveau semestre:
|
|
|
|
do_inscrit(
|
|
|
|
sem,
|
|
|
|
a_inscrire,
|
|
|
|
inscrit_groupes=inscrit_groupes,
|
|
|
|
)
|
|
|
|
# Désinscriptions:
|
|
|
|
do_desinscrit(sem, a_desinscrire)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
H.append(
|
2023-01-26 18:29:16 +01:00
|
|
|
f"""<h3>Opération effectuée</h3>
|
|
|
|
<ul>
|
|
|
|
<li><a class="stdlink" href="{
|
|
|
|
url_for("notes.formsemestre_inscr_passage",
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id)
|
|
|
|
}">Continuer les inscriptions</a>
|
|
|
|
</li>
|
|
|
|
<li><a class="stdlink" href="{
|
|
|
|
url_for("notes.formsemestre_status",
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id)
|
|
|
|
}">Tableau de bord du semestre</a>
|
|
|
|
</li>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2021-08-19 10:28:35 +02:00
|
|
|
partition = sco_groups.formsemestre_get_main_partition(formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
if (
|
|
|
|
partition["partition_id"]
|
2021-08-19 10:28:35 +02:00
|
|
|
!= sco_groups.formsemestre_get_main_partition(formsemestre_id)[
|
2020-09-26 16:19:37 +02:00
|
|
|
"partition_id"
|
|
|
|
]
|
|
|
|
): # il y a au moins une vraie partition
|
|
|
|
H.append(
|
2021-08-16 08:33:12 +02:00
|
|
|
f"""<li><a class="stdlink" href="{
|
2021-10-04 22:05:05 +02:00
|
|
|
url_for("scolar.affect_groups",
|
2023-01-26 18:29:16 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, partition_id=partition["partition_id"])
|
2021-08-16 08:33:12 +02:00
|
|
|
}">Répartir les groupes de {partition["partition_name"]}</a></li>
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
#
|
|
|
|
H.append(footer)
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2023-01-26 18:29:16 +01:00
|
|
|
def _build_page(
|
2020-09-26 16:19:37 +02:00
|
|
|
sem,
|
|
|
|
auth_etuds_by_sem,
|
|
|
|
inscrits,
|
|
|
|
candidats_non_inscrits,
|
|
|
|
inscrits_ailleurs,
|
|
|
|
inscrit_groupes=False,
|
2022-01-18 22:01:30 +01:00
|
|
|
ignore_jury=False,
|
2020-09-26 16:19:37 +02:00
|
|
|
):
|
2023-07-11 06:57:38 +02:00
|
|
|
formsemestre: FormSemestre = db.session.get(FormSemestre, sem["formsemestre_id"])
|
2020-09-26 16:19:37 +02:00
|
|
|
inscrit_groupes = int(inscrit_groupes)
|
2022-01-18 22:01:30 +01:00
|
|
|
ignore_jury = int(ignore_jury)
|
2020-09-26 16:19:37 +02:00
|
|
|
if inscrit_groupes:
|
|
|
|
inscrit_groupes_checked = " checked"
|
|
|
|
else:
|
|
|
|
inscrit_groupes_checked = ""
|
2022-01-18 22:01:30 +01:00
|
|
|
if ignore_jury:
|
|
|
|
ignore_jury_checked = " checked"
|
|
|
|
else:
|
|
|
|
ignore_jury_checked = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
H = [
|
2021-06-13 19:12:20 +02:00
|
|
|
html_sco_header.html_sem_header(
|
2022-01-07 15:11:24 +01:00
|
|
|
"Passages dans le semestre", with_page_header=False
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
2023-01-26 18:29:16 +01:00
|
|
|
f"""<form name="f" method="post" action="{request.base_url}">
|
|
|
|
|
|
|
|
<input type="hidden" name="formsemestre_id" value="{sem['formsemestre_id']}"/>
|
|
|
|
|
|
|
|
<input type="submit" name="submitted" value="Appliquer les modifications"/>
|
|
|
|
<a href="#help">aide</a>
|
|
|
|
|
|
|
|
<input name="inscrit_groupes" type="checkbox" value="1"
|
|
|
|
{inscrit_groupes_checked}>inscrire aux mêmes groupes</input>
|
|
|
|
|
|
|
|
<input name="ignore_jury" type="checkbox" value="1" onchange="document.f.submit()"
|
|
|
|
{ignore_jury_checked}>inclure tous les étudiants (même sans décision de jury)</input>
|
|
|
|
|
|
|
|
<div class="pas_recap">Actuellement <span id="nbinscrits">{len(inscrits)}</span> inscrits
|
|
|
|
et {len(candidats_non_inscrits)} candidats supplémentaires
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>{scu.EMO_WARNING} <em>Seuls les semestres dont la date de fin est antérieure à la date de début
|
|
|
|
de ce semestre ({formsemestre.date_debut.strftime("%d/%m/%Y")}) sont pris en compte.</em></div>
|
|
|
|
{etuds_select_boxes(auth_etuds_by_sem, inscrits_ailleurs)}
|
|
|
|
|
|
|
|
<input type="submit" name="submitted" value="Appliquer les modifications"/>
|
|
|
|
|
|
|
|
{formsemestre_inscr_passage_help(sem)}
|
|
|
|
|
|
|
|
</form>
|
|
|
|
""",
|
2020-09-26 16:19:37 +02:00
|
|
|
]
|
|
|
|
|
2023-01-26 18:29:16 +01:00
|
|
|
# Semestres sans étudiants autorisés
|
2020-09-26 16:19:37 +02:00
|
|
|
empty_sems = []
|
|
|
|
for formsemestre_id in auth_etuds_by_sem.keys():
|
|
|
|
if not auth_etuds_by_sem[formsemestre_id]["etuds"]:
|
|
|
|
empty_sems.append(auth_etuds_by_sem[formsemestre_id]["infos"])
|
|
|
|
if empty_sems:
|
|
|
|
H.append(
|
|
|
|
"""<div class="pas_empty_sems"><h3>Autres semestres sans candidats :</h3><ul>"""
|
|
|
|
)
|
|
|
|
for infos in empty_sems:
|
2023-01-26 18:29:16 +01:00
|
|
|
H.append(
|
|
|
|
"""<li><a class="stdlink" href="%(title_target)s">%(title)s</a></li>"""
|
|
|
|
% infos
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("""</ul></div>""")
|
|
|
|
|
|
|
|
return H
|
|
|
|
|
|
|
|
|
|
|
|
def formsemestre_inscr_passage_help(sem):
|
2023-01-24 00:35:15 +01:00
|
|
|
return f"""<div class="pas_help"><h3><a name="help">Explications</a></h3>
|
2020-09-26 16:19:37 +02:00
|
|
|
<p>Cette page permet d'inscrire des étudiants dans le semestre destination
|
|
|
|
<a class="stdlink"
|
2023-01-24 00:35:15 +01:00
|
|
|
href="{
|
|
|
|
url_for("notes.formsemestre_status", scodoc_dept=g.scodoc_dept, formsemestre_id=sem["formsemestre_id"] )
|
|
|
|
}">{sem['titreannee']}</a>,
|
2020-09-26 16:19:37 +02:00
|
|
|
et d'en désincrire si besoin.
|
|
|
|
</p>
|
|
|
|
<p>Les étudiants sont groupés par semestres d'origines. Ceux qui sont en caractères
|
|
|
|
<span class="inscrit">gras</span> sont déjà inscrits dans le semestre destination.
|
|
|
|
Ceux qui sont en <span class"inscrailleurs">gras et en rouge</span> sont inscrits
|
|
|
|
dans un <em>autre</em> semestre.</p>
|
|
|
|
<p>Au départ, les étudiants déjà inscrits sont sélectionnés; vous pouvez ajouter d'autres
|
|
|
|
étudiants à inscrire dans le semestre destination.</p>
|
|
|
|
<p>Si vous dé-selectionnez un étudiant déjà inscrit (en gras), il sera désinscrit.</p>
|
2023-01-24 00:35:15 +01:00
|
|
|
<p>Le bouton <em>inscrire aux mêmes groupes</em> ne prend en compte que les groupes qui existent
|
|
|
|
dans les deux semestres: pensez à créer les partitions et groupes que vous souhaitez conserver
|
|
|
|
<b>avant</b> d'inscrire les étudiants.
|
|
|
|
</p>
|
2020-09-26 16:19:37 +02:00
|
|
|
<p class="help">Aucune action ne sera effectuée si vous n'appuyez pas sur le bouton "Appliquer les modifications" !</p>
|
2023-01-24 00:35:15 +01:00
|
|
|
</div>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
def etuds_select_boxes(
|
|
|
|
auth_etuds_by_cat,
|
|
|
|
inscrits_ailleurs={},
|
|
|
|
sel_inscrits=True,
|
|
|
|
show_empty_boxes=False,
|
|
|
|
export_cat_xls=None,
|
|
|
|
base_url="",
|
|
|
|
read_only=False,
|
|
|
|
):
|
|
|
|
"""Boites pour selection étudiants par catégorie
|
|
|
|
auth_etuds_by_cat = { category : { 'info' : {}, 'etuds' : ... }
|
|
|
|
inscrits_ailleurs =
|
2020-12-02 01:00:23 +01:00
|
|
|
sel_inscrits=
|
2020-09-26 16:19:37 +02:00
|
|
|
export_cat_xls =
|
|
|
|
"""
|
|
|
|
if export_cat_xls:
|
2021-08-21 00:24:51 +02:00
|
|
|
return etuds_select_box_xls(auth_etuds_by_cat[export_cat_xls])
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
H = [
|
|
|
|
"""<script type="text/javascript">
|
|
|
|
function sem_select(formsemestre_id, state) {
|
|
|
|
var elems = document.getElementById(formsemestre_id).getElementsByTagName("input");
|
|
|
|
for (var i =0; i < elems.length; i++) { elems[i].checked=state; }
|
|
|
|
}
|
|
|
|
function sem_select_inscrits(formsemestre_id) {
|
|
|
|
var elems = document.getElementById(formsemestre_id).getElementsByTagName("input");
|
|
|
|
for (var i =0; i < elems.length; i++) {
|
|
|
|
if (elems[i].parentNode.className.indexOf('inscrit') >= 0) {
|
|
|
|
elems[i].checked=true;
|
|
|
|
} else {
|
|
|
|
elems[i].checked=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<div class="etuds_select_boxes">"""
|
|
|
|
] # "
|
2021-09-25 10:43:06 +02:00
|
|
|
# Élimine les boites vides:
|
|
|
|
auth_etuds_by_cat = {
|
|
|
|
k: auth_etuds_by_cat[k]
|
|
|
|
for k in auth_etuds_by_cat
|
|
|
|
if auth_etuds_by_cat[k]["etuds"]
|
|
|
|
}
|
2020-09-26 16:19:37 +02:00
|
|
|
for src_cat in auth_etuds_by_cat.keys():
|
|
|
|
infos = auth_etuds_by_cat[src_cat]["infos"]
|
|
|
|
infos["comment"] = infos.get("comment", "") # commentaire dans sous-titre boite
|
|
|
|
help = infos.get("help", "")
|
|
|
|
etuds = auth_etuds_by_cat[src_cat]["etuds"]
|
2021-07-09 23:19:30 +02:00
|
|
|
etuds.sort(key=itemgetter("nom"))
|
2020-09-26 16:19:37 +02:00
|
|
|
with_checkbox = (not read_only) and auth_etuds_by_cat[src_cat]["infos"].get(
|
|
|
|
"with_checkbox", True
|
|
|
|
)
|
|
|
|
checkbox_name = auth_etuds_by_cat[src_cat]["infos"].get(
|
|
|
|
"checkbox_name", "etuds"
|
|
|
|
)
|
|
|
|
etud_key = auth_etuds_by_cat[src_cat]["infos"].get("etud_key", "etudid")
|
|
|
|
if etuds or show_empty_boxes:
|
|
|
|
infos["nbetuds"] = len(etuds)
|
|
|
|
H.append(
|
|
|
|
"""<div class="pas_sembox" id="%(id)s">
|
|
|
|
<div class="pas_sembox_title"><a href="%(title_target)s" """
|
|
|
|
% infos
|
|
|
|
)
|
|
|
|
if help: # bubble
|
|
|
|
H.append('title="%s"' % help)
|
|
|
|
H.append(
|
|
|
|
""">%(title)s</a></div>
|
|
|
|
<div class="pas_sembox_subtitle">(%(nbetuds)d étudiants%(comment)s)"""
|
|
|
|
% infos
|
|
|
|
)
|
|
|
|
if with_checkbox:
|
|
|
|
H.append(
|
|
|
|
""" (Select.
|
2023-01-24 00:35:15 +01:00
|
|
|
<a href="#" class="stdlink" onclick="sem_select('%(id)s', true);">tous</a>
|
|
|
|
<a href="#" class="stdlink" onclick="sem_select('%(id)s', false );">aucun</a>""" # "
|
2020-09-26 16:19:37 +02:00
|
|
|
% infos
|
|
|
|
)
|
|
|
|
if sel_inscrits:
|
|
|
|
H.append(
|
2023-01-24 00:35:15 +01:00
|
|
|
"""<a href="#" class="stdlink" onclick="sem_select_inscrits('%(id)s');">inscrits</a>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
% infos
|
|
|
|
)
|
|
|
|
if with_checkbox or sel_inscrits:
|
|
|
|
H.append(")")
|
|
|
|
if base_url and etuds:
|
2021-09-25 10:43:06 +02:00
|
|
|
url = scu.build_url_query(base_url, export_cat_xls=src_cat)
|
|
|
|
H.append(f'<a href="{url}">{scu.ICON_XLS}</a> ')
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("</div>")
|
|
|
|
for etud in etuds:
|
|
|
|
if etud.get("inscrit", False):
|
|
|
|
c = " inscrit"
|
|
|
|
checked = 'checked="checked"'
|
|
|
|
else:
|
|
|
|
checked = ""
|
|
|
|
if etud["etudid"] in inscrits_ailleurs:
|
|
|
|
c = " inscrailleurs"
|
|
|
|
else:
|
|
|
|
c = ""
|
2021-06-19 23:21:37 +02:00
|
|
|
sco_etud.format_etud_ident(etud)
|
2020-09-26 16:19:37 +02:00
|
|
|
if etud["etudid"]:
|
2021-07-11 17:37:12 +02:00
|
|
|
elink = """<a class="discretelink %s" href="%s">%s</a>""" % (
|
|
|
|
c,
|
|
|
|
url_for(
|
|
|
|
"scolar.ficheEtud",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
etudid=etud["etudid"],
|
|
|
|
),
|
|
|
|
etud["nomprenom"],
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
# ce n'est pas un etudiant ScoDoc
|
|
|
|
elink = etud["nomprenom"]
|
|
|
|
|
|
|
|
if etud.get("datefinalisationinscription", None):
|
|
|
|
elink += (
|
|
|
|
'<span class="finalisationinscription">'
|
|
|
|
+ " : inscription finalisée le "
|
|
|
|
+ etud["datefinalisationinscription"].strftime("%d/%m/%Y")
|
|
|
|
+ "</span>"
|
|
|
|
)
|
|
|
|
|
|
|
|
if not etud.get("paiementinscription", True):
|
|
|
|
elink += '<span class="paspaye"> (non paiement)</span>'
|
|
|
|
|
|
|
|
H.append("""<div class="pas_etud%s">""" % c)
|
|
|
|
if "etape" in etud:
|
|
|
|
etape_str = etud["etape"] or ""
|
|
|
|
else:
|
|
|
|
etape_str = ""
|
|
|
|
H.append("""<span class="sp_etape">%s</span>""" % etape_str)
|
|
|
|
if with_checkbox:
|
|
|
|
H.append(
|
|
|
|
"""<input type="checkbox" name="%s:list" value="%s" %s>"""
|
|
|
|
% (checkbox_name, etud[etud_key], checked)
|
|
|
|
)
|
|
|
|
H.append(elink)
|
|
|
|
if with_checkbox:
|
|
|
|
H.append("""</input>""")
|
|
|
|
H.append("</div>")
|
|
|
|
H.append("</div>")
|
|
|
|
|
|
|
|
H.append("</div>")
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def etuds_select_box_xls(src_cat):
|
2020-09-26 16:19:37 +02:00
|
|
|
"export a box to excel"
|
|
|
|
etuds = src_cat["etuds"]
|
2021-02-13 17:28:55 +01:00
|
|
|
columns_ids = ["etudid", "civilite_str", "nom", "prenom", "etape"]
|
2020-12-02 01:00:23 +01:00
|
|
|
titles = {x: x for x in columns_ids}
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
# Ajoute colonne paiement inscription
|
|
|
|
columns_ids.append("paiementinscription_str")
|
|
|
|
titles["paiementinscription_str"] = "paiement inscription"
|
|
|
|
for e in etuds:
|
|
|
|
if not e.get("paiementinscription", True):
|
|
|
|
e["paiementinscription_str"] = "NON"
|
|
|
|
else:
|
|
|
|
e["paiementinscription_str"] = "-"
|
|
|
|
tab = GenTable(
|
|
|
|
titles=titles,
|
|
|
|
columns_ids=columns_ids,
|
|
|
|
rows=etuds,
|
|
|
|
caption="%(title)s. %(help)s" % src_cat["infos"],
|
2021-07-28 17:03:54 +02:00
|
|
|
preferences=sco_preferences.SemPreferences(),
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2021-09-25 10:43:06 +02:00
|
|
|
return tab.excel() # tab.make_page(filename=src_cat["infos"]["filename"])
|