From 8f12c452dfc0b6a46742a7c44430a386ba137c86 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 30 Jun 2024 00:26:17 +0200 Subject: [PATCH] =?UTF-8?q?Tri=20date=20table=20op=C3=A9rations=20sur=20?= =?UTF-8?q?=C3=A9valuation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_undo_notes.py | 39 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/app/scodoc/sco_undo_notes.py b/app/scodoc/sco_undo_notes.py index 1268a831..a8da7995 100644 --- a/app/scodoc/sco_undo_notes.py +++ b/app/scodoc/sco_undo_notes.py @@ -68,17 +68,18 @@ class NotesOperation(dict): Keys: evaluation_id, date, uid, notes """ - def get_comment(self): + def get_comment(self) -> str: + "le commentaire ou une chaine vide" if self["notes"]: return self["notes"][0]["comment"] - else: - return "" + return "" def comp_values(self): "compute keys: comment, nb_notes" self["comment"] = self.get_comment() self["nb_notes"] = len(self["notes"]) - self["datestr"] = self["date"].strftime("%a %d/%m/%y %Hh%M") + self["date_str"] = self["date"].strftime("%a %d/%m/%y %Hh%M") + self["_date_str_order"] = self["date"].isoformat() def undo(self): "undo operation" @@ -113,12 +114,12 @@ def list_operations(evaluation_id): ).values() ) dt = OPERATION_DATE_TOLERANCE - NotesDates = {} # { uid : intervalmap } + notes_dates = {} # { uid : intervalmap } for note in notes + notes_log: - if note["uid"] not in NotesDates: - NotesDates[note["uid"]] = intervalmap() - nd = NotesDates[note["uid"]] + if note["uid"] not in notes_dates: + notes_dates[note["uid"]] = intervalmap() + nd = notes_dates[note["uid"]] if nd[note["date"]] is None: nd[note["date"] - dt : note["date"] + dt] = [note] else: @@ -128,32 +129,32 @@ def list_operations(evaluation_id): for note in notes: current_notes_by_etud[note["etudid"]] = note - Ops = [] - for uid in NotesDates.keys(): + operations = [] + for uid, note_date in notes_dates.items(): user_name = "{prenomnom} ({user_name})".format(**sco_users.user_info(uid)) - for (t0, _), notes in NotesDates[uid].items(): - Op = NotesOperation( + for (t0, _), notes in note_date.items(): + operation = NotesOperation( evaluation_id=evaluation_id, date=t0, uid=uid, user_name=user_name, - notes=NotesDates[uid][t0], + notes=note_date[t0], current_notes_by_etud=current_notes_by_etud, ) - Op.comp_values() - Ops.append(Op) + operation.comp_values() + operations.append(operation) - return Ops + return operations -def evaluation_list_operations(evaluation_id): +def evaluation_list_operations(evaluation_id: int): """Page listing operations on evaluation""" evaluation = Evaluation.get_evaluation(evaluation_id) operations = list_operations(evaluation_id) - columns_ids = ("datestr", "user_name", "nb_notes", "comment") + columns_ids = ("date_str", "user_name", "nb_notes", "comment") titles = { - "datestr": "Date", + "date_str": "Date", "user_name": "Enseignant", "nb_notes": "Nb de notes", "comment": "Commentaire",