1
0
forked from ScoDoc/ScoDoc

Bulletins BUT JSON: décisions de jury et situation

This commit is contained in:
Emmanuel Viennet 2021-12-17 00:25:45 +01:00
parent 78c7c1a763
commit b153c9ad9e
2 changed files with 44 additions and 31 deletions

View File

@ -16,7 +16,7 @@ from app.comp import moy_ue, moy_sem, inscr_mod
from app.models import ModuleImpl
from app.scodoc import sco_utils as scu
from app.scodoc.sco_cache import ResultatsSemestreBUTCache
from app.scodoc.sco_exceptions import ScoFormatError
from app.scodoc import sco_bulletins_json
from app.scodoc import sco_preferences
from app.scodoc.sco_utils import jsnan, fmt_note
@ -237,23 +237,21 @@ class ResultatsSemestreBUT:
"options": bulletin_option_affichage(formsemestre),
}
semestre_infos = {
"etapes": { # XXX TODO
# à spécifier: liste des étapes Apogée
},
"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": self.formsemestre.annee_scolaire_str(),
"inscription": "TODO-MM-JJ", # XXX TODO
"numero": formsemestre.semestre_id,
"decision": None, # XXX TODO
"situation": "non disponible", # "Décision jury: Validé. Diplôme obtenu.", # XXX TODO
"date_jury": "AAAA-MM-JJ", # XXX TODO
"groupes": [], # XXX TODO
"absences": { # XXX TODO
"injustifie": 1,
"total": 33,
},
}
semestre_infos.update(
sco_bulletins_json.dict_decision_jury(etud.id, formsemestre.id)
)
if etat_inscription == scu.INSCRIT:
semestre_infos.update(
{

View File

@ -334,19 +334,44 @@ def formsemestre_bulletinetud_published_dict(
d["absences"] = dict(nbabs=nbabs, nbabsjust=nbabsjust)
# --- Decision Jury
d.update(
dict_decision_jury(etudid, formsemestre_id, with_decisions=xml_with_decisions)
)
# --- Appreciations
cnx = ndb.GetDBConnexion()
apprecs = sco_etud.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
)
d["appreciation"] = []
for app in apprecs:
d["appreciation"].append(
dict(
comment=scu.quote_xml_attr(app["comment"]),
date=ndb.DateDMYtoISO(app["date"]),
)
)
#
return d
def dict_decision_jury(etudid, formsemestre_id, with_decisions=False):
"dict avec decision pour bulletins json"
from app.scodoc import sco_bulletins
d = {}
if (
sco_preferences.get_preference("bul_show_decision", formsemestre_id)
or xml_with_decisions
or with_decisions
):
infos, dpv = sco_bulletins.etud_descr_situation_semestre(
etudid,
formsemestre_id,
format="xml",
show_uevalid=sco_preferences.get_preference(
"bul_show_uevalid", formsemestre_id
),
)
d["situation"] = scu.quote_xml_attr(infos["situation"])
d["situation"] = infos["situation"]
if dpv:
decision = dpv["decisions"][0]
etat = decision["etat"]
@ -355,7 +380,13 @@ def formsemestre_bulletinetud_published_dict(
else:
code = ""
d["decision"] = dict(code=code, etat=etat)
d["decision"] = dict(
code=code,
etat=etat,
date=ndb.DateDMYtoISO(
dpv["decisions"][0]["decision_sem"]["event_date"]
),
)
if (
decision["decision_sem"]
and "compense_formsemestre_id" in decision["decision_sem"]
@ -373,11 +404,11 @@ def formsemestre_bulletinetud_published_dict(
d["decision_ue"].append(
dict(
ue_id=ue["ue_id"],
numero=scu.quote_xml_attr(ue["numero"]),
acronyme=scu.quote_xml_attr(ue["acronyme"]),
titre=scu.quote_xml_attr(ue["titre"]),
numero=ue["numero"],
acronyme=ue["acronyme"],
titre=ue["titre"],
code=decision["decisions_ue"][ue_id]["code"],
ects=scu.quote_xml_attr(ue["ects"] or ""),
ects=ue["ects"] or "",
)
)
d["autorisation_inscription"] = []
@ -387,20 +418,4 @@ def formsemestre_bulletinetud_published_dict(
)
else:
d["decision"] = dict(code="", etat="DEM")
# --- Appreciations
cnx = ndb.GetDBConnexion()
apprecs = sco_etud.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
)
d["appreciation"] = []
for app in apprecs:
d["appreciation"].append(
dict(
comment=scu.quote_xml_attr(app["comment"]),
date=ndb.DateDMYtoISO(app["date"]),
)
)
#
return d