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
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2024-02-25 16:58:59 +01:00
|
|
|
"""Génération du bulletin en format JSON (formations classiques)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
"""
|
2021-02-01 16:23:11 +01:00
|
|
|
import datetime
|
2020-09-26 16:19:37 +02:00
|
|
|
import json
|
|
|
|
|
2022-08-08 10:34:13 +02:00
|
|
|
from flask import abort
|
|
|
|
|
2023-07-11 06:57:38 +02:00
|
|
|
from app import db, ScoDocJSONEncoder
|
2022-02-09 23:22:00 +01:00
|
|
|
from app.comp import res_sem
|
2022-03-27 22:25:00 +02:00
|
|
|
from app.comp.res_compat import NotesTableCompat
|
2024-10-10 00:41:20 +02:00
|
|
|
from app.formations import edit_ue
|
2022-07-08 18:09:45 +02:00
|
|
|
from app.models import but_validations
|
2023-08-29 11:27:24 +02:00
|
|
|
from app.models import BulAppreciations, Evaluation, Matiere, UniteEns
|
2021-12-17 21:36:34 +01:00
|
|
|
from app.models.etudiants import Identite
|
2022-07-08 18:09:45 +02:00
|
|
|
from app.models.formsemestre import FormSemestre
|
2021-12-12 15:55:04 +01:00
|
|
|
|
2021-06-19 23:21:37 +02:00
|
|
|
import app.scodoc.sco_utils as scu
|
|
|
|
import app.scodoc.notesdb as ndb
|
2023-06-30 15:34:50 +02:00
|
|
|
from app.scodoc import sco_assiduites
|
2022-11-22 13:13:16 +01:00
|
|
|
from app.scodoc import sco_evaluations
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_formsemestre
|
|
|
|
from app.scodoc import sco_groups
|
|
|
|
from app.scodoc import sco_photos
|
|
|
|
from app.scodoc import sco_preferences
|
|
|
|
from app.scodoc import sco_etud
|
2022-11-26 00:02:30 +01:00
|
|
|
from app.scodoc.sco_preferences import SemPreferences
|
2022-11-13 14:55:18 +01:00
|
|
|
from app.scodoc.sco_xml import quote_xml_attr
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# -------- Bulletin en JSON
|
|
|
|
|
|
|
|
|
|
|
|
def make_json_formsemestre_bulletinetud(
|
2021-09-18 13:42:19 +02:00
|
|
|
formsemestre_id: int,
|
|
|
|
etudid: int,
|
2020-09-26 16:19:37 +02:00
|
|
|
xml_with_decisions=False,
|
|
|
|
version="long",
|
|
|
|
force_publishing=False, # force publication meme si semestre non publie sur "portail"
|
2021-09-18 13:42:19 +02:00
|
|
|
) -> str:
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Renvoie bulletin en chaine JSON"""
|
|
|
|
|
|
|
|
d = formsemestre_bulletinetud_published_dict(
|
|
|
|
formsemestre_id,
|
|
|
|
etudid,
|
|
|
|
force_publishing=force_publishing,
|
|
|
|
xml_with_decisions=xml_with_decisions,
|
|
|
|
version=version,
|
|
|
|
)
|
|
|
|
|
2023-04-04 09:57:54 +02:00
|
|
|
return json.dumps(d, cls=ScoDocJSONEncoder)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
# (fonction séparée: n'utilise pas formsemestre_bulletinetud_dict()
|
|
|
|
# pour simplifier le code, mais attention a la maintenance !)
|
|
|
|
#
|
|
|
|
def formsemestre_bulletinetud_published_dict(
|
|
|
|
formsemestre_id,
|
|
|
|
etudid,
|
|
|
|
force_publishing=False,
|
|
|
|
xml_nodate=False,
|
2023-10-13 22:25:44 +02:00
|
|
|
xml_with_decisions=False, # inclure les décisions même si non publiées
|
2020-09-26 16:19:37 +02:00
|
|
|
version="long",
|
2022-11-22 13:13:16 +01:00
|
|
|
) -> dict:
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Dictionnaire representant les informations _publiees_ du bulletin de notes
|
2024-03-24 15:47:42 +01:00
|
|
|
Utilisé pour JSON des formations classiques (mais pas pour le XML, qui est deprecated).
|
2022-11-26 00:02:30 +01:00
|
|
|
|
|
|
|
version:
|
|
|
|
short (sans les évaluations)
|
|
|
|
long (avec les évaluations)
|
|
|
|
|
2023-10-13 22:25:44 +02:00
|
|
|
# non implémenté: short_mat (sans évaluations, et structuration en matières)
|
|
|
|
# long_mat (avec évaluations, et structuration en matières)
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_bulletins
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-11-26 00:02:30 +01:00
|
|
|
with_matieres = False
|
|
|
|
if version.endswith("_mat"):
|
|
|
|
version = version[:-4] # enlève le "_mat"
|
|
|
|
with_matieres = True
|
|
|
|
|
2023-03-20 11:17:38 +01:00
|
|
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
2022-11-22 13:13:16 +01:00
|
|
|
prefs = sco_preferences.SemPreferences(formsemestre_id)
|
2023-03-20 11:17:38 +01:00
|
|
|
etud = Identite.get_etud(etudid)
|
2021-12-12 15:55:04 +01:00
|
|
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
|
|
|
|
2022-02-09 23:22:00 +01:00
|
|
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
2023-08-23 01:42:03 +02:00
|
|
|
if etudid not in nt.identdict:
|
2022-08-08 10:34:13 +02:00
|
|
|
abort(404, "etudiant non inscrit dans ce semestre")
|
2022-05-03 12:50:43 +02:00
|
|
|
d = {"type": "classic", "version": "0"}
|
2024-03-19 18:22:02 +01:00
|
|
|
|
|
|
|
published = (not formsemestre.bul_hide_xml) or force_publishing
|
2020-09-26 16:19:37 +02:00
|
|
|
if xml_nodate:
|
|
|
|
docdate = ""
|
|
|
|
else:
|
|
|
|
docdate = datetime.datetime.now().isoformat()
|
|
|
|
|
|
|
|
el = {
|
|
|
|
"etudid": etudid,
|
|
|
|
"formsemestre_id": formsemestre_id,
|
|
|
|
"date": docdate,
|
|
|
|
"publie": published,
|
|
|
|
"etapes": sem["etapes"],
|
|
|
|
}
|
|
|
|
# backward compat:
|
|
|
|
if sem["etapes"]:
|
|
|
|
el["etape_apo"] = sem["etapes"][0] or ""
|
|
|
|
n = 2
|
|
|
|
for et in sem["etapes"][1:]:
|
|
|
|
el["etape_apo" + str(n)] = et or ""
|
|
|
|
n += 1
|
|
|
|
d.update(**el)
|
|
|
|
|
|
|
|
# Infos sur l'etudiant
|
2021-08-22 13:24:36 +02:00
|
|
|
etudinfo = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
d["etudiant"] = dict(
|
|
|
|
etudid=etudid,
|
|
|
|
code_nip=etudinfo["code_nip"],
|
|
|
|
code_ine=etudinfo["code_ine"],
|
2022-11-13 14:55:18 +01:00
|
|
|
nom=quote_xml_attr(etudinfo["nom"]),
|
|
|
|
prenom=quote_xml_attr(etudinfo["prenom"]),
|
|
|
|
civilite=quote_xml_attr(etudinfo["civilite_str"]),
|
|
|
|
photo_url=quote_xml_attr(sco_photos.etud_photo_url(etudinfo, fast=True)),
|
|
|
|
email=quote_xml_attr(etudinfo["email"]),
|
|
|
|
emailperso=quote_xml_attr(etudinfo["emailperso"]),
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2021-02-13 17:28:55 +01:00
|
|
|
d["etudiant"]["sexe"] = d["etudiant"]["civilite"] # backward compat for our clients
|
2020-09-26 16:19:37 +02:00
|
|
|
# Disponible pour publication ?
|
2022-07-05 20:40:21 +02:00
|
|
|
d["publie"] = published
|
2020-09-26 16:19:37 +02:00
|
|
|
if not published:
|
|
|
|
return d # stop !
|
|
|
|
|
2022-03-06 22:40:20 +01:00
|
|
|
etat_inscription = etud.inscription_etat(formsemestre.id)
|
2021-12-17 21:36:34 +01:00
|
|
|
if etat_inscription != scu.INSCRIT:
|
2022-07-08 18:09:45 +02:00
|
|
|
d.update(dict_decision_jury(etud, formsemestre, with_decisions=True))
|
2021-12-17 21:36:34 +01:00
|
|
|
return d
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
# Groupes:
|
2021-08-19 10:28:35 +02:00
|
|
|
partitions = sco_groups.get_partitions_list(formsemestre_id, with_default=False)
|
2020-09-26 16:19:37 +02:00
|
|
|
partitions_etud_groups = {} # { partition_id : { etudid : group } }
|
|
|
|
for partition in partitions:
|
|
|
|
pid = partition["partition_id"]
|
2021-08-19 10:28:35 +02:00
|
|
|
partitions_etud_groups[pid] = sco_groups.get_etud_groups_in_partition(pid)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2024-03-24 15:47:42 +01:00
|
|
|
# Il serait préférable de factoriser et d'avoir la même section
|
|
|
|
# "semestre" que celle des bulletins BUT.
|
|
|
|
etud_groups = sco_groups.get_etud_formsemestre_groups(
|
|
|
|
etud, formsemestre, only_to_show=True
|
|
|
|
)
|
|
|
|
d["semestre"] = {
|
|
|
|
"etapes": [str(x.etape_apo) for x in formsemestre.etapes if x.etape_apo],
|
|
|
|
"date_debut": formsemestre.date_debut.isoformat(),
|
|
|
|
"date_fin": formsemestre.date_fin.isoformat(),
|
|
|
|
"annee_universitaire": formsemestre.annee_scolaire_str(),
|
|
|
|
"numero": formsemestre.semestre_id,
|
|
|
|
"inscription": "", # inutilisé mais nécessaire pour le js de Seb.
|
|
|
|
"groupes": [group.to_dict() for group in etud_groups],
|
|
|
|
}
|
|
|
|
|
2022-12-02 15:57:25 +01:00
|
|
|
ues_stat = nt.get_ues_stat_dict()
|
2021-12-26 19:15:47 +01:00
|
|
|
modimpls = nt.get_modimpls_dict()
|
2021-12-24 00:08:25 +01:00
|
|
|
nbetuds = len(nt.etud_moy_gen_ranks)
|
2022-11-22 13:13:16 +01:00
|
|
|
moy_gen = scu.fmt_note(nt.get_etud_moy_gen(etudid))
|
|
|
|
if nt.get_moduleimpls_attente() or not prefs["bul_show_rangs"]:
|
2020-09-26 16:19:37 +02:00
|
|
|
# n'affiche pas le rang sur le bulletin s'il y a des
|
|
|
|
# notes en attente dans ce semestre
|
|
|
|
rang = ""
|
|
|
|
rang_gr = {}
|
|
|
|
ninscrits_gr = {}
|
|
|
|
else:
|
|
|
|
rang = str(nt.get_etud_rang(etudid))
|
|
|
|
rang_gr, ninscrits_gr, gr_name = sco_bulletins.get_etud_rangs_groups(
|
2022-05-18 20:43:01 +02:00
|
|
|
etudid, partitions, partitions_etud_groups, nt
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
d["note"] = dict(
|
2022-11-22 13:13:16 +01:00
|
|
|
value=moy_gen,
|
2021-02-01 16:23:11 +01:00
|
|
|
min=scu.fmt_note(nt.moy_min),
|
|
|
|
max=scu.fmt_note(nt.moy_max),
|
|
|
|
moy=scu.fmt_note(nt.moy_moy),
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
d["rang"] = dict(value=rang, ninscrits=nbetuds)
|
|
|
|
d["rang_group"] = []
|
|
|
|
if rang_gr:
|
|
|
|
for partition in partitions:
|
|
|
|
d["rang_group"].append(
|
|
|
|
dict(
|
|
|
|
group_type=partition["partition_name"],
|
|
|
|
group_name=gr_name[partition["partition_id"]],
|
|
|
|
value=rang_gr[partition["partition_id"]],
|
|
|
|
ninscrits=ninscrits_gr[partition["partition_id"]],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
d["note_max"] = dict(value=20) # notes toujours sur 20
|
2022-01-25 10:45:13 +01:00
|
|
|
d["bonus_sport_culture"] = dict(
|
|
|
|
value=nt.bonus[etudid] if nt.bonus is not None else 0.0
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Liste les UE / modules /evals
|
|
|
|
d["ue"] = []
|
|
|
|
d["ue_capitalisee"] = []
|
2022-12-02 15:57:25 +01:00
|
|
|
for ue_st in ues_stat:
|
2022-12-05 21:59:10 +01:00
|
|
|
ue_id = ue_st["ue_id"]
|
|
|
|
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
2022-12-02 15:57:25 +01:00
|
|
|
if ue_st["ects"] is None:
|
2020-09-26 16:19:37 +02:00
|
|
|
ects_txt = ""
|
2021-08-30 16:43:18 +02:00
|
|
|
else:
|
2022-12-02 15:57:25 +01:00
|
|
|
ects_txt = f"{ue_st['ects']:2.3g}"
|
2022-12-05 21:59:10 +01:00
|
|
|
rang, effectif = nt.get_etud_ue_rang(ue_id, etudid)
|
2020-09-26 16:19:37 +02:00
|
|
|
u = dict(
|
2022-12-05 21:59:10 +01:00
|
|
|
id=ue_id,
|
2022-12-02 15:57:25 +01:00
|
|
|
numero=quote_xml_attr(ue_st["numero"]),
|
|
|
|
acronyme=quote_xml_attr(ue_st["acronyme"]),
|
|
|
|
titre=quote_xml_attr(ue_st["titre"]),
|
2020-09-26 16:19:37 +02:00
|
|
|
note=dict(
|
2022-02-12 22:57:46 +01:00
|
|
|
value=scu.fmt_note(ue_status["cur_moy_ue"] if ue_status else ""),
|
2022-12-02 15:57:25 +01:00
|
|
|
min=scu.fmt_note(ue_st["min"]),
|
|
|
|
max=scu.fmt_note(ue_st["max"]),
|
|
|
|
moy=scu.fmt_note(ue_st["moy"]),
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
2022-02-09 23:22:00 +01:00
|
|
|
rang=rang,
|
|
|
|
effectif=effectif,
|
2020-09-26 16:19:37 +02:00
|
|
|
ects=ects_txt,
|
2022-12-02 15:57:25 +01:00
|
|
|
code_apogee=quote_xml_attr(ue_st["code_apogee"]),
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
d["ue"].append(u)
|
2022-11-26 00:02:30 +01:00
|
|
|
|
|
|
|
if with_matieres:
|
|
|
|
u["module"] = []
|
|
|
|
# Structure UE/Matière/Module
|
|
|
|
# Recodé en 2022
|
2023-07-11 06:57:38 +02:00
|
|
|
ue = db.session.get(UniteEns, ue_id)
|
2022-11-26 00:02:30 +01:00
|
|
|
u["matiere"] = [
|
|
|
|
{
|
|
|
|
"matiere_id": mat.id,
|
|
|
|
"note": scu.fmt_note(nt.get_etud_mat_moy(mat.id, etudid)),
|
|
|
|
"titre": mat.titre,
|
|
|
|
"module": _list_modimpls(
|
|
|
|
nt,
|
|
|
|
etudid,
|
|
|
|
[
|
|
|
|
mod
|
|
|
|
for mod in modimpls
|
|
|
|
if mod["module"]["matiere_id"] == mat.id
|
|
|
|
],
|
|
|
|
prefs,
|
|
|
|
version,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
for mat in ue.matieres.order_by(Matiere.numero)
|
|
|
|
]
|
|
|
|
|
|
|
|
else:
|
|
|
|
# Liste les modules de l'UE
|
|
|
|
u["module"] = _list_modimpls(
|
|
|
|
nt,
|
|
|
|
etudid,
|
2022-12-05 21:59:10 +01:00
|
|
|
[mod for mod in modimpls if mod["module"]["ue_id"] == ue_id],
|
2022-11-26 00:02:30 +01:00
|
|
|
prefs,
|
|
|
|
version,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
2022-12-02 15:57:25 +01:00
|
|
|
# UE capitalisée (listée seulement si meilleure que l'UE courante)
|
2020-09-26 16:19:37 +02:00
|
|
|
if ue_status["is_capitalized"]:
|
|
|
|
try:
|
2022-12-17 14:09:55 +01:00
|
|
|
ects_txt = str(int(ue_status["ue"].get("ects", "") or 0.0))
|
2022-12-02 15:57:25 +01:00
|
|
|
except ValueError:
|
2020-09-26 16:19:37 +02:00
|
|
|
ects_txt = ""
|
|
|
|
d["ue_capitalisee"].append(
|
|
|
|
dict(
|
2022-12-05 21:59:10 +01:00
|
|
|
id=ue_id,
|
2022-12-06 13:06:50 +01:00
|
|
|
numero=quote_xml_attr(ue_st["numero"]),
|
|
|
|
acronyme=quote_xml_attr(ue_st["acronyme"]),
|
|
|
|
titre=quote_xml_attr(ue_st["titre"]),
|
2021-02-01 16:23:11 +01:00
|
|
|
note=scu.fmt_note(ue_status["moy"]),
|
|
|
|
coefficient_ue=scu.fmt_note(ue_status["coef_ue"]),
|
|
|
|
date_capitalisation=ndb.DateDMYtoISO(ue_status["event_date"]),
|
2020-09-26 16:19:37 +02:00
|
|
|
ects=ects_txt,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Absences
|
2022-11-22 13:13:16 +01:00
|
|
|
if prefs["bul_show_abs"]:
|
2024-03-01 12:40:05 +01:00
|
|
|
_, nbabsjust, nbabs = sco_assiduites.get_assiduites_count(etudid, sem)
|
2020-09-26 16:19:37 +02:00
|
|
|
d["absences"] = dict(nbabs=nbabs, nbabsjust=nbabsjust)
|
|
|
|
|
2022-11-26 00:02:30 +01:00
|
|
|
# --- Décision Jury
|
2022-07-08 18:09:45 +02:00
|
|
|
d.update(dict_decision_jury(etud, formsemestre, with_decisions=xml_with_decisions))
|
2022-11-26 00:02:30 +01:00
|
|
|
|
|
|
|
# --- Appréciations
|
2023-08-29 11:27:24 +02:00
|
|
|
appreciations = BulAppreciations.get_appreciations_list(formsemestre.id, etudid)
|
|
|
|
d["appreciation"] = [
|
|
|
|
{
|
2023-09-03 19:23:00 +02:00
|
|
|
"comment": quote_xml_attr(appreciation.comment),
|
2023-08-29 11:27:24 +02:00
|
|
|
"date": appreciation.date.isoformat() if appreciation.date else "",
|
|
|
|
}
|
|
|
|
for appreciation in appreciations
|
|
|
|
]
|
2021-12-17 00:25:45 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
2022-11-26 00:02:30 +01:00
|
|
|
def _list_modimpls(
|
|
|
|
nt: NotesTableCompat,
|
|
|
|
etudid: int,
|
2023-08-22 17:02:00 +02:00
|
|
|
modimpls: list[dict],
|
2022-11-26 00:02:30 +01:00
|
|
|
prefs: SemPreferences,
|
|
|
|
version: str,
|
|
|
|
) -> list[dict]:
|
|
|
|
modules_dict = []
|
|
|
|
for modimpl in modimpls:
|
|
|
|
mod_moy = scu.fmt_note(nt.get_etud_mod_moy(modimpl["moduleimpl_id"], etudid))
|
|
|
|
if mod_moy == "NI": # ne mentionne pas les modules ou n'est pas inscrit
|
|
|
|
continue
|
2023-08-25 17:58:57 +02:00
|
|
|
modimpl_results = nt.modimpls_results.get(modimpl["moduleimpl_id"])
|
2022-11-26 00:02:30 +01:00
|
|
|
mod = modimpl["module"]
|
|
|
|
# if mod['ects'] is None:
|
|
|
|
# ects = ''
|
|
|
|
# else:
|
|
|
|
# ects = str(mod['ects'])
|
|
|
|
modstat = nt.get_mod_stats(modimpl["moduleimpl_id"])
|
|
|
|
|
|
|
|
mod_dict = dict(
|
|
|
|
id=modimpl["moduleimpl_id"],
|
|
|
|
code=mod["code"],
|
|
|
|
coefficient=mod["coefficient"],
|
|
|
|
numero=mod["numero"],
|
|
|
|
titre=quote_xml_attr(mod["titre"]),
|
|
|
|
abbrev=quote_xml_attr(mod["abbrev"]),
|
|
|
|
# ects=ects, ects des modules maintenant inutilisés
|
|
|
|
note=dict(value=mod_moy),
|
|
|
|
code_apogee=quote_xml_attr(mod["code_apogee"]),
|
|
|
|
matiere_id=mod["matiere_id"],
|
|
|
|
)
|
|
|
|
mod_dict["note"].update(modstat)
|
|
|
|
for k in ("min", "max", "moy"): # formatte toutes les notes
|
|
|
|
mod_dict["note"][k] = scu.fmt_note(mod_dict["note"][k])
|
|
|
|
|
|
|
|
if prefs["bul_show_mod_rangs"] and nt.mod_rangs is not None:
|
|
|
|
mod_dict["rang"] = dict(
|
|
|
|
value=nt.mod_rangs[modimpl["moduleimpl_id"]][0][etudid]
|
|
|
|
)
|
|
|
|
mod_dict["effectif"] = dict(value=nt.mod_rangs[modimpl["moduleimpl_id"]][1])
|
|
|
|
|
|
|
|
# --- notes de chaque eval:
|
2023-08-25 17:58:57 +02:00
|
|
|
evaluations_completes = nt.get_modimpl_evaluations_completes(
|
|
|
|
modimpl["moduleimpl_id"]
|
|
|
|
)
|
2022-11-26 00:02:30 +01:00
|
|
|
mod_dict["evaluation"] = []
|
|
|
|
if version != "short":
|
2023-08-25 17:58:57 +02:00
|
|
|
for e in evaluations_completes:
|
|
|
|
if e.visibulletin or version == "long":
|
|
|
|
# Note à l'évaluation:
|
|
|
|
val = modimpl_results.evals_notes[e.id].get(etudid, "NP")
|
2022-11-26 00:02:30 +01:00
|
|
|
# nb: val est NA si etud démissionnaire
|
2023-08-25 17:58:57 +02:00
|
|
|
e_dict = e.to_dict_bul()
|
|
|
|
e_dict["note"] = scu.fmt_note(val, note_max=e.note_max)
|
|
|
|
|
2022-11-26 00:02:30 +01:00
|
|
|
if prefs["bul_show_minmax_eval"] or prefs["bul_show_moypromo"]:
|
2023-08-25 17:58:57 +02:00
|
|
|
# XXX à revoir pour utiliser modimplresult
|
|
|
|
etat = sco_evaluations.do_evaluation_etat(e.id)
|
2022-11-26 00:02:30 +01:00
|
|
|
if prefs["bul_show_minmax_eval"]:
|
2023-08-25 17:58:57 +02:00
|
|
|
e_dict["min"] = etat["mini"] # chaine, sur 20
|
|
|
|
e_dict["max"] = etat["maxi"]
|
2022-11-26 00:02:30 +01:00
|
|
|
if prefs["bul_show_moypromo"]:
|
2023-08-25 17:58:57 +02:00
|
|
|
e_dict["moy"] = etat["moy"]
|
2022-11-26 00:02:30 +01:00
|
|
|
|
2023-08-25 17:58:57 +02:00
|
|
|
mod_dict["evaluation"].append(e_dict)
|
2022-11-26 00:02:30 +01:00
|
|
|
|
|
|
|
# Evaluations incomplètes ou futures:
|
2023-08-25 17:58:57 +02:00
|
|
|
complete_eval_ids = {e.id for e in evaluations_completes}
|
2022-11-26 00:02:30 +01:00
|
|
|
if prefs["bul_show_all_evals"]:
|
2023-08-25 17:58:57 +02:00
|
|
|
evaluations: list[Evaluation] = Evaluation.query.filter_by(
|
2023-08-22 17:02:00 +02:00
|
|
|
moduleimpl_id=modimpl["moduleimpl_id"]
|
|
|
|
).order_by(Evaluation.date_debut)
|
|
|
|
# plus ancienne d'abord
|
|
|
|
for e in evaluations:
|
|
|
|
if e.id not in complete_eval_ids:
|
2023-08-25 17:58:57 +02:00
|
|
|
e_dict = e.to_dict_bul()
|
|
|
|
e_dict["incomplete"] = 1
|
|
|
|
mod_dict["evaluation"].append(e_dict)
|
2022-11-26 00:02:30 +01:00
|
|
|
modules_dict.append(mod_dict)
|
|
|
|
return modules_dict
|
|
|
|
|
|
|
|
|
2022-07-08 18:09:45 +02:00
|
|
|
def dict_decision_jury(
|
|
|
|
etud: Identite, formsemestre: FormSemestre, with_decisions: bool = False
|
|
|
|
) -> dict:
|
2022-07-05 20:40:21 +02:00
|
|
|
"""dict avec decision pour bulletins json
|
2023-08-02 00:13:31 +02:00
|
|
|
- autorisation_inscription
|
2022-07-05 20:40:21 +02:00
|
|
|
- decision : décision semestre
|
2023-09-05 22:50:01 +02:00
|
|
|
- decision_annee : annee BUT
|
2022-07-05 20:40:21 +02:00
|
|
|
- decision_ue : list des décisions UE
|
|
|
|
- situation
|
|
|
|
|
|
|
|
with_decision donne les décision même si bul_show_decision est faux.
|
|
|
|
|
2022-07-08 18:09:45 +02:00
|
|
|
Si formation APC, indique aussi validations année et RCUEs
|
|
|
|
|
2022-07-05 20:40:21 +02:00
|
|
|
Exemple:
|
|
|
|
{
|
|
|
|
'autorisation_inscription': [{'semestre_id': 4}],
|
|
|
|
'decision': {'code': 'ADM',
|
|
|
|
'compense_formsemestre_id': None,
|
|
|
|
'date': '2022-01-21',
|
|
|
|
'etat': 'I'},
|
|
|
|
'decision_ue': [
|
|
|
|
{
|
|
|
|
'acronyme': 'UE31',
|
|
|
|
'code': 'ADM',
|
|
|
|
'ects': 16.0,
|
|
|
|
'numero': 23,
|
|
|
|
'titre': 'Approfondissement métiers',
|
|
|
|
'ue_id': 1787
|
|
|
|
},
|
|
|
|
...
|
|
|
|
],
|
|
|
|
'situation': 'Inscrit le 25/06/2021. Décision jury: Validé. UE acquises: '
|
2024-07-05 17:11:21 +02:00
|
|
|
'UE31, UE32. Diplôme obtenu.',
|
|
|
|
'diplomation' : 'Diplôme obtenu.' # (ou vide)
|
2024-07-07 22:07:27 +02:00
|
|
|
|
2024-07-05 17:11:21 +02:00
|
|
|
}
|
2022-07-05 20:40:21 +02:00
|
|
|
"""
|
2021-12-17 00:25:45 +01:00
|
|
|
from app.scodoc import sco_bulletins
|
|
|
|
|
2022-11-22 13:13:16 +01:00
|
|
|
prefs = sco_preferences.SemPreferences(formsemestre.id)
|
|
|
|
|
2021-12-17 00:25:45 +01:00
|
|
|
d = {}
|
2022-11-22 13:13:16 +01:00
|
|
|
if prefs["bul_show_decision"] or with_decisions:
|
2020-09-26 16:19:37 +02:00
|
|
|
infos, dpv = sco_bulletins.etud_descr_situation_semestre(
|
2022-07-08 18:09:45 +02:00
|
|
|
etud.id,
|
2023-03-08 22:56:11 +01:00
|
|
|
formsemestre,
|
2022-11-22 13:13:16 +01:00
|
|
|
show_uevalid=prefs["bul_show_uevalid"],
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2024-07-05 17:11:21 +02:00
|
|
|
d["diplomation"] = infos["diplomation"]
|
2024-07-07 22:07:27 +02:00
|
|
|
d["situation"] = infos["situation"]
|
|
|
|
d["diplome_dut120"] = infos["diplome_dut120"]
|
|
|
|
d["diplome_dut120_descr"] = infos["diplome_dut120_descr"]
|
2020-09-26 16:19:37 +02:00
|
|
|
if dpv:
|
|
|
|
decision = dpv["decisions"][0]
|
|
|
|
etat = decision["etat"]
|
|
|
|
if decision["decision_sem"]:
|
|
|
|
code = decision["decision_sem"]["code"]
|
2021-12-17 00:39:06 +01:00
|
|
|
date = ndb.DateDMYtoISO(
|
|
|
|
dpv["decisions"][0]["decision_sem"]["event_date"]
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
code = ""
|
2021-12-17 00:39:06 +01:00
|
|
|
date = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-12-17 00:25:45 +01:00
|
|
|
d["decision"] = dict(
|
|
|
|
code=code,
|
|
|
|
etat=etat,
|
2021-12-17 00:39:06 +01:00
|
|
|
date=date,
|
2021-12-17 00:25:45 +01:00
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
if (
|
|
|
|
decision["decision_sem"]
|
|
|
|
and "compense_formsemestre_id" in decision["decision_sem"]
|
|
|
|
):
|
|
|
|
d["decision"]["compense_formsemestre_id"] = decision["decision_sem"][
|
|
|
|
"compense_formsemestre_id"
|
|
|
|
]
|
|
|
|
|
|
|
|
d["decision_ue"] = []
|
|
|
|
if decision[
|
|
|
|
"decisions_ue"
|
2021-07-28 17:03:54 +02:00
|
|
|
]: # and sco_preferences.get_preference( 'bul_show_uevalid', formsemestre_id): always publish (car utile pour export Apogee)
|
2020-09-26 16:19:37 +02:00
|
|
|
for ue_id in decision["decisions_ue"].keys():
|
2024-10-10 00:41:20 +02:00
|
|
|
ue = edit_ue.ue_list({"ue_id": ue_id})[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
d["decision_ue"].append(
|
|
|
|
dict(
|
|
|
|
ue_id=ue["ue_id"],
|
2021-12-17 00:25:45 +01:00
|
|
|
numero=ue["numero"],
|
|
|
|
acronyme=ue["acronyme"],
|
|
|
|
titre=ue["titre"],
|
2020-09-26 16:19:37 +02:00
|
|
|
code=decision["decisions_ue"][ue_id]["code"],
|
2021-12-17 00:25:45 +01:00
|
|
|
ects=ue["ects"] or "",
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
d["autorisation_inscription"] = []
|
|
|
|
for aut in decision["autorisations"]:
|
|
|
|
d["autorisation_inscription"].append(
|
2023-08-02 00:13:31 +02:00
|
|
|
dict(
|
|
|
|
semestre_id=aut["semestre_id"],
|
|
|
|
date=aut["date"].isoformat() if aut["date"] else None,
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
d["decision"] = dict(code="", etat="DEM")
|
2022-07-08 18:09:45 +02:00
|
|
|
# Ajout jury BUT:
|
|
|
|
if formsemestre.formation.is_apc():
|
|
|
|
d.update(but_validations.dict_decision_jury(etud, formsemestre))
|
2020-09-26 16:19:37 +02:00
|
|
|
return d
|