forked from ScoDoc/ScoDoc
Bulletin BUT: ne mentionne pas les évaluations rattrapage/session2 sans notes. (c'est déjà le cas en classic)
This commit is contained in:
parent
9bd05ea241
commit
41fec29452
@ -9,12 +9,14 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
|
import pandas as pd
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from flask import g, has_request_context, url_for
|
from flask import g, has_request_context, url_for
|
||||||
|
|
||||||
from app import db
|
from app import db
|
||||||
|
from app.comp.moy_mod import ModuleImplResults
|
||||||
from app.comp.res_but import ResultatsSemestreBUT
|
from app.comp.res_but import ResultatsSemestreBUT
|
||||||
from app.models import Evaluation, FormSemestre, Identite
|
from app.models import Evaluation, FormSemestre, Identite, ModuleImpl
|
||||||
from app.models.groups import GroupDescr
|
from app.models.groups import GroupDescr
|
||||||
from app.models.ues import UniteEns
|
from app.models.ues import UniteEns
|
||||||
from app.scodoc import sco_bulletins, sco_utils as scu
|
from app.scodoc import sco_bulletins, sco_utils as scu
|
||||||
@ -249,59 +251,88 @@ class BulletinBUT:
|
|||||||
# "moy": fmt_note(moyennes_etuds.mean()),
|
# "moy": fmt_note(moyennes_etuds.mean()),
|
||||||
},
|
},
|
||||||
"evaluations": (
|
"evaluations": (
|
||||||
[
|
self.etud_list_modimpl_evaluations(
|
||||||
self.etud_eval_results(etud, e)
|
etud, modimpl, modimpl_results, version
|
||||||
for e in modimpl.evaluations
|
)
|
||||||
if (e.visibulletin or version == "long")
|
|
||||||
and (e.id in modimpl_results.evaluations_etat)
|
|
||||||
and (
|
|
||||||
modimpl_results.evaluations_etat[e.id].is_complete
|
|
||||||
or self.prefs["bul_show_all_evals"]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
if version != "short"
|
if version != "short"
|
||||||
else []
|
else []
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def etud_eval_results(self, etud, e: Evaluation) -> dict:
|
def etud_list_modimpl_evaluations(
|
||||||
|
self,
|
||||||
|
etud: Identite,
|
||||||
|
modimpl: ModuleImpl,
|
||||||
|
modimpl_results: ModuleImplResults,
|
||||||
|
version: str,
|
||||||
|
) -> list[dict]:
|
||||||
|
"""Liste des résultats aux évaluations de ce modimpl à montrer pour cet étudiant"""
|
||||||
|
evaluation: Evaluation
|
||||||
|
eval_results = []
|
||||||
|
for evaluation in modimpl.evaluations:
|
||||||
|
if (
|
||||||
|
(evaluation.visibulletin or version == "long")
|
||||||
|
and (evaluation.id in modimpl_results.evaluations_etat)
|
||||||
|
and (
|
||||||
|
modimpl_results.evaluations_etat[evaluation.id].is_complete
|
||||||
|
or self.prefs["bul_show_all_evals"]
|
||||||
|
)
|
||||||
|
):
|
||||||
|
eval_notes = self.res.modimpls_results[modimpl.id].evals_notes[
|
||||||
|
evaluation.id
|
||||||
|
]
|
||||||
|
|
||||||
|
if (evaluation.evaluation_type == Evaluation.EVALUATION_NORMALE) or (
|
||||||
|
not np.isnan(eval_notes[etud.id])
|
||||||
|
):
|
||||||
|
eval_results.append(
|
||||||
|
self.etud_eval_results(etud, evaluation, eval_notes)
|
||||||
|
)
|
||||||
|
return eval_results
|
||||||
|
|
||||||
|
def etud_eval_results(
|
||||||
|
self, etud: Identite, evaluation: Evaluation, eval_notes: pd.DataFrame
|
||||||
|
) -> dict:
|
||||||
"dict resultats d'un étudiant à une évaluation"
|
"dict resultats d'un étudiant à une évaluation"
|
||||||
# eval_notes est une pd.Series avec toutes les notes des étudiants inscrits
|
# eval_notes est une pd.Series avec toutes les notes des étudiants inscrits
|
||||||
eval_notes = self.res.modimpls_results[e.moduleimpl_id].evals_notes[e.id]
|
|
||||||
notes_ok = eval_notes.where(eval_notes > scu.NOTES_ABSENCE).dropna()
|
notes_ok = eval_notes.where(eval_notes > scu.NOTES_ABSENCE).dropna()
|
||||||
modimpls_evals_poids = self.res.modimpls_evals_poids[e.moduleimpl_id]
|
modimpls_evals_poids = self.res.modimpls_evals_poids[evaluation.moduleimpl_id]
|
||||||
try:
|
try:
|
||||||
etud_ues_ids = self.res.etud_ues_ids(etud.id)
|
etud_ues_ids = self.res.etud_ues_ids(etud.id)
|
||||||
poids = {
|
poids = {
|
||||||
ue.acronyme: modimpls_evals_poids[ue.id][e.id]
|
ue.acronyme: modimpls_evals_poids[ue.id][evaluation.id]
|
||||||
for ue in self.res.ues
|
for ue in self.res.ues
|
||||||
if (ue.type != UE_SPORT) and (ue.id in etud_ues_ids)
|
if (ue.type != UE_SPORT) and (ue.id in etud_ues_ids)
|
||||||
}
|
}
|
||||||
except KeyError:
|
except KeyError:
|
||||||
poids = collections.defaultdict(lambda: 0.0)
|
poids = collections.defaultdict(lambda: 0.0)
|
||||||
d = {
|
d = {
|
||||||
"id": e.id,
|
"id": evaluation.id,
|
||||||
"coef": (
|
"coef": (
|
||||||
fmt_note(e.coefficient)
|
fmt_note(evaluation.coefficient)
|
||||||
if e.evaluation_type == Evaluation.EVALUATION_NORMALE
|
if evaluation.evaluation_type == Evaluation.EVALUATION_NORMALE
|
||||||
else None
|
else None
|
||||||
),
|
),
|
||||||
"date_debut": e.date_debut.isoformat() if e.date_debut else None,
|
"date_debut": (
|
||||||
"date_fin": e.date_fin.isoformat() if e.date_fin else None,
|
evaluation.date_debut.isoformat() if evaluation.date_debut else None
|
||||||
"description": e.description,
|
),
|
||||||
"evaluation_type": e.evaluation_type,
|
"date_fin": (
|
||||||
|
evaluation.date_fin.isoformat() if evaluation.date_fin else None
|
||||||
|
),
|
||||||
|
"description": evaluation.description,
|
||||||
|
"evaluation_type": evaluation.evaluation_type,
|
||||||
"note": (
|
"note": (
|
||||||
{
|
{
|
||||||
"value": fmt_note(
|
"value": fmt_note(
|
||||||
eval_notes[etud.id],
|
eval_notes[etud.id],
|
||||||
note_max=e.note_max,
|
note_max=evaluation.note_max,
|
||||||
),
|
),
|
||||||
"min": fmt_note(notes_ok.min(), note_max=e.note_max),
|
"min": fmt_note(notes_ok.min(), note_max=evaluation.note_max),
|
||||||
"max": fmt_note(notes_ok.max(), note_max=e.note_max),
|
"max": fmt_note(notes_ok.max(), note_max=evaluation.note_max),
|
||||||
"moy": fmt_note(notes_ok.mean(), note_max=e.note_max),
|
"moy": fmt_note(notes_ok.mean(), note_max=evaluation.note_max),
|
||||||
}
|
}
|
||||||
if not e.is_blocked()
|
if not evaluation.is_blocked()
|
||||||
else {}
|
else {}
|
||||||
),
|
),
|
||||||
"poids": poids,
|
"poids": poids,
|
||||||
@ -309,17 +340,25 @@ class BulletinBUT:
|
|||||||
url_for(
|
url_for(
|
||||||
"notes.evaluation_listenotes",
|
"notes.evaluation_listenotes",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
evaluation_id=e.id,
|
evaluation_id=evaluation.id,
|
||||||
)
|
)
|
||||||
if has_request_context()
|
if has_request_context()
|
||||||
else "na"
|
else "na"
|
||||||
),
|
),
|
||||||
# deprecated (supprimer avant #sco9.7)
|
# deprecated (supprimer avant #sco9.7)
|
||||||
"date": e.date_debut.isoformat() if e.date_debut else None,
|
"date": (
|
||||||
"heure_debut": (
|
evaluation.date_debut.isoformat() if evaluation.date_debut else None
|
||||||
e.date_debut.time().isoformat("minutes") if e.date_debut else None
|
),
|
||||||
|
"heure_debut": (
|
||||||
|
evaluation.date_debut.time().isoformat("minutes")
|
||||||
|
if evaluation.date_debut
|
||||||
|
else None
|
||||||
|
),
|
||||||
|
"heure_fin": (
|
||||||
|
evaluation.date_fin.time().isoformat("minutes")
|
||||||
|
if evaluation.date_fin
|
||||||
|
else None
|
||||||
),
|
),
|
||||||
"heure_fin": e.date_fin.time().isoformat("minutes") if e.date_fin else None,
|
|
||||||
}
|
}
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@ -446,7 +446,8 @@ def _ue_mod_bulletin(
|
|||||||
):
|
):
|
||||||
"""Infos sur les modules (et évaluations) dans une UE
|
"""Infos sur les modules (et évaluations) dans une UE
|
||||||
(ajoute les informations aux modimpls)
|
(ajoute les informations aux modimpls)
|
||||||
Result: liste de modules de l'UE avec les infos dans chacun (seulement ceux où l'étudiant est inscrit).
|
Result: liste de modules de l'UE avec les infos dans chacun (seulement
|
||||||
|
ceux où l'étudiant est inscrit).
|
||||||
"""
|
"""
|
||||||
bul_show_mod_rangs = sco_preferences.get_preference(
|
bul_show_mod_rangs = sco_preferences.get_preference(
|
||||||
"bul_show_mod_rangs", formsemestre_id
|
"bul_show_mod_rangs", formsemestre_id
|
||||||
|
@ -159,8 +159,9 @@ def anonymize_users(cursor):
|
|||||||
# Change les noms/prenoms/mail
|
# Change les noms/prenoms/mail
|
||||||
cursor.execute("""SELECT * FROM "user";""")
|
cursor.execute("""SELECT * FROM "user";""")
|
||||||
users = cursor.fetchall() # fetch tout car modifie cette table ds la boucle
|
users = cursor.fetchall() # fetch tout car modifie cette table ds la boucle
|
||||||
|
nb_users = len(users)
|
||||||
used_user_names = {u["user_name"] for u in users}
|
used_user_names = {u["user_name"] for u in users}
|
||||||
for user in users:
|
for i, user in enumerate(users):
|
||||||
user_name = user["user_name"]
|
user_name = user["user_name"]
|
||||||
nom, prenom = random.choice(NOMS), random.choice(PRENOMS)
|
nom, prenom = random.choice(NOMS), random.choice(PRENOMS)
|
||||||
new_name = (prenom[0] + nom).lower()
|
new_name = (prenom[0] + nom).lower()
|
||||||
@ -168,7 +169,7 @@ def anonymize_users(cursor):
|
|||||||
while new_name in used_user_names:
|
while new_name in used_user_names:
|
||||||
new_name += "x"
|
new_name += "x"
|
||||||
used_user_names.add(new_name)
|
used_user_names.add(new_name)
|
||||||
print(f"{user_name} > {new_name}")
|
print(f"{i}/{nb_users}\t{user_name} > {new_name}")
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""UPDATE "user"
|
"""UPDATE "user"
|
||||||
SET nom=%(nom)s, prenom=%(prenom)s, email=%(email)s, user_name=%(new_name)s
|
SET nom=%(nom)s, prenom=%(prenom)s, email=%(email)s, user_name=%(new_name)s
|
||||||
@ -234,6 +235,7 @@ if __name__ == "__main__":
|
|||||||
cursor = cnx.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
cursor = cnx.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||||||
|
|
||||||
anonymize_db(cursor)
|
anonymize_db(cursor)
|
||||||
|
rename_students(cursor)
|
||||||
if PROCESS_USERS:
|
if PROCESS_USERS:
|
||||||
anonymize_users(cursor)
|
anonymize_users(cursor)
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user