was_capitalized / optim. -nt

This commit is contained in:
Emmanuel Viennet 2022-02-13 15:50:16 +01:00
parent 3cafbf5988
commit 45c845d23b
5 changed files with 52 additions and 28 deletions

View File

@ -219,6 +219,7 @@ class ResultatsSemestre(ResultatsCache):
if ue.type == UE_SPORT: if ue.type == UE_SPORT:
return { return {
"is_capitalized": False, "is_capitalized": False,
"was_capitalized": False,
"is_external": False, "is_external": False,
"coef_ue": 0.0, "coef_ue": 0.0,
"cur_moy_ue": 0.0, "cur_moy_ue": 0.0,
@ -235,7 +236,10 @@ class ResultatsSemestre(ResultatsCache):
self.validations = res_sem.load_formsemestre_validations(self.formsemestre) self.validations = res_sem.load_formsemestre_validations(self.formsemestre)
cur_moy_ue = self.etud_moy_ue[ue_id][etudid] cur_moy_ue = self.etud_moy_ue[ue_id][etudid]
moy_ue = cur_moy_ue moy_ue = cur_moy_ue
is_capitalized = False is_capitalized = False # si l'UE prise en compte est une UE capitalisée
was_capitalized = (
False # s'il y a precedemment une UE capitalisée (pas forcement meilleure)
)
if etudid in self.validations.ue_capitalisees.index: if etudid in self.validations.ue_capitalisees.index:
ue_cap = self._get_etud_ue_cap(etudid, ue) ue_cap = self._get_etud_ue_cap(etudid, ue)
if ( if (
@ -243,6 +247,7 @@ class ResultatsSemestre(ResultatsCache):
and not ue_cap.empty and not ue_cap.empty
and not np.isnan(ue_cap["moy_ue"]) and not np.isnan(ue_cap["moy_ue"])
): ):
was_capitalized = True
if ue_cap["moy_ue"] > cur_moy_ue or np.isnan(cur_moy_ue): if ue_cap["moy_ue"] > cur_moy_ue or np.isnan(cur_moy_ue):
moy_ue = ue_cap["moy_ue"] moy_ue = ue_cap["moy_ue"]
is_capitalized = True is_capitalized = True
@ -251,6 +256,7 @@ class ResultatsSemestre(ResultatsCache):
return { return {
"is_capitalized": is_capitalized, "is_capitalized": is_capitalized,
"was_capitalized": was_capitalized,
"is_external": ue_cap["is_external"] if is_capitalized else ue.is_external, "is_external": ue_cap["is_external"] if is_capitalized else ue.is_external,
"coef_ue": coef_ue, "coef_ue": coef_ue,
"ects_pot": ue.ects or 0.0, "ects_pot": ue.ects or 0.0,
@ -425,6 +431,10 @@ class NotesTableCompat(ResultatsSemestre):
ue_status_list.append(ue_status) ue_status_list.append(ue_status)
return self.parcours.check_barre_ues(ue_status_list) return self.parcours.check_barre_ues(ue_status_list)
def etud_has_decision(self, etudid):
"""True s'il y a une décision de jury pour cet étudiant"""
return self.get_etud_decision_ues(etudid) or self.get_etud_decision_sem(etudid)
def get_etud_decision_ues(self, etudid: int) -> dict: def get_etud_decision_ues(self, etudid: int) -> dict:
"""Decisions du jury pour les UE de cet etudiant, ou None s'il n'y en pas eu. """Decisions du jury pour les UE de cet etudiant, ou None s'il n'y en pas eu.
Ne tient pas compte des UE capitalisées. Ne tient pas compte des UE capitalisées.

View File

@ -32,14 +32,16 @@ import time
import flask import flask
from flask import url_for, g, request from flask import url_for, g, request
from app.comp import res_sem
from app.comp.res_common import NotesTableCompat
from app.models import FormSemestre
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app import log from app import log
from app.scodoc.scolog import logdb from app.scodoc.scolog import logdb
from app.scodoc.sco_exceptions import ScoException, ScoValueError from app.scodoc.sco_exceptions import ScoException, ScoValueError
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_codes_parcours import UE_STANDARD, UE_SPORT, UE_TYPE_NAME from app.scodoc.sco_codes_parcours import UE_STANDARD, UE_SPORT, UE_TYPE_NAME
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
from app.scodoc.TrivialFormulator import TrivialFormulator, TF from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc import sco_find_etud from app.scodoc import sco_find_etud
from app.scodoc import sco_formsemestre from app.scodoc import sco_formsemestre
from app.scodoc import sco_moduleimpl from app.scodoc import sco_moduleimpl
@ -186,7 +188,9 @@ def do_formsemestre_desinscription(etudid, formsemestre_id):
raise ScoValueError("desinscription impossible: semestre verrouille") raise ScoValueError("desinscription impossible: semestre verrouille")
# -- Si decisions de jury, desinscription interdite # -- Si decisions de jury, desinscription interdite
nt = sco_cache.NotesTableCache.get(formsemestre_id) formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
if nt.etud_has_decision(etudid): if nt.etud_has_decision(etudid):
raise ScoValueError( raise ScoValueError(
"desinscription impossible: l'étudiant a une décision de jury (la supprimer avant si nécessaire)" "desinscription impossible: l'étudiant a une décision de jury (la supprimer avant si nécessaire)"
@ -475,7 +479,8 @@ def formsemestre_inscription_option(etudid, formsemestre_id):
raise ScoValueError("Modification impossible: semestre verrouille") raise ScoValueError("Modification impossible: semestre verrouille")
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
nt = sco_cache.NotesTableCache.get(formsemestre_id) formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
H = [ H = [
@ -785,7 +790,9 @@ def list_inscrits_ailleurs(formsemestre_id):
Pour chacun, donne la liste des semestres. Pour chacun, donne la liste des semestres.
{ etudid : [ liste de sems ] } { etudid : [ liste de sems ] }
""" """
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_etudids formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
etudids = nt.get_etudids() etudids = nt.get_etudids()
d = {} d = {}
for etudid in etudids: for etudid in etudids:

View File

@ -33,6 +33,10 @@ import flask
from flask import url_for, g, request from flask import url_for, g, request
from flask_login import current_user from flask_login import current_user
from app.comp import res_sem
from app.comp.res_common import NotesTableCompat
from app.models import FormSemestre
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app import log from app import log
@ -479,7 +483,9 @@ def get_etuds_with_capitalized_ue(formsemestre_id):
returns { ue_id : [ { infos } ] } returns { ue_id : [ { infos } ] }
""" """
UECaps = scu.DictDefault(defaultvalue=[]) UECaps = scu.DictDefault(defaultvalue=[])
nt = sco_cache.NotesTableCache.get(formsemestre_id) formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list( inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
args={"formsemestre_id": formsemestre_id} args={"formsemestre_id": formsemestre_id}
) )

View File

@ -39,14 +39,16 @@ from operator import itemgetter
from flask import url_for, g, request from flask import url_for, g, request
import pydot import pydot
from app.comp import res_sem
from app.comp.res_common import NotesTableCompat
from app.models import FormSemestre
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app.models import FormationModalite from app.models import FormationModalite
from app.scodoc import notesdb as ndb from app.scodoc import notesdb as ndb
from app.scodoc import html_sco_header from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours from app.scodoc import sco_codes_parcours
from app.scodoc import sco_cache
from app.scodoc import sco_etud from app.scodoc import sco_etud
from app.scodoc import sco_excel
from app.scodoc import sco_formsemestre from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_parcours_dut from app.scodoc import sco_parcours_dut
@ -61,9 +63,9 @@ MAX_ETUD_IN_DESCR = 20
def formsemestre_etuds_stats(sem, only_primo=False): def formsemestre_etuds_stats(sem, only_primo=False):
"""Récupère liste d'etudiants avec etat et decision.""" """Récupère liste d'etudiants avec etat et decision."""
nt = sco_cache.NotesTableCache.get( formsemestre = FormSemestre.query.get_or_404(sem["formsemestre_id"])
sem["formsemestre_id"] nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
) # > get_table_moyennes_triees, identdict, get_etud_decision_sem, get_etud_etat,
T = nt.get_table_moyennes_triees() T = nt.get_table_moyennes_triees()
# Construit liste d'étudiants du semestre avec leur decision # Construit liste d'étudiants du semestre avec leur decision
etuds = [] etuds = []
@ -400,9 +402,8 @@ def table_suivi_cohorte(
logt("table_suivi_cohorte: start") logt("table_suivi_cohorte: start")
# 1-- Liste des semestres posterieurs dans lesquels ont été les etudiants de sem # 1-- Liste des semestres posterieurs dans lesquels ont été les etudiants de sem
nt = sco_cache.NotesTableCache.get( formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
formsemestre_id nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
) # > get_etudids, get_etud_decision_sem
etudids = nt.get_etudids() etudids = nt.get_etudids()
logt("A: orig etuds set") logt("A: orig etuds set")
@ -456,9 +457,8 @@ def table_suivi_cohorte(
s["members"] = orig_set.intersection(inset) s["members"] = orig_set.intersection(inset)
nb_dipl = 0 # combien de diplomes dans ce semestre ? nb_dipl = 0 # combien de diplomes dans ce semestre ?
if s["semestre_id"] == nt.parcours.NB_SEM: if s["semestre_id"] == nt.parcours.NB_SEM:
nt = sco_cache.NotesTableCache.get( s_formsemestre = FormSemestre.query.get_or_404(s["formsemestre_id"])
s["formsemestre_id"] nt: NotesTableCompat = res_sem.load_formsemestre_results(s_formsemestre)
) # > get_etud_decision_sem
for etudid in s["members"]: for etudid in s["members"]:
dec = nt.get_etud_decision_sem(etudid) dec = nt.get_etud_decision_sem(etudid)
if dec and code_semestre_validant(dec["code"]): if dec and code_semestre_validant(dec["code"]):
@ -905,9 +905,9 @@ def _descr_etud_set(etudids):
def _count_dem_reo(formsemestre_id, etudids): def _count_dem_reo(formsemestre_id, etudids):
"count nb of demissions and reorientation in this etud set" "count nb of demissions and reorientation in this etud set"
nt = sco_cache.NotesTableCache.get( formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
formsemestre_id nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
) # > get_etud_etat, get_etud_decision_sem
dems = set() dems = set()
reos = set() reos = set()
for etudid in etudids: for etudid in etudids:
@ -971,9 +971,9 @@ def get_codeparcoursetud(etud, prefix="", separator=""):
i = len(sems) - 1 i = len(sems) - 1
while i >= 0: while i >= 0:
s = sems[i] # 'sems' est a l'envers, du plus recent au plus ancien s = sems[i] # 'sems' est a l'envers, du plus recent au plus ancien
nt = sco_cache.NotesTableCache.get( s_formsemestre = FormSemestre.query.get_or_404(s["formsemestre_id"])
s["formsemestre_id"] nt: NotesTableCompat = res_sem.load_formsemestre_results(s_formsemestre)
) # > get_etud_etat, get_etud_decision_sem
p.append(_codesem(s, prefix=prefix)) p.append(_codesem(s, prefix=prefix))
# code decisions jury de chaque semestre: # code decisions jury de chaque semestre:
if nt.get_etud_etat(etud["etudid"]) == "D": if nt.get_etud_etat(etud["etudid"]) == "D":
@ -1017,7 +1017,8 @@ def tsp_etud_list(
""" """
# log('tsp_etud_list(%s, bac="%s")' % (formsemestre_id,bac)) # log('tsp_etud_list(%s, bac="%s")' % (formsemestre_id,bac))
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_etudids, formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
etudids = nt.get_etudids() etudids = nt.get_etudids()
etuds = [] etuds = []
bacs = set() bacs = set()
@ -1260,9 +1261,8 @@ def graph_parcours(
nxt = {} nxt = {}
etudid = etud["etudid"] etudid = etud["etudid"]
for s in etud["sems"]: # du plus recent au plus ancien for s in etud["sems"]: # du plus recent au plus ancien
nt = sco_cache.NotesTableCache.get( s_formsemestre = FormSemestre.query.get_or_404(s["formsemestre_id"])
s["formsemestre_id"] nt: NotesTableCompat = res_sem.load_formsemestre_results(s_formsemestre)
) # > get_etud_decision_sem, get_etud_etat
dec = nt.get_etud_decision_sem(etudid) dec = nt.get_etud_decision_sem(etudid)
if nxt: if nxt:
if ( if (

View File

@ -434,6 +434,7 @@ def localize_logo(logo: str = None, dept: str = None): # migrate-scodoc7-dept-l
@click.argument("xlsfile", type=click.File("rb")) @click.argument("xlsfile", type=click.File("rb"))
@click.argument("zipfile", type=click.File("rb")) @click.argument("zipfile", type=click.File("rb"))
def photos_import_files(formsemestre_id: int, xlsfile: str, zipfile: str): def photos_import_files(formsemestre_id: int, xlsfile: str, zipfile: str):
"""Import des photos d'étudiants à partir d'une liste excel et d'un zip avec les images."""
import app as mapp import app as mapp
from app.scodoc import sco_trombino, sco_photos from app.scodoc import sco_trombino, sco_photos
from app.scodoc import notesdb as ndb from app.scodoc import notesdb as ndb