diff --git a/app/models/evaluations.py b/app/models/evaluations.py index 71d54d82e..04d0dcf91 100644 --- a/app/models/evaluations.py +++ b/app/models/evaluations.py @@ -13,6 +13,8 @@ from app.models.ues import UniteEns from app.scodoc.sco_exceptions import ScoValueError import app.scodoc.notesdb as ndb +DEFAULT_EVALUATION_TIME = datetime.time(8, 0) + class Evaluation(db.Model): """Evaluation (contrôle, examen, ...)""" @@ -111,12 +113,24 @@ class Evaluation(db.Model): if self.heure_debut and ( not self.heure_fin or self.heure_fin == self.heure_debut ): - return f"""à {self.heure_debut.strftime("%H:%M")}""" + return f"""à {self.heure_debut.strftime("%Hh%M")}""" elif self.heure_debut and self.heure_fin: - return f"""de {self.heure_debut.strftime("%H:%M")} à {self.heure_fin.strftime("%H:%M")}""" + return f"""de {self.heure_debut.strftime("%Hh%M")} à {self.heure_fin.strftime("%Hh%M")}""" else: return "" + def descr_duree(self) -> str: + "Description de la durée pour affichages" + if self.heure_debut is None and self.heure_fin is None: + return "" + debut = self.heure_debut or DEFAULT_EVALUATION_TIME + fin = self.heure_fin or DEFAULT_EVALUATION_TIME + d = (fin.hour * 60 + fin.minute) - (debut.hour * 60 + debut.minute) + duree = f"{d//60}h" + if d % 60: + duree += f"{d%60:02d}" + return duree + def clone(self, not_copying=()): """Clone, not copying the given attrs Attention: la copie n'a pas d'id avant le prochain commit diff --git a/app/scodoc/sco_moduleimpl_status.py b/app/scodoc/sco_moduleimpl_status.py index 3ab89db7e..305f03b14 100644 --- a/app/scodoc/sco_moduleimpl_status.py +++ b/app/scodoc/sco_moduleimpl_status.py @@ -203,16 +203,22 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): sem = sco_formsemestre.get_formsemestre(formsemestre_id) F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0] mod_inscrits = sco_moduleimpl.do_moduleimpl_inscription_list( - moduleimpl_id=M["moduleimpl_id"] + moduleimpl_id=moduleimpl_id ) nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) - mod_evals = sco_evaluation_db.do_evaluation_list({"moduleimpl_id": moduleimpl_id}) - mod_evals.sort( - key=lambda x: (x["numero"], x["jour"], x["heure_debut"]), reverse=True - ) # la plus RECENTE en tête - + # mod_evals = sco_evaluation_db.do_evaluation_list({"moduleimpl_id": moduleimpl_id}) + # mod_evals.sort( + # key=lambda x: (x["numero"], x["jour"], x["heure_debut"]), reverse=True + # ) + # la plus RECENTE en tête + evaluations = modimpl.evaluations.order_by( + Evaluation.numero.desc(), + Evaluation.jour.desc(), + Evaluation.heure_debut.desc(), + ).all() + nb_evaluations = len(evaluations) # sem_locked = not sem["etat"] can_edit_evals = ( @@ -329,8 +335,10 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): # ) H.append("") H.append( - '