From 4de2d638613f61b99b59a8d8c226bc3fa8e1a012 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 19 Jul 2024 16:32:56 +0200 Subject: [PATCH] =?UTF-8?q?Import=20notes=20toutes=20=C3=A9valuations=20d'?= =?UTF-8?q?un=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/etudiants.py | 4 +- app/scodoc/sco_excel.py | 16 ++-- app/scodoc/sco_exceptions.py | 6 +- app/scodoc/sco_moduleimpl_status.py | 15 ++- app/scodoc/sco_saisie_excel.py | 92 +++++++++++++++---- app/static/css/scodoc.css | 5 + app/templates/formsemestre/import_notes.j2 | 25 ++++- .../formsemestre/import_notes_after.j2 | 27 +++++- app/views/notes.py | 87 +++++++++++++++--- 9 files changed, 225 insertions(+), 52 deletions(-) diff --git a/app/models/etudiants.py b/app/models/etudiants.py index 61ca8e5b8..e64bbbb87 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -830,7 +830,7 @@ def check_etud_duplicate_code(args, code_name, edit=True): dest_endpoint = "notes.index_html" parameters = {} - err_page = f"""

Code étudiant ({code_name}) dupliqué !

+ err_page = f"""

Code étudiant ({code_name}) dupliqué !

Le {code_name} {args[code_name]} est déjà utilisé: un seul étudiant peut avoir ce code. Vérifier votre valeur ou supprimer l'autre étudiant avec cette valeur.

@@ -845,7 +845,7 @@ def check_etud_duplicate_code(args, code_name, edit=True): log(f"*** error: code {code_name} duplique: {args[code_name]}") - raise ScoGenError(err_page) + raise ScoGenError(err_page, safe=True) def make_etud_args( diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index da6050936..1ef1df495 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -508,24 +508,26 @@ def excel_simple_table( return ws.generate() -def excel_bytes_to_list(bytes_content): +def excel_bytes_to_list(bytes_content) -> tuple[list, list[list]]: + "Lecture d'un flux xlsx" try: filelike = io.BytesIO(bytes_content) + return _excel_to_list(filelike) except Exception as exc: raise ScoValueError( - """Le fichier xlsx attendu n'est pas lisible ! + """Le fichier xlsx attendu n'est pas lisible ! (1) Peut-être avez-vous fourni un fichier au mauvais format (txt, xls, ..) """ ) from exc - return _excel_to_list(filelike) -def excel_file_to_list(filename): +def excel_file_to_list(filelike) -> tuple[list, list[list]]: + "Lecture d'un flux xlsx" try: - return _excel_to_list(filename) + return _excel_to_list(filelike) except Exception as exc: raise ScoValueError( - """Le fichier xlsx attendu n'est pas lisible ! + """Le fichier xlsx attendu n'est pas lisible ! (2) Peut-être avez-vous fourni un fichier au mauvais format (txt, xls, ...) """ ) from exc @@ -611,7 +613,7 @@ def excel_workbook_to_list(filelike): workbook = _open_workbook(filelike) except Exception as exc: raise ScoValueError( - """Le fichier xlsx attendu n'est pas lisible ! + """Le fichier xlsx attendu n'est pas lisible ! (3) Peut-être avez-vous fourni un fichier au mauvais format (txt, xls, ...) """ ) from exc diff --git a/app/scodoc/sco_exceptions.py b/app/scodoc/sco_exceptions.py index 53b1711c2..741ad9fdb 100644 --- a/app/scodoc/sco_exceptions.py +++ b/app/scodoc/sco_exceptions.py @@ -200,11 +200,11 @@ class ScoNoReferentielCompetences(ScoValueError): super().__init__(msg) -class ScoGenError(ScoException): +class ScoGenError(ScoValueError): "exception avec affichage d'une page explicative ad-hoc" - def __init__(self, msg=""): - super().__init__(msg) + def __init__(self, msg="", safe=False): + super().__init__(msg, safe=safe) class AccessDenied(ScoGenError): diff --git a/app/scodoc/sco_moduleimpl_status.py b/app/scodoc/sco_moduleimpl_status.py index 514321f9f..8fe8eb3f4 100644 --- a/app/scodoc/sco_moduleimpl_status.py +++ b/app/scodoc/sco_moduleimpl_status.py @@ -478,8 +478,17 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): Trier par date + }" title="Ordonner les évaluations par date">Trier par date """ + bot_table_links = ( + top_table_links + + f""" + Importer les notes + """ + ) if nb_evaluations > 0: H.append( '