forked from ScoDoc/ScoDoc
Merge branch 'refactor_nt' of https://scodoc.org/git/ScoDoc/ScoDoc into entreprises
This commit is contained in:
commit
acb8d58642
@ -6,6 +6,7 @@
|
||||
|
||||
"""Résultats semestres BUT
|
||||
"""
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from app.comp import moy_ue, moy_sem, inscr_mod
|
||||
@ -113,7 +114,9 @@ class ResultatsSemestreBUT(NotesTableCompat):
|
||||
mod_idx = self.modimpl_coefs_df.columns.get_loc(moduleimpl_id)
|
||||
etud_idx = self.etud_index[etudid]
|
||||
# moyenne sur les UE:
|
||||
return self.sem_cube[etud_idx, mod_idx].mean()
|
||||
if len(self.sem_cube[etud_idx, mod_idx]):
|
||||
return np.nanmean(self.sem_cube[etud_idx, mod_idx])
|
||||
return np.nan
|
||||
|
||||
def compute_etud_ue_coef(self, etudid: int, ue: UniteEns) -> float:
|
||||
"""Détermine le coefficient de l'UE pour cet étudiant.
|
||||
|
@ -216,11 +216,24 @@ class ResultatsSemestre(ResultatsCache):
|
||||
|
||||
def get_etud_ue_status(self, etudid: int, ue_id: int) -> dict:
|
||||
"""L'état de l'UE pour cet étudiant.
|
||||
Result: dict
|
||||
L'UE doit être du semestre.
|
||||
Result: dict.
|
||||
"""
|
||||
if not self.validations:
|
||||
self.validations = res_sem.load_formsemestre_validations(self.formsemestre)
|
||||
ue = UniteEns.query.get(ue_id) # TODO cacher nos UEs ?
|
||||
if ue.type == UE_SPORT:
|
||||
return {
|
||||
"is_capitalized": False,
|
||||
"is_external": False,
|
||||
"coef_ue": 0.0,
|
||||
"cur_moy_ue": 0.0,
|
||||
"moy": 0.0,
|
||||
"event_date": None,
|
||||
"ue": ue.to_dict(),
|
||||
"formsemestre_id": None,
|
||||
"capitalized_ue_id": None,
|
||||
}
|
||||
cur_moy_ue = self.etud_moy_ue[ue_id][etudid]
|
||||
moy_ue = cur_moy_ue
|
||||
is_capitalized = False
|
||||
@ -464,7 +477,7 @@ class NotesTableCompat(ResultatsSemestre):
|
||||
ects_pot += ue.ects
|
||||
return {
|
||||
"ects_pot": ects_pot,
|
||||
"ects_fond": 0.0, # not implemented (anciennemment pour école ingé)
|
||||
"ects_pot_fond": 0.0, # not implemented (anciennemment pour école ingé)
|
||||
}
|
||||
|
||||
def get_etud_rang(self, etudid: int):
|
||||
|
@ -132,7 +132,47 @@ class FormSemestre(db.Model):
|
||||
else:
|
||||
d["date_fin"] = d["date_fin_iso"] = ""
|
||||
d["responsables"] = [u.id for u in self.responsables]
|
||||
return d
|
||||
|
||||
def get_infos_dict(self) -> dict:
|
||||
"""Un dict avec des informations sur le semestre
|
||||
pour les bulletins et autres templates
|
||||
(contenu compatible scodoc7 / anciens templates)
|
||||
"""
|
||||
d = self.to_dict()
|
||||
d["anneescolaire"] = self.annee_scolaire_str()
|
||||
d["annee_debut"] = str(self.date_debut.year)
|
||||
d["annee"] = d["annee_debut"]
|
||||
d["annee_fin"] = str(self.date_fin.year)
|
||||
d["mois_debut_ord"] = self.date_debut.month
|
||||
d["mois_fin_ord"] = self.date_fin.month
|
||||
# La période: considère comme "S1" (ou S3) les débuts en aout-sept-octobre
|
||||
# devrait sans doute pouvoir etre changé...
|
||||
if self.date_debut.month >= 8 and self.date_debut.month <= 10:
|
||||
d["periode"] = 1 # typiquement, début en septembre: S1, S3...
|
||||
else:
|
||||
d["periode"] = 2 # typiquement, début en février: S2, S4...
|
||||
d["titre_num"] = self.titre_num
|
||||
d["titreannee"] = "%s %s %s" % (
|
||||
d["titre_num"],
|
||||
self.modalite or "",
|
||||
self.date_debut.year,
|
||||
)
|
||||
if d["annee_fin"] != d["annee_debut"]:
|
||||
d["titreannee"] += "-" + str(d["annee_fin"])
|
||||
d["annee"] += "-" + str(d["annee_fin"])
|
||||
d["mois_debut"] = f"{self.date_debut.month} {self.date_debut.year}"
|
||||
d["mois_fin"] = f"{self.date_fin.month} {self.date_fin.year}"
|
||||
d["titremois"] = "%s %s (%s - %s)" % (
|
||||
d["titre_num"],
|
||||
self.modalite or "",
|
||||
d["mois_debut"],
|
||||
d["mois_fin"],
|
||||
)
|
||||
d["session_id"] = self.session_id()
|
||||
d["etapes"] = self.etapes_apo_vdi()
|
||||
d["etapes_apo_str"] = self.etapes_apo_str()
|
||||
d["responsables"] = [u.id for u in self.responsables] # liste des ids
|
||||
return d
|
||||
|
||||
def query_ues(self, with_sport=False) -> flask_sqlalchemy.BaseQuery:
|
||||
@ -231,6 +271,11 @@ class FormSemestre(db.Model):
|
||||
not self.semestre_id % 2 and self.date_debut.month > 6
|
||||
)
|
||||
|
||||
def etapes_apo_vdi(self) -> list[ApoEtapeVDI]:
|
||||
"Liste des vdis"
|
||||
# was read_formsemestre_etapes
|
||||
return [e.as_apovdi() for e in self.etapes if e.etape_apo]
|
||||
|
||||
def etapes_apo_str(self) -> str:
|
||||
"""Chaine décrivant les étapes de ce semestre
|
||||
ex: "V1RT, V1RT3, V1RT4"
|
||||
|
@ -63,6 +63,7 @@ class Module(db.Model):
|
||||
e["numero"] = 0 if self.numero is None else self.numero
|
||||
e["coefficient"] = 0.0 if self.coefficient is None else self.coefficient
|
||||
e["module_type"] = 0 if self.module_type is None else self.module_type
|
||||
e["code_apogee"] = e["code_apogee"] or "" # pas de None
|
||||
return e
|
||||
|
||||
def is_apc(self):
|
||||
|
@ -62,6 +62,7 @@ class UniteEns(db.Model):
|
||||
e["numero"] = e["numero"] if e["numero"] else 0
|
||||
e["ects"] = e["ects"] if e["ects"] else 0.0
|
||||
e["coefficient"] = e["coefficient"] if e["coefficient"] else 0.0
|
||||
e["code_apogee"] = e["code_apogee"] or "" # pas de None
|
||||
return e
|
||||
|
||||
def is_locked(self):
|
||||
|
@ -413,7 +413,7 @@ class ApoEtud(dict):
|
||||
# Elements UE
|
||||
decisions_ue = nt.get_etud_decision_ues(etudid)
|
||||
for ue in nt.get_ues_stat_dict():
|
||||
if code in ue["code_apogee"].split(","):
|
||||
if ue["code_apogee"] and code in ue["code_apogee"].split(","):
|
||||
if self.export_res_ues:
|
||||
if decisions_ue and ue["ue_id"] in decisions_ue:
|
||||
ue_status = nt.get_etud_ue_status(etudid, ue["ue_id"])
|
||||
@ -434,7 +434,9 @@ class ApoEtud(dict):
|
||||
modimpls = nt.get_modimpls_dict()
|
||||
module_code_found = False
|
||||
for modimpl in modimpls:
|
||||
if code in modimpl["module"]["code_apogee"].split(","):
|
||||
if modimpl["module"]["code_apogee"] and code in modimpl["module"][
|
||||
"code_apogee"
|
||||
].split(","):
|
||||
n = nt.get_etud_mod_moy(modimpl["moduleimpl_id"], etudid)
|
||||
if n != "NI" and self.export_res_modules:
|
||||
return dict(N=_apo_fmt_note(n), B=20, J="", R="")
|
||||
@ -947,13 +949,15 @@ class ApoData(object):
|
||||
# associé à une UE:
|
||||
nt = sco_cache.NotesTableCache.get(sem["formsemestre_id"])
|
||||
for ue in nt.get_ues_stat_dict():
|
||||
if code in ue["code_apogee"].split(","):
|
||||
if ue["code_apogee"] and code in ue["code_apogee"].split(","):
|
||||
s.add(code)
|
||||
continue
|
||||
# associé à un module:
|
||||
modimpls = nt.get_modimpls_dict()
|
||||
for modimpl in modimpls:
|
||||
if code in modimpl["module"]["code_apogee"].split(","):
|
||||
if modimpl["module"]["code_apogee"] and code in modimpl["module"][
|
||||
"code_apogee"
|
||||
].split(","):
|
||||
s.add(code)
|
||||
continue
|
||||
# log('codes_by_sem=%s' % pprint.pformat(codes_by_sem))
|
||||
|
@ -148,7 +148,7 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"):
|
||||
I = scu.DictDefault(defaultvalue="")
|
||||
I["etudid"] = etudid
|
||||
I["formsemestre_id"] = formsemestre_id
|
||||
I["sem"] = nt.sem
|
||||
I["sem"] = formsemestre.get_infos_dict()
|
||||
I["server_name"] = request.url_root
|
||||
|
||||
# Formation et parcours
|
||||
|
@ -141,7 +141,7 @@ def process_field(field, cdict, style, suppress_empty_pars=False, format="pdf"):
|
||||
except:
|
||||
log("process_field: invalid format=%s" % field)
|
||||
text = (
|
||||
"<para><i>format invalide !<i></para><para>"
|
||||
"<para><i>format invalide !</i></para><para>"
|
||||
+ traceback.format_exc()
|
||||
+ "</para>"
|
||||
)
|
||||
|
@ -702,17 +702,14 @@ def formsemestre_recap_parcours_table(
|
||||
)
|
||||
# total ECTS (affiché sous la moyenne générale)
|
||||
H.append(
|
||||
'<td class="sem_ects_tit"><a title="crédit potentiels (dont nb de fondamentaux)">ECTS:</a></td><td class="sem_ects">%g <span class="ects_fond">%g</span></td>'
|
||||
% (etud_ects_infos["ects_pot"], etud_ects_infos["ects_pot_fond"])
|
||||
'<td class="sem_ects_tit"><a title="crédit potentiels (dont nb de fondamentaux)">ECTS:</a></td><td class="sem_ects">%g</td>'
|
||||
% (etud_ects_infos["ects_pot"])
|
||||
)
|
||||
H.append('<td class="rcp_abs"></td>')
|
||||
# ECTS validables dans chaque UE
|
||||
for ue in ues:
|
||||
ue_status = nt.get_etud_ue_status(etudid, ue["ue_id"])
|
||||
H.append(
|
||||
'<td class="ue">%g <span class="ects_fond">%g</span></td>'
|
||||
% (ue_status["ects_pot"], ue_status["ects_pot_fond"])
|
||||
)
|
||||
H.append('<td class="ue">%g</td>' % (ue_status["ects_pot"]))
|
||||
H.append("<td></td></tr>")
|
||||
|
||||
H.append("</table>")
|
||||
|
@ -85,8 +85,8 @@ def formsemestre_recapcomplet(
|
||||
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
||||
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
|
||||
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
|
||||
# Options pour APC BUT: cache les modules par défaut car moyenne n'a pas de sens
|
||||
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
# Pour APC (BUT): cache les modules par défaut car moyenne n'a pas de sens
|
||||
if formsemestre.formation.is_apc():
|
||||
hidemodules = True
|
||||
# traduit du DTML
|
||||
@ -312,10 +312,7 @@ def make_formsemestre_recapcomplet(
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
modimpls = formsemestre.modimpls_sorted
|
||||
ues = nt.get_ues_stat_dict() # incluant le(s) UE de sport
|
||||
#
|
||||
# if formsemestre.formation.is_apc():
|
||||
# nt.apc_recompute_moyennes()
|
||||
#
|
||||
|
||||
partitions, partitions_etud_groups = sco_groups.get_formsemestre_groups(
|
||||
formsemestre_id
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
SCOVERSION = "9.2.0a"
|
||||
SCOVERSION = "9.1.50a"
|
||||
|
||||
SCONAME = "ScoDoc"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user