From b8b3185901d43513dd049acb236d3f7583cd8222 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 17 Jan 2022 00:06:21 +0100 Subject: [PATCH 1/2] Traite #276 --- app/comp/moy_ue.py | 18 ++++++++++++------ sco_version.py | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/comp/moy_ue.py b/app/comp/moy_ue.py index a707633f..44dbe3cf 100644 --- a/app/comp/moy_ue.py +++ b/app/comp/moy_ue.py @@ -121,6 +121,7 @@ def notes_sem_assemble_cube(modimpls_notes: list[pd.DataFrame]) -> np.ndarray: (DataFrames rendus par compute_module_moy, (etud x UE)) Resultat: ndarray (etud x module x UE) """ + assert len(modimpls_notes) modimpls_notes_arr = [df.values for df in modimpls_notes] modimpls_notes = np.stack(modimpls_notes_arr) # passe de (mod x etud x ue) à (etud x mod x UE) @@ -156,8 +157,13 @@ def notes_sem_load_cube(formsemestre): modimpls_evaluations[modimpl.id] = evaluations modimpls_evaluations_complete[modimpl.id] = evaluations_completes modimpls_notes.append(etuds_moy_module) + if len(modimpls_notes): + cube = notes_sem_assemble_cube(modimpls_notes) + else: + nb_etuds = formsemestre.etuds.count() + cube = np.zeros((nb_etuds, 0, 0), dtype=float) return ( - notes_sem_assemble_cube(modimpls_notes), + cube, modimpls_evals_poids, modimpls_evals_notes, modimpls_evaluations, @@ -191,8 +197,12 @@ def compute_ue_moys( Resultat: DataFrame columns UE, rows etudid """ nb_etuds, nb_modules, nb_ues = sem_cube.shape - assert len(etuds) == nb_etuds assert len(modimpls) == nb_modules + if nb_modules == 0 or nb_etuds == 0: + return pd.DataFrame( + index=modimpl_inscr_df.index, columns=modimpl_coefs_df.index + ) + assert len(etuds) == nb_etuds assert len(ues) == nb_ues assert modimpl_inscr_df.shape[0] == nb_etuds assert modimpl_inscr_df.shape[1] == nb_modules @@ -200,10 +210,6 @@ def compute_ue_moys( assert modimpl_coefs_df.shape[1] == nb_modules modimpl_inscr = modimpl_inscr_df.values modimpl_coefs = modimpl_coefs_df.values - if nb_etuds == 0: - return pd.DataFrame( - index=modimpl_inscr_df.index, columns=modimpl_coefs_df.index - ) # Duplique les inscriptions sur les UEs: modimpl_inscr_stacked = np.stack([modimpl_inscr] * nb_ues, axis=2) # Enlève les NaN du numérateur: diff --git a/sco_version.py b/sco_version.py index 64e77bf1..cab845d1 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.1.24" +SCOVERSION = "9.1.25" SCONAME = "ScoDoc" From 831d14cf7de2aa425672f8fe7547e55f2372f309 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 17 Jan 2022 00:18:08 +0100 Subject: [PATCH 2/2] 9.0.25 --- app/scodoc/sco_compute_moy.py | 10 ++++++---- app/scodoc/sco_evaluation_check_abs.py | 6 +++--- app/scodoc/sco_evaluation_db.py | 4 ++-- app/scodoc/sco_liste_notes.py | 12 ++++++------ app/scodoc/sco_saisie_notes.py | 16 ++++++++-------- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/app/scodoc/sco_compute_moy.py b/app/scodoc/sco_compute_moy.py index 85b65454..b35ca6d4 100644 --- a/app/scodoc/sco_compute_moy.py +++ b/app/scodoc/sco_compute_moy.py @@ -191,6 +191,7 @@ def compute_user_formula( return user_moy +# XXX OBSOLETE def compute_moduleimpl_moyennes(nt, modimpl): """Retourne dict { etudid : note_moyenne } pour tous les etuds inscrits au moduleimpl mod, la liste des evaluations "valides" (toutes notes entrées @@ -228,22 +229,23 @@ def compute_moduleimpl_moyennes(nt, modimpl): user_expr = moduleimpl_has_expression(modimpl) attente = False - # recupere les notes de toutes les evaluations + # récupere les notes de toutes les evaluations eval_rattr = None for e in evals: e["nb_inscrits"] = e["etat"]["nb_inscrits"] - NotesDB = sco_evaluation_db.do_evaluation_get_all_notes( + # XXX OBSOLETE + notes_db = sco_evaluation_db.do_evaluation_get_all_notes( e["evaluation_id"] ) # toutes, y compris demissions # restreint aux étudiants encore inscrits à ce module notes = [ - NotesDB[etudid]["value"] for etudid in NotesDB if (etudid in insmod_set) + notes_db[etudid]["value"] for etudid in notes_db if (etudid in insmod_set) ] e["nb_notes"] = len(notes) e["nb_abs"] = len([x for x in notes if x is None]) e["nb_neutre"] = len([x for x in notes if x == NOTES_NEUTRALISE]) e["nb_att"] = len([x for x in notes if x == NOTES_ATTENTE]) - e["notes"] = NotesDB + e["notes"] = notes_db if e["etat"]["evalattente"]: attente = True diff --git a/app/scodoc/sco_evaluation_check_abs.py b/app/scodoc/sco_evaluation_check_abs.py index 78c18045..8d52fc4c 100644 --- a/app/scodoc/sco_evaluation_check_abs.py +++ b/app/scodoc/sco_evaluation_check_abs.py @@ -85,7 +85,7 @@ def evaluation_check_absences(evaluation_id): Justs = set([x["etudid"] for x in Just]) # ensemble des etudiants avec justif # Les notes: - NotesDB = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) + notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) ValButAbs = [] # une note mais noté absent AbsNonSignalee = [] # note ABS mais pas noté absent ExcNonSignalee = [] # note EXC mais pas noté absent @@ -94,8 +94,8 @@ def evaluation_check_absences(evaluation_id): for etudid, _ in sco_groups.do_evaluation_listeetuds_groups( evaluation_id, getallstudents=True ): - if etudid in NotesDB: - val = NotesDB[etudid]["value"] + if etudid in notes_db: + val = notes_db[etudid]["value"] if ( val != None and val != scu.NOTES_NEUTRALISE and val != scu.NOTES_ATTENTE ) and etudid in As: diff --git a/app/scodoc/sco_evaluation_db.py b/app/scodoc/sco_evaluation_db.py index 36fbb35a..17d47915 100644 --- a/app/scodoc/sco_evaluation_db.py +++ b/app/scodoc/sco_evaluation_db.py @@ -306,8 +306,8 @@ def do_evaluation_delete(evaluation_id): raise AccessDenied( "Modification évaluation impossible pour %s" % current_user.get_nomplogin() ) - NotesDB = do_evaluation_get_all_notes(evaluation_id) # { etudid : value } - notes = [x["value"] for x in NotesDB.values()] + notes_db = do_evaluation_get_all_notes(evaluation_id) # { etudid : value } + notes = [x["value"] for x in notes_db.values()] if notes: raise ScoValueError( "Impossible de supprimer cette évaluation: il reste des notes" diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index dace96b0..4ef37d68 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -653,11 +653,11 @@ def _add_eval_columns( notes = [] # liste des notes numeriques, pour calcul histogramme uniquement evaluation_id = e["evaluation_id"] e_o = Evaluation.query.get(evaluation_id) # XXX en attendant ré-écriture - NotesDB = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) + notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) for row in rows: etudid = row["etudid"] - if etudid in NotesDB: - val = NotesDB[etudid]["value"] + if etudid in notes_db: + val = notes_db[etudid]["value"] if val is None: nb_abs += 1 if val == scu.NOTES_ATTENTE: @@ -674,12 +674,12 @@ def _add_eval_columns( nb_notes = nb_notes + 1 sum_notes += val val_fmt = scu.fmt_note(val, keep_numeric=keep_numeric) - comment = NotesDB[etudid]["comment"] + comment = notes_db[etudid]["comment"] if comment is None: comment = "" explanation = "%s (%s) %s" % ( - NotesDB[etudid]["date"].strftime("%d/%m/%y %Hh%M"), - sco_users.user_info(NotesDB[etudid]["uid"])["nomcomplet"], + notes_db[etudid]["date"].strftime("%d/%m/%y %Hh%M"), + sco_users.user_info(notes_db[etudid]["uid"])["nomcomplet"], comment, ) else: diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index 7f7012db..0fa105db 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -308,13 +308,13 @@ def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False): # XXX imaginer un redirect + msg erreur raise AccessDenied("Modification des notes impossible pour %s" % current_user) # - NotesDB = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) + notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) etudid_etats = sco_groups.do_evaluation_listeetuds_groups( evaluation_id, getallstudents=True, include_dems=False ) notes = [] for etudid, _ in etudid_etats: # pour tous les inscrits - if etudid not in NotesDB: # pas de note + if etudid not in notes_db: # pas de note notes.append((etudid, value)) # Check value L, invalids, _, _, _ = _check_notes(notes, E, M["module"]) @@ -393,18 +393,18 @@ def evaluation_suppress_alln(evaluation_id, dialog_confirmed=False): ): # On a le droit de modifier toutes les notes # recupere les etuds ayant une note - NotesDB = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) + notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) elif sco_permissions_check.can_edit_notes( current_user, E["moduleimpl_id"], allow_ens=True ): # Enseignant associé au module: ne peut supprimer que les notes qu'il a saisi - NotesDB = sco_evaluation_db.do_evaluation_get_all_notes( + notes_db = sco_evaluation_db.do_evaluation_get_all_notes( evaluation_id, by_uid=current_user.id ) else: raise AccessDenied("Modification des notes impossible pour %s" % current_user) - notes = [(etudid, scu.NOTES_SUPPRESS) for etudid in NotesDB.keys()] + notes = [(etudid, scu.NOTES_SUPPRESS) for etudid in notes_db.keys()] if not dialog_confirmed: nb_changed, nb_suppress, existing_decisions = notes_add( @@ -493,7 +493,7 @@ def notes_add( "etudiant %s: valeur de note invalide (%s)" % (etudid, value) ) # Recherche notes existantes - NotesDB = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) + notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) # Met a jour la base cnx = ndb.GetDBConnexion() cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) @@ -507,7 +507,7 @@ def notes_add( try: for (etudid, value) in notes: changed = False - if etudid not in NotesDB: + if etudid not in notes_db: # nouvelle note if value != scu.NOTES_SUPPRESS: if do_it: @@ -530,7 +530,7 @@ def notes_add( changed = True else: # il y a deja une note - oldval = NotesDB[etudid]["value"] + oldval = notes_db[etudid]["value"] if type(value) != type(oldval): changed = True elif type(value) == type(1.0) and (