From 9e52566781822e99b29dfd456a893c313f747285 Mon Sep 17 00:00:00 2001
From: Emmanuel Viennet
"
else:
@@ -93,9 +92,11 @@ def pvjury_page_but(formsemestre_id: int, fmt="html"):
def pvjury_table_but(
- formsemestre: FormSemestre, line_sep: str = "\n"
+ formsemestre: FormSemestre, etudids: list[int] = None, line_sep: str = "\n"
) -> tuple[list[dict], dict]:
- "table avec résultats jury BUT pour PV"
+ """Table avec résultats jury BUT pour PV.
+ Si etudids est None, prend tous les étudiants inscrits.
+ """
# remplace pour le BUT la fonction sco_pvjury.pvjury_table
annee_but = (formsemestre.semestre_id + 1) // 2
titles = {
@@ -110,7 +111,12 @@ def pvjury_table_but(
"observations": "Observations",
}
rows = []
- for etudid in formsemestre.etuds_inscriptions:
+ formsemestre_etudids = formsemestre.etuds_inscriptions.keys()
+ if etudids is None:
+ etudids = formsemestre_etudids
+ for etudid in etudids:
+ if not etudid in formsemestre_etudids:
+ continue # garde fou
etud: Identite = Identite.query.get(etudid)
try:
deca = jury_but.DecisionsProposeesAnnee(etud, formsemestre)
diff --git a/app/but/jury_but_results.py b/app/but/jury_but_results.py
index 79aa14df..d947bf84 100644
--- a/app/but/jury_but_results.py
+++ b/app/but/jury_but_results.py
@@ -12,7 +12,7 @@ import numpy as np
from app.but import jury_but
from app.models.etudiants import Identite
from app.models.formsemestre import FormSemestre
-from app.scodoc import sco_pvjury
+from app.scodoc import sco_dict_pv_jury
def get_jury_but_results(formsemestre: FormSemestre) -> list[dict]:
@@ -20,7 +20,7 @@ def get_jury_but_results(formsemestre: FormSemestre) -> list[dict]:
if formsemestre.formation.referentiel_competence is None:
# pas de ref. comp., donc pas de decisions de jury (ne lance pas d'exception)
return []
- dpv = sco_pvjury.dict_pvjury(formsemestre.id)
+ dpv = sco_dict_pv_jury.dict_pvjury(formsemestre.id)
rows = []
for etudid in formsemestre.etuds_inscriptions:
rows.append(_get_jury_but_etud_result(formsemestre, dpv, etudid))
diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py
index 3b01ff96..9815b9fd 100644
--- a/app/models/formsemestre.py
+++ b/app/models/formsemestre.py
@@ -435,6 +435,12 @@ class FormSemestre(db.Model):
)
)
+ def est_terminal(self) -> bool:
+ "Vrai si dernier semestre de son cursus (ou formation mono-semestre)"
+ return (self.semestre_id < 0) or (
+ self.semestre_id == self.formation.get_cursus().NB_SEM
+ )
+
@classmethod
def comp_periode(
cls,
diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py
index aa57823a..3e3ff43a 100644
--- a/app/scodoc/sco_archives.py
+++ b/app/scodoc/sco_archives.py
@@ -71,14 +71,14 @@ from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import Departement, FormSemestre
from app.scodoc.TrivialFormulator import TrivialFormulator
-from app.scodoc.sco_exceptions import AccessDenied, ScoPermissionDenied
+from app.scodoc.sco_exceptions import ScoPermissionDenied
from app.scodoc import html_sco_header
from app.scodoc import sco_bulletins_pdf
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_groups_view
-from app.scodoc import sco_permissions_check
from app.scodoc import sco_pvjury
+from app.scodoc import sco_dict_pv_jury
from app.scodoc import sco_pvpdf
from app.scodoc.sco_exceptions import ScoValueError
@@ -299,13 +299,13 @@ def do_formsemestre_archive(
date_jury="",
signature=None, # pour lettres indiv
date_commission=None,
- numeroArrete=None,
- VDICode=None,
- showTitle=False,
+ numero_arrete=None,
+ code_vdi=None,
+ show_title=False,
pv_title=None,
with_paragraph_nom=False,
anonymous=False,
- bulVersion="long",
+ bul_version="long",
):
"""Make and store new archive for this formsemestre.
Store:
@@ -377,7 +377,7 @@ def do_formsemestre_archive(
)
# Classeur bulletins (PDF)
data, _ = sco_bulletins_pdf.get_formsemestre_bulletins_pdf(
- formsemestre_id, version=bulVersion
+ formsemestre_id, version=bul_version
)
if data:
PVArchive.store(archive_id, "Bulletins.pdf", data)
@@ -395,14 +395,16 @@ def do_formsemestre_archive(
# PV de jury (PDF): disponible seulement en classique
# en BUT, le PV est sous forme excel (Decisions_Jury.xlsx ci-dessus)
if not formsemestre.formation.is_apc():
- dpv = sco_pvjury.dict_pvjury(formsemestre_id, etudids=etudids, with_prev=True)
+ dpv = sco_dict_pv_jury.dict_pvjury(
+ formsemestre_id, etudids=etudids, with_prev=True
+ )
data = sco_pvpdf.pvjury_pdf(
dpv,
date_commission=date_commission,
date_jury=date_jury,
- numeroArrete=numeroArrete,
- VDICode=VDICode,
- showTitle=showTitle,
+ numero_arrete=numero_arrete,
+ code_vdi=code_vdi,
+ show_title=show_title,
pv_title=pv_title,
with_paragraph_nom=with_paragraph_nom,
anonymous=anonymous,
@@ -411,7 +413,7 @@ def do_formsemestre_archive(
PVArchive.store(archive_id, "PV_Jury%s.pdf" % groups_filename, data)
-def formsemestre_archive(formsemestre_id, group_ids=[]):
+def formsemestre_archive(formsemestre_id, group_ids: list[int] = None):
"""Make and store new archive for this formsemestre.
(all students or only selected groups)
"""
@@ -424,8 +426,6 @@ def formsemestre_archive(formsemestre_id, group_ids=[]):
formsemestre_id=formsemestre_id,
)
)
-
- sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not group_ids:
# tous les inscrits du semestre
group_ids = [sco_groups.get_default_group(formsemestre_id)]
@@ -462,7 +462,7 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement.
),
("sep", {"input_type": "separator", "title": "Informations sur PV de jury"}),
]
- descr += sco_pvjury.descrform_pvjury(sem)
+ descr += sco_pvjury.descrform_pvjury(formsemestre)
descr += [
(
"signature",
@@ -473,7 +473,7 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement.
},
),
(
- "bulVersion",
+ "bul_version",
{
"input_type": "menu",
"title": "Version des bulletins archivés",
@@ -523,20 +523,24 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement.
date_jury=tf[2]["date_jury"],
date_commission=tf[2]["date_commission"],
signature=signature,
- numeroArrete=tf[2]["numeroArrete"],
- VDICode=tf[2]["VDICode"],
+ numero_arrete=tf[2]["numero_arrete"],
+ code_vdi=tf[2]["code_vdi"],
pv_title=tf[2]["pv_title"],
- showTitle=tf[2]["showTitle"],
+ show_title=tf[2]["show_title"],
with_paragraph_nom=tf[2]["with_paragraph_nom"],
anonymous=tf[2]["anonymous"],
- bulVersion=tf[2]["bulVersion"],
+ bul_version=tf[2]["bul_version"],
)
msg = "Nouvelle%20archive%20créée"
# submitted or cancelled:
+ flash(msg)
return flask.redirect(
- "formsemestre_list_archives?formsemestre_id=%s&head_message=%s"
- % (formsemestre_id, msg)
+ url_for(
+ "notes.formsemestre_list_archives",
+ scodoc_dept=g.scodoc_dept,
+ formsemestre_id=formsemestre_id,
+ )
)
diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py
index cef2c73e..84e810a7 100644
--- a/app/scodoc/sco_bulletins.py
+++ b/app/scodoc/sco_bulletins.py
@@ -56,12 +56,10 @@ from app.scodoc import sco_bulletins_xml
from app.scodoc import codes_cursus
from app.scodoc import sco_etud
from app.scodoc import sco_evaluation_db
-from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
-from app.scodoc import sco_permissions_check
from app.scodoc import sco_preferences
-from app.scodoc import sco_pvjury
+from app.scodoc import sco_dict_pv_jury
from app.scodoc import sco_users
import app.scodoc.sco_utils as scu
from app.scodoc.sco_utils import ModuleType, fmt_note
@@ -789,7 +787,7 @@ def etud_descr_situation_semestre(
infos["date_defaillance"] = date_def
infos["descr_decision_jury"] = f"Défaillant{ne}"
- dpv = sco_pvjury.dict_pvjury(formsemestre_id, etudids=[etudid])
+ dpv = sco_dict_pv_jury.dict_pvjury(formsemestre_id, etudids=[etudid])
if dpv:
infos["decision_sem"] = dpv["decisions"][0]["decision_sem"]
diff --git a/app/scodoc/sco_dict_pv_jury.py b/app/scodoc/sco_dict_pv_jury.py
new file mode 100644
index 00000000..1075a2ce
--- /dev/null
+++ b/app/scodoc/sco_dict_pv_jury.py
@@ -0,0 +1,324 @@
+# -*- mode: python -*-
+# -*- coding: utf-8 -*-
+
+##############################################################################
+#
+# Gestion scolarite IUT
+#
+# Copyright (c) 1999 - 2023 Emmanuel Viennet. All rights reserved.
+#
+# 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
+#
+##############################################################################
+
+"""Ancienne fonction de synthèse des information jury
+ (pour formations classiques)
+"""
+from operator import itemgetter
+
+from app import log
+from app.comp import res_sem
+from app.comp.res_compat import NotesTableCompat
+from app.models import (
+ Formation,
+ FormSemestre,
+ Identite,
+ ScolarAutorisationInscription,
+ UniteEns,
+ but_validations,
+)
+from app.scodoc import codes_cursus
+from app.scodoc import sco_etud
+from app.scodoc import sco_formsemestre
+from app.scodoc import sco_cursus
+from app.scodoc import sco_cursus_dut
+import app.scodoc.notesdb as ndb
+import app.scodoc.sco_utils as scu
+
+
+def dict_pvjury(
+ formsemestre_id,
+ etudids=None,
+ with_prev=False,
+ with_parcours_decisions=False,
+):
+ """Données pour édition jury
+ etudids == None => tous les inscrits, sinon donne la liste des ids
+ Si with_prev: ajoute infos sur code jury semestre precedent
+ Si with_parcours_decisions: ajoute infos sur code decision jury de tous les semestre du parcours
+ Résultat:
+ {
+ 'date' : date de la decision la plus recente,
+ 'formsemestre' : sem,
+ 'is_apc' : bool,
+ 'formation' : { 'acronyme' :, 'titre': ... }
+ 'decisions' : { [ { 'identite' : {'nom' :, 'prenom':, ...,},
+ 'etat' : I ou D ou DEF
+ 'decision_sem' : {'code':, 'code_prev': },
+ 'decisions_ue' : { ue_id : { 'code' : ADM|CMP|AJ, 'event_date' :,
+ 'acronyme', 'numero': } },
+ 'autorisations' : [ { 'semestre_id' : { ... } } ],
+ 'validation_parcours' : True si parcours validé (diplome obtenu)
+ 'prev_code' : code (calculé slt si with_prev),
+ 'mention' : mention (en fct moy gen),
+ 'sum_ects' : total ECTS acquis dans ce semestre (incluant les UE capitalisées)
+ 'sum_ects_capitalises' : somme des ECTS des UE capitalisees
+ }
+ ]
+ },
+ 'decisions_dict' : { etudid : decision (comme ci-dessus) },
+ }
+ """
+ formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
+ nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
+ if etudids is None:
+ etudids = nt.get_etudids()
+ if not etudids:
+ return {}
+ cnx = ndb.GetDBConnexion()
+ sem = sco_formsemestre.get_formsemestre(formsemestre_id)
+ max_date = "0000-01-01"
+ has_prev = False # vrai si au moins un etudiant a un code prev
+ semestre_non_terminal = False # True si au moins un etudiant a un devenir
+
+ decisions = []
+ D = {} # même chose que decisions, mais { etudid : dec }
+ for etudid in etudids:
+ etud: Identite = Identite.query.get(etudid)
+ Se = sco_cursus.get_situation_etud_cursus(
+ etud.to_dict_scodoc7(), formsemestre_id
+ )
+ semestre_non_terminal = semestre_non_terminal or Se.semestre_non_terminal
+ d = {}
+ d["identite"] = nt.identdict[etudid]
+ d["etat"] = nt.get_etud_etat(
+ etudid
+ ) # I|D|DEF (inscription ou démission ou défaillant)
+ d["decision_sem"] = nt.get_etud_decision_sem(etudid)
+ d["decisions_ue"] = nt.get_etud_decision_ues(etudid)
+ if formsemestre.formation.is_apc():
+ d.update(but_validations.dict_decision_jury(etud, formsemestre))
+ d["last_formsemestre_id"] = Se.get_semestres()[
+ -1
+ ] # id du dernier semestre (chronologiquement) dans lequel il a été inscrit
+
+ ects_capitalises_by_ue_code = _comp_ects_capitalises_by_ue_code(nt, etudid)
+ d["sum_ects_capitalises"] = sum(ects_capitalises_by_ue_code.values())
+ ects_by_ue_code = _comp_ects_by_ue_code(nt, d["decisions_ue"])
+ d["sum_ects"] = _sum_ects_dicts(ects_capitalises_by_ue_code, ects_by_ue_code)
+
+ if d["decision_sem"] and codes_cursus.code_semestre_validant(
+ d["decision_sem"]["code"]
+ ):
+ d["mention"] = scu.get_mention(nt.get_etud_moy_gen(etudid))
+ else:
+ d["mention"] = ""
+ # Versions "en français": (avec les UE capitalisées d'ailleurs)
+ dec_ue_list = _descr_decisions_ues(
+ nt, etudid, d["decisions_ue"], d["decision_sem"]
+ )
+ d["decisions_ue_nb"] = len(
+ dec_ue_list
+ ) # avec les UE capitalisées, donc des éventuels doublons
+ # Mais sur la description (eg sur les bulletins), on ne veut pas
+ # afficher ces doublons: on uniquifie sur ue_code
+ _codes = set()
+ ue_uniq = []
+ for ue in dec_ue_list:
+ if ue["ue_code"] not in _codes:
+ ue_uniq.append(ue)
+ _codes.add(ue["ue_code"])
+
+ d["decisions_ue_descr"] = ", ".join([ue["acronyme"] for ue in ue_uniq])
+ if nt.is_apc:
+ d["decision_sem_descr"] = "" # pas de validation de semestre en BUT
+ else:
+ d["decision_sem_descr"] = _descr_decision_sem(d["etat"], d["decision_sem"])
+
+ autorisations = ScolarAutorisationInscription.query.filter_by(
+ etudid=etudid, origin_formsemestre_id=formsemestre_id
+ ).all()
+ d["autorisations"] = [a.to_dict() for a in autorisations]
+ d["autorisations_descr"] = _descr_autorisations(autorisations)
+
+ d["validation_parcours"] = Se.parcours_validated()
+ d["parcours"] = Se.get_cursus_descr(filter_futur=True)
+ if with_parcours_decisions:
+ d["parcours_decisions"] = Se.get_parcours_decisions()
+ # Observations sur les compensations:
+ compensators = sco_cursus_dut.scolar_formsemestre_validation_list(
+ cnx, args={"compense_formsemestre_id": formsemestre_id, "etudid": etudid}
+ )
+ obs = []
+ for compensator in compensators:
+ # nb: il ne devrait y en avoir qu'un !
+ csem = sco_formsemestre.get_formsemestre(compensator["formsemestre_id"])
+ obs.append(
+ "%s compensé par %s (%s)"
+ % (sem["sem_id_txt"], csem["sem_id_txt"], csem["anneescolaire"])
+ )
+
+ if d["decision_sem"] and d["decision_sem"]["compense_formsemestre_id"]:
+ compensed = sco_formsemestre.get_formsemestre(
+ d["decision_sem"]["compense_formsemestre_id"]
+ )
+ obs.append(
+ f"""{sem["sem_id_txt"]} compense {compensed["sem_id_txt"]} ({compensed["anneescolaire"]})"""
+ )
+
+ d["observation"] = ", ".join(obs)
+
+ # Cherche la date de decision (sem ou UE) la plus récente:
+ if d["decision_sem"]:
+ date = ndb.DateDMYtoISO(d["decision_sem"]["event_date"])
+ if date and date > max_date: # decision plus recente
+ max_date = date
+ if d["decisions_ue"]:
+ for dec_ue in d["decisions_ue"].values():
+ if dec_ue:
+ date = ndb.DateDMYtoISO(dec_ue["event_date"])
+ if date and date > max_date: # decision plus recente
+ max_date = date
+ # Code semestre precedent
+ if with_prev: # optionnel car un peu long...
+ info = sco_etud.get_etud_info(etudid=etudid, filled=True)
+ if not info:
+ continue # should not occur
+ etud = info[0]
+ if Se.prev and Se.prev_decision:
+ d["prev_decision_sem"] = Se.prev_decision
+ d["prev_code"] = Se.prev_decision["code"]
+ d["prev_code_descr"] = _descr_decision_sem(
+ scu.INSCRIT, Se.prev_decision
+ )
+ d["prev"] = Se.prev
+ has_prev = True
+ else:
+ d["prev_decision_sem"] = None
+ d["prev_code"] = ""
+ d["prev_code_descr"] = ""
+ d["Se"] = Se
+
+ decisions.append(d)
+ D[etudid] = d
+
+ return {
+ "date": ndb.DateISOtoDMY(max_date),
+ "formsemestre": sem,
+ "is_apc": nt.is_apc,
+ "has_prev": has_prev,
+ "semestre_non_terminal": semestre_non_terminal,
+ "formation": Formation.query.get_or_404(sem["formation_id"]).to_dict(),
+ "decisions": decisions,
+ "decisions_dict": D,
+ }
+
+
+def _comp_ects_capitalises_by_ue_code(nt: NotesTableCompat, etudid: int):
+ """Calcul somme des ECTS des UE capitalisees"""
+ ues = nt.get_ues_stat_dict()
+ ects_by_ue_code = {}
+ for ue in ues:
+ ue_status = nt.get_etud_ue_status(etudid, ue["ue_id"])
+ if ue_status and ue_status["is_capitalized"]:
+ ects_val = float(ue_status["ue"]["ects"] or 0.0)
+ ects_by_ue_code[ue["ue_code"]] = ects_val
+
+ return ects_by_ue_code
+
+
+def _comp_ects_by_ue_code(nt, decision_ues):
+ """Calcul somme des ECTS validés dans ce semestre (sans les UE capitalisées)
+ decision_ues est le resultat de nt.get_etud_decision_ues
+ Chaque resultat est un dict: { ue_code : ects }
+ """
+ if not decision_ues:
+ return {}
+
+ ects_by_ue_code = {}
+ for ue_id in decision_ues:
+ d = decision_ues[ue_id]
+ ue = UniteEns.query.get(ue_id)
+ ects_by_ue_code[ue.ue_code] = d["ects"]
+
+ return ects_by_ue_code
+
+
+def _descr_autorisations(autorisations: list[ScolarAutorisationInscription]) -> str:
+ "résumé textuel des autorisations d'inscription (-> 'S1, S3' )"
+ return ", ".join([f"S{a.semestre_id}" for a in autorisations])
+
+
+def _descr_decisions_ues(nt, etudid, decisions_ue, decision_sem) -> list[dict]:
+ """Liste des UE validées dans ce semestre (incluant les UE capitalisées)"""
+ if not decisions_ue:
+ return []
+ uelist = []
+ # Les UE validées dans ce semestre:
+ for ue_id in decisions_ue.keys():
+ try:
+ if decisions_ue[ue_id] and (
+ codes_cursus.code_ue_validant(decisions_ue[ue_id]["code"])
+ or (
+ (not nt.is_apc)
+ and (
+ # XXX ceci devrait dépendre du parcours et non pas être une option ! #sco8
+ decision_sem
+ and scu.CONFIG.CAPITALIZE_ALL_UES
+ and codes_cursus.code_semestre_validant(decision_sem["code"])
+ )
+ )
+ ):
+ ue = sco_edit_ue.ue_list(args={"ue_id": ue_id})[0]
+ uelist.append(ue)
+ except:
+ log(
+ f"Exception in descr_decisions_ues: ue_id={ue_id} decisions_ue={decisions_ue}"
+ )
+ # Les UE capitalisées dans d'autres semestres:
+ if etudid in nt.validations.ue_capitalisees.index:
+ for ue_id in nt.validations.ue_capitalisees.loc[[etudid]]["ue_id"]:
+ try:
+ uelist.append(nt.get_etud_ue_status(etudid, ue_id)["ue"])
+ except (KeyError, TypeError):
+ pass
+ uelist.sort(key=itemgetter("numero"))
+
+ return uelist
+
+
+def _descr_decision_sem(etat, decision_sem):
+ "résumé textuel de la décision de semestre"
+ if etat == "D":
+ decision = "Démission"
+ else:
+ if decision_sem:
+ cod = decision_sem["code"]
+ decision = codes_cursus.CODES_EXPL.get(cod, "") # + ' (%s)' % cod
+ else:
+ decision = ""
+ return decision
+
+
+def _sum_ects_dicts(s, t):
+ """Somme deux dictionnaires { ue_code : ects },
+ quand une UE de même code apparait deux fois, prend celle avec le plus d'ECTS.
+ """
+ sum_ects = sum(s.values()) + sum(t.values())
+ for ue_code in set(s).intersection(set(t)):
+ sum_ects -= min(s[ue_code], t[ue_code])
+ return sum_ects
diff --git a/app/scodoc/sco_export_results.py b/app/scodoc/sco_export_results.py
index 1ad0f370..4d27ec1a 100644
--- a/app/scodoc/sco_export_results.py
+++ b/app/scodoc/sco_export_results.py
@@ -39,9 +39,8 @@ from app.models import Formation
from app.scodoc import html_sco_header
from app.scodoc import sco_bac
from app.scodoc import codes_cursus
-from app.scodoc import sco_formations
from app.scodoc import sco_preferences
-from app.scodoc import sco_pvjury
+from app.scodoc import sco_dict_pv_jury
from app.scodoc import sco_etud
import sco_version
from app.scodoc.gen_tables import GenTable
@@ -58,7 +57,7 @@ def _build_results_table(start_date=None, end_date=None, types_parcours=[]):
# Décisions de jury de tous les semestres:
dpv_by_sem = {}
for formsemestre_id in formsemestre_ids:
- dpv_by_sem[formsemestre_id] = sco_pvjury.dict_pvjury(
+ dpv_by_sem[formsemestre_id] = sco_dict_pv_jury.dict_pvjury(
formsemestre_id, with_parcours_decisions=True
)
@@ -349,7 +348,7 @@ end_date='2017-08-31'
formsemestre_ids = get_set_formsemestre_id_dates( start_date, end_date)
dpv_by_sem = {}
for formsemestre_id in formsemestre_ids:
- dpv_by_sem[formsemestre_id] = sco_pvjury.dict_pvjury( formsemestre_id, with_parcours_decisions=True)
+ dpv_by_sem[formsemestre_id] = sco_dict_pv_jury.dict_pvjury( formsemestre_id, with_parcours_decisions=True)
semlist = [ dpv['formsemestre'] for dpv in dpv_by_sem.values() ]
diff --git a/app/scodoc/sco_formsemestre_validation.py b/app/scodoc/sco_formsemestre_validation.py
index 15e67fa5..49ca5de0 100644
--- a/app/scodoc/sco_formsemestre_validation.py
+++ b/app/scodoc/sco_formsemestre_validation.py
@@ -64,7 +64,7 @@ from app.scodoc import sco_cursus_dut
from app.scodoc.sco_cursus_dut import etud_est_inscrit_ue
from app.scodoc import sco_photos
from app.scodoc import sco_preferences
-from app.scodoc import sco_pvjury
+from app.scodoc import sco_dict_pv_jury
# ------------------------------------------------------------------------------------
def formsemestre_validation_etud_form(
@@ -562,7 +562,7 @@ def formsemestre_recap_parcours_table(
is_cur = Se.formsemestre_id == sem["formsemestre_id"]
num_sem += 1
- dpv = sco_pvjury.dict_pvjury(sem["formsemestre_id"], etudids=[etudid])
+ dpv = sco_dict_pv_jury.dict_pvjury(sem["formsemestre_id"], etudids=[etudid])
pv = dpv["decisions"][0]
decision_sem = pv["decision_sem"]
decisions_ue = pv["decisions_ue"]
diff --git a/app/scodoc/sco_inscr_passage.py b/app/scodoc/sco_inscr_passage.py
index b26701f6..197b5169 100644
--- a/app/scodoc/sco_inscr_passage.py
+++ b/app/scodoc/sco_inscr_passage.py
@@ -47,7 +47,7 @@ from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_groups
from app.scodoc import sco_preferences
-from app.scodoc import sco_pvjury
+from app.scodoc import sco_dict_pv_jury
from app.scodoc.sco_exceptions import ScoValueError
@@ -137,7 +137,7 @@ def list_inscrits(formsemestre_id, with_dems=False):
def list_etuds_from_sem(src, dst) -> list[dict]:
"""Liste des etudiants du semestre src qui sont autorisés à passer dans le semestre dst."""
target = dst["semestre_id"]
- dpv = sco_pvjury.dict_pvjury(src["formsemestre_id"])
+ dpv = sco_dict_pv_jury.dict_pvjury(src["formsemestre_id"])
if not dpv:
return []
etuds = [
diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py
index d1bd0e0b..6ec676a4 100644
--- a/app/scodoc/sco_pvjury.py
+++ b/app/scodoc/sco_pvjury.py
@@ -47,7 +47,6 @@ Jury de semestre n
"""
import time
-from operator import itemgetter
from reportlab.platypus import Paragraph
from reportlab.lib import styles
@@ -55,25 +54,18 @@ import flask
from flask import flash, redirect, url_for
from flask import g, request
-from app.comp import res_sem
-from app.comp.res_compat import NotesTableCompat
from app.models import (
Formation,
FormSemestre,
- UniteEns,
ScolarAutorisationInscription,
- but_validations,
)
from app.models.etudiants import Identite
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
-from app import log
from app.scodoc import html_sco_header
from app.scodoc import codes_cursus
-from app.scodoc import sco_cursus
-from app.scodoc import sco_cursus_dut
-from app.scodoc import sco_edit_ue
+from app.scodoc import sco_dict_pv_jury
from app.scodoc import sco_etud
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
@@ -87,57 +79,6 @@ from app.scodoc.sco_pdf import PDFLOCK
from app.scodoc.TrivialFormulator import TrivialFormulator
-def _descr_decisions_ues(nt, etudid, decisions_ue, decision_sem) -> list[dict]:
- """Liste des UE validées dans ce semestre (incluant les UE capitalisées)"""
- if not decisions_ue:
- return []
- uelist = []
- # Les UE validées dans ce semestre:
- for ue_id in decisions_ue.keys():
- try:
- if decisions_ue[ue_id] and (
- codes_cursus.code_ue_validant(decisions_ue[ue_id]["code"])
- or (
- (not nt.is_apc)
- and (
- # XXX ceci devrait dépendre du parcours et non pas être une option ! #sco8
- decision_sem
- and scu.CONFIG.CAPITALIZE_ALL_UES
- and codes_cursus.code_semestre_validant(decision_sem["code"])
- )
- )
- ):
- ue = sco_edit_ue.ue_list(args={"ue_id": ue_id})[0]
- uelist.append(ue)
- except:
- log(
- f"Exception in descr_decisions_ues: ue_id={ue_id} decisions_ue={decisions_ue}"
- )
- # Les UE capitalisées dans d'autres semestres:
- if etudid in nt.validations.ue_capitalisees.index:
- for ue_id in nt.validations.ue_capitalisees.loc[[etudid]]["ue_id"]:
- try:
- uelist.append(nt.get_etud_ue_status(etudid, ue_id)["ue"])
- except (KeyError, TypeError):
- pass
- uelist.sort(key=itemgetter("numero"))
-
- return uelist
-
-
-def _descr_decision_sem(etat, decision_sem):
- "résumé textuel de la décision de semestre"
- if etat == "D":
- decision = "Démission"
- else:
- if decision_sem:
- cod = decision_sem["code"]
- decision = codes_cursus.CODES_EXPL.get(cod, "") # + ' (%s)' % cod
- else:
- decision = ""
- return decision
-
-
def _descr_decision_sem_abbrev(etat, decision_sem):
"résumé textuel tres court (code) de la décision de semestre"
if etat == "D":
@@ -150,230 +91,6 @@ def _descr_decision_sem_abbrev(etat, decision_sem):
return decision
-def descr_autorisations(autorisations: list[ScolarAutorisationInscription]) -> str:
- "résumé textuel des autorisations d'inscription (-> 'S1, S3' )"
- return ", ".join([f"S{a.semestre_id}" for a in autorisations])
-
-
-def _comp_ects_by_ue_code(nt, decision_ues):
- """Calcul somme des ECTS validés dans ce semestre (sans les UE capitalisées)
- decision_ues est le resultat de nt.get_etud_decision_ues
- Chaque resultat est un dict: { ue_code : ects }
- """
- if not decision_ues:
- return {}
-
- ects_by_ue_code = {}
- for ue_id in decision_ues:
- d = decision_ues[ue_id]
- ue = UniteEns.query.get(ue_id)
- ects_by_ue_code[ue.ue_code] = d["ects"]
-
- return ects_by_ue_code
-
-
-def _comp_ects_capitalises_by_ue_code(nt: NotesTableCompat, etudid: int):
- """Calcul somme des ECTS des UE capitalisees"""
- ues = nt.get_ues_stat_dict()
- ects_by_ue_code = {}
- for ue in ues:
- ue_status = nt.get_etud_ue_status(etudid, ue["ue_id"])
- if ue_status and ue_status["is_capitalized"]:
- ects_val = float(ue_status["ue"]["ects"] or 0.0)
- ects_by_ue_code[ue["ue_code"]] = ects_val
-
- return ects_by_ue_code
-
-
-def _sum_ects_dicts(s, t):
- """Somme deux dictionnaires { ue_code : ects },
- quand une UE de même code apparait deux fois, prend celle avec le plus d'ECTS.
- """
- sum_ects = sum(s.values()) + sum(t.values())
- for ue_code in set(s).intersection(set(t)):
- sum_ects -= min(s[ue_code], t[ue_code])
- return sum_ects
-
-
-def dict_pvjury(
- formsemestre_id,
- etudids=None,
- with_prev=False,
- with_parcours_decisions=False,
-):
- """Données pour édition jury
- etudids == None => tous les inscrits, sinon donne la liste des ids
- Si with_prev: ajoute infos sur code jury semestre precedent
- Si with_parcours_decisions: ajoute infos sur code decision jury de tous les semestre du parcours
- Résultat:
- {
- 'date' : date de la decision la plus recente,
- 'formsemestre' : sem,
- 'is_apc' : bool,
- 'formation' : { 'acronyme' :, 'titre': ... }
- 'decisions' : { [ { 'identite' : {'nom' :, 'prenom':, ...,},
- 'etat' : I ou D ou DEF
- 'decision_sem' : {'code':, 'code_prev': },
- 'decisions_ue' : { ue_id : { 'code' : ADM|CMP|AJ, 'event_date' :,
- 'acronyme', 'numero': } },
- 'autorisations' : [ { 'semestre_id' : { ... } } ],
- 'validation_parcours' : True si parcours validé (diplome obtenu)
- 'prev_code' : code (calculé slt si with_prev),
- 'mention' : mention (en fct moy gen),
- 'sum_ects' : total ECTS acquis dans ce semestre (incluant les UE capitalisées)
- 'sum_ects_capitalises' : somme des ECTS des UE capitalisees
- }
- ]
- },
- 'decisions_dict' : { etudid : decision (comme ci-dessus) },
- }
- """
- formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
- nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
- if etudids is None:
- etudids = nt.get_etudids()
- if not etudids:
- return {}
- cnx = ndb.GetDBConnexion()
- sem = sco_formsemestre.get_formsemestre(formsemestre_id)
- max_date = "0000-01-01"
- has_prev = False # vrai si au moins un etudiant a un code prev
- semestre_non_terminal = False # True si au moins un etudiant a un devenir
-
- decisions = []
- D = {} # même chose que decisions, mais { etudid : dec }
- for etudid in etudids:
- # etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
- etud: Identite = Identite.query.get(etudid)
- Se = sco_cursus.get_situation_etud_cursus(
- etud.to_dict_scodoc7(), formsemestre_id
- )
- semestre_non_terminal = semestre_non_terminal or Se.semestre_non_terminal
- d = {}
- d["identite"] = nt.identdict[etudid]
- d["etat"] = nt.get_etud_etat(
- etudid
- ) # I|D|DEF (inscription ou démission ou défaillant)
- d["decision_sem"] = nt.get_etud_decision_sem(etudid)
- d["decisions_ue"] = nt.get_etud_decision_ues(etudid)
- if formsemestre.formation.is_apc():
- d.update(but_validations.dict_decision_jury(etud, formsemestre))
- d["last_formsemestre_id"] = Se.get_semestres()[
- -1
- ] # id du dernier semestre (chronologiquement) dans lequel il a été inscrit
-
- ects_capitalises_by_ue_code = _comp_ects_capitalises_by_ue_code(nt, etudid)
- d["sum_ects_capitalises"] = sum(ects_capitalises_by_ue_code.values())
- ects_by_ue_code = _comp_ects_by_ue_code(nt, d["decisions_ue"])
- d["sum_ects"] = _sum_ects_dicts(ects_capitalises_by_ue_code, ects_by_ue_code)
-
- if d["decision_sem"] and codes_cursus.code_semestre_validant(
- d["decision_sem"]["code"]
- ):
- d["mention"] = scu.get_mention(nt.get_etud_moy_gen(etudid))
- else:
- d["mention"] = ""
- # Versions "en français": (avec les UE capitalisées d'ailleurs)
- dec_ue_list = _descr_decisions_ues(
- nt, etudid, d["decisions_ue"], d["decision_sem"]
- )
- d["decisions_ue_nb"] = len(
- dec_ue_list
- ) # avec les UE capitalisées, donc des éventuels doublons
- # Mais sur la description (eg sur les bulletins), on ne veut pas
- # afficher ces doublons: on uniquifie sur ue_code
- _codes = set()
- ue_uniq = []
- for ue in dec_ue_list:
- if ue["ue_code"] not in _codes:
- ue_uniq.append(ue)
- _codes.add(ue["ue_code"])
-
- d["decisions_ue_descr"] = ", ".join([ue["acronyme"] for ue in ue_uniq])
- if nt.is_apc:
- d["decision_sem_descr"] = "" # pas de validation de semestre en BUT
- else:
- d["decision_sem_descr"] = _descr_decision_sem(d["etat"], d["decision_sem"])
-
- autorisations = ScolarAutorisationInscription.query.filter_by(
- etudid=etudid, origin_formsemestre_id=formsemestre_id
- ).all()
- d["autorisations"] = [a.to_dict() for a in autorisations]
- d["autorisations_descr"] = descr_autorisations(autorisations)
-
- d["validation_parcours"] = Se.parcours_validated()
- d["parcours"] = Se.get_cursus_descr(filter_futur=True)
- if with_parcours_decisions:
- d["parcours_decisions"] = Se.get_parcours_decisions()
- # Observations sur les compensations:
- compensators = sco_cursus_dut.scolar_formsemestre_validation_list(
- cnx, args={"compense_formsemestre_id": formsemestre_id, "etudid": etudid}
- )
- obs = []
- for compensator in compensators:
- # nb: il ne devrait y en avoir qu'un !
- csem = sco_formsemestre.get_formsemestre(compensator["formsemestre_id"])
- obs.append(
- "%s compensé par %s (%s)"
- % (sem["sem_id_txt"], csem["sem_id_txt"], csem["anneescolaire"])
- )
-
- if d["decision_sem"] and d["decision_sem"]["compense_formsemestre_id"]:
- compensed = sco_formsemestre.get_formsemestre(
- d["decision_sem"]["compense_formsemestre_id"]
- )
- obs.append(
- f"""{sem["sem_id_txt"]} compense {compensed["sem_id_txt"]} ({compensed["anneescolaire"]})"""
- )
-
- d["observation"] = ", ".join(obs)
-
- # Cherche la date de decision (sem ou UE) la plus récente:
- if d["decision_sem"]:
- date = ndb.DateDMYtoISO(d["decision_sem"]["event_date"])
- if date and date > max_date: # decision plus recente
- max_date = date
- if d["decisions_ue"]:
- for dec_ue in d["decisions_ue"].values():
- if dec_ue:
- date = ndb.DateDMYtoISO(dec_ue["event_date"])
- if date and date > max_date: # decision plus recente
- max_date = date
- # Code semestre precedent
- if with_prev: # optionnel car un peu long...
- info = sco_etud.get_etud_info(etudid=etudid, filled=True)
- if not info:
- continue # should not occur
- etud = info[0]
- if Se.prev and Se.prev_decision:
- d["prev_decision_sem"] = Se.prev_decision
- d["prev_code"] = Se.prev_decision["code"]
- d["prev_code_descr"] = _descr_decision_sem(
- scu.INSCRIT, Se.prev_decision
- )
- d["prev"] = Se.prev
- has_prev = True
- else:
- d["prev_decision_sem"] = None
- d["prev_code"] = ""
- d["prev_code_descr"] = ""
- d["Se"] = Se
-
- decisions.append(d)
- D[etudid] = d
-
- return {
- "date": ndb.DateISOtoDMY(max_date),
- "formsemestre": sem,
- "is_apc": nt.is_apc,
- "has_prev": has_prev,
- "semestre_non_terminal": semestre_non_terminal,
- "formation": Formation.query.get_or_404(sem["formation_id"]).to_dict(),
- "decisions": decisions,
- "decisions_dict": D,
- }
-
-
def pvjury_table(
dpv,
only_diplome=False,
@@ -420,7 +137,7 @@ def pvjury_table(
if dpv["has_prev"]:
id_prev = sem["semestre_id"] - 1 # numero du semestre precedent
- titles["prev_decision"] = "Décision S%s" % id_prev
+ titles["prev_decision"] = f"Décision S{id_prev}"
columns_ids += ["prev_decision"]
if not dpv["is_apc"]:
@@ -528,7 +245,7 @@ def formsemestre_pvjury(formsemestre_id, format="html", publish=True): # XXX
footer = html_sco_header.sco_footer()
- dpv = dict_pvjury(formsemestre_id, with_prev=True)
+ dpv = sco_dict_pv_jury.dict_pvjury(formsemestre_id, with_prev=True)
if not dpv:
if format == "html":
return (
@@ -628,7 +345,7 @@ def formsemestre_pvjury_pdf(formsemestre_id, group_ids: list[int] = None, etudid
Si etudid, PV pour un seul etudiant. Sinon, tout les inscrits au groupe indiqué.
"""
group_ids = group_ids or []
- sem = sco_formsemestre.get_formsemestre(formsemestre_id)
+ formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
# Mise à jour des groupes d'étapes:
sco_groups.create_etapes_partition(formsemestre_id)
groups_infos = None
@@ -671,7 +388,7 @@ def formsemestre_pvjury_pdf(formsemestre_id, group_ids: list[int] = None, etudid