From c039c02484ae2f5e4ae6445fd8dc2723e6bde43b Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 6 Feb 2023 13:05:39 +0100 Subject: [PATCH] tables: reorganisation, corrections. --- app/api/jury.py | 8 +- app/but/jury_but_results.py | 94 ++++++ app/scodoc/sco_pvjury.py | 4 +- app/scodoc/sco_recapcomplet.py | 2 +- app/static/js/table_recap.js | 2 + .../jury_recap.py} | 275 +----------------- app/tables/recap.py | 27 +- app/views/notes.py | 5 +- 8 files changed, 134 insertions(+), 283 deletions(-) create mode 100644 app/but/jury_but_results.py rename app/{but/jury_but_recap.py => tables/jury_recap.py} (59%) diff --git a/app/api/jury.py b/app/api/jury.py index f31d1a788..383396e58 100644 --- a/app/api/jury.py +++ b/app/api/jury.py @@ -5,7 +5,7 @@ ############################################################################## """ - ScoDoc 9 API : jury + ScoDoc 9 API : jury WIP """ from flask import g, jsonify, request @@ -17,8 +17,8 @@ from app.api import api_bp as bp, api_web_bp from app.decorators import scodoc, permission_required from app.scodoc.sco_exceptions import ScoException from app.scodoc.sco_utils import json_error -from app.but import jury_but_recap -from app.models import FormSemestre, FormSemestreInscription, Identite +from app.but import jury_but_results +from app.models import FormSemestre from app.scodoc.sco_permissions import Permission @@ -33,7 +33,7 @@ def decisions_jury(formsemestre_id: int): formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id) if formsemestre.formation.is_apc(): app.set_sco_dept(formsemestre.departement.acronym) - rows = jury_but_recap.get_jury_but_results(formsemestre) + rows = jury_but_results.get_jury_but_results(formsemestre) return jsonify(rows) else: raise ScoException("non implemente") diff --git a/app/but/jury_but_results.py b/app/but/jury_but_results.py new file mode 100644 index 000000000..79aa14df3 --- /dev/null +++ b/app/but/jury_but_results.py @@ -0,0 +1,94 @@ +############################################################################## +# ScoDoc +# Copyright (c) 1999 - 2023 Emmanuel Viennet. All rights reserved. +# See LICENSE +############################################################################## + +"""Jury BUT et classiques: récupération des résults pour API +""" + +import numpy as np + +from app.but import jury_but +from app.models.etudiants import Identite +from app.models.formsemestre import FormSemestre +from app.scodoc import sco_pvjury + + +def get_jury_but_results(formsemestre: FormSemestre) -> list[dict]: + """Liste des résultats jury BUT sous forme de dict, pour API""" + if formsemestre.formation.referentiel_competence is None: + # pas de ref. comp., donc pas de decisions de jury (ne lance pas d'exception) + return [] + dpv = sco_pvjury.dict_pvjury(formsemestre.id) + rows = [] + for etudid in formsemestre.etuds_inscriptions: + rows.append(_get_jury_but_etud_result(formsemestre, dpv, etudid)) + return rows + + +def _get_jury_but_etud_result( + formsemestre: FormSemestre, dpv: dict, etudid: int +) -> dict: + """Résultats de jury d'un étudiant sur un semestre pair de BUT""" + etud: Identite = Identite.query.get(etudid) + dec_etud = dpv["decisions_dict"][etudid] + if formsemestre.formation.is_apc(): + deca = jury_but.DecisionsProposeesAnnee(etud, formsemestre) + else: + deca = None + row = { + "etudid": etud.id, + "code_nip": etud.code_nip, + "code_ine": etud.code_ine, + "is_apc": dpv["is_apc"], # BUT ou classic ? + "etat": dec_etud["etat"], # I ou D ou DEF + "nb_competences": deca.nb_competences if deca else 0, + } + # --- Les RCUEs + rcue_list = [] + if deca: + for rcue in deca.rcues_annee: + dec_rcue = deca.dec_rcue_by_ue.get(rcue.ue_1.id) + if dec_rcue is not None: # None si l'UE n'est pas associée à un niveau + dec_ue1 = deca.decisions_ues[rcue.ue_1.id] + dec_ue2 = deca.decisions_ues[rcue.ue_2.id] + rcue_dict = { + "ue_1": { + "ue_id": rcue.ue_1.id, + "moy": None + if (dec_ue1.moy_ue is None or np.isnan(dec_ue1.moy_ue)) + else dec_ue1.moy_ue, + "code": dec_ue1.code_valide, + }, + "ue_2": { + "ue_id": rcue.ue_2.id, + "moy": None + if (dec_ue2.moy_ue is None or np.isnan(dec_ue2.moy_ue)) + else dec_ue2.moy_ue, + "code": dec_ue2.code_valide, + }, + "moy": rcue.moy_rcue, + "code": dec_rcue.code_valide, + } + rcue_list.append(rcue_dict) + row["rcues"] = rcue_list + # --- Les UEs + ue_list = [] + if dec_etud["decisions_ue"]: + for ue_id, ue_dec in dec_etud["decisions_ue"].items(): + ue_dict = { + "ue_id": ue_id, + "code": ue_dec["code"], + "ects": ue_dec["ects"], + } + ue_list.append(ue_dict) + row["ues"] = ue_list + # --- Le semestre (pour les formations classiques) + if dec_etud["decision_sem"]: + row["semestre"] = {"code": dec_etud["decision_sem"].get("code")} + else: + row["semestre"] = {} # APC, ... + # --- Autorisations + row["autorisations"] = dec_etud["autorisations"] + return row diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py index e323348de..416c985ba 100644 --- a/app/scodoc/sco_pvjury.py +++ b/app/scodoc/sco_pvjury.py @@ -522,9 +522,9 @@ def formsemestre_pvjury(formsemestre_id, format="html", publish=True): formsemestre = FormSemestre.query.get_or_404(formsemestre_id) is_apc = formsemestre.formation.is_apc() if format == "html" and is_apc and formsemestre.semestre_id % 2 == 0: - from app.but import jury_but_recap + from app.tables import jury_recap - return jury_but_recap.formsemestre_saisie_jury_but( + return jury_recap.formsemestre_saisie_jury_but( formsemestre, read_only=True, mode="recap" ) # /XXX diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py index 7343ceb2e..4c1a63401 100644 --- a/app/scodoc/sco_recapcomplet.py +++ b/app/scodoc/sco_recapcomplet.py @@ -54,7 +54,7 @@ from app.scodoc import sco_formsemestre_status from app.scodoc import sco_permissions_check from app.scodoc import sco_preferences from app.tables.recap import TableRecap -from app.but.jury_but_recap import TableJury +from app.tables.jury_recap import TableJury def formsemestre_recapcomplet( diff --git a/app/static/js/table_recap.js b/app/static/js/table_recap.js index 9597f9dbb..0e2f9f109 100644 --- a/app/static/js/table_recap.js +++ b/app/static/js/table_recap.js @@ -1,6 +1,8 @@ // Tableau recap notes $(function () { $(function () { + if ($('table.table_recap').length == 0) { return; } + let hidden_colums = [ "etud_codes", "identite_detail", "partition_aux", "partition_rangs", "admission", diff --git a/app/but/jury_but_recap.py b/app/tables/jury_recap.py similarity index 59% rename from app/but/jury_but_recap.py rename to app/tables/jury_recap.py index 6ac6ba0a9..ce9620026 100644 --- a/app/but/jury_but_recap.py +++ b/app/tables/jury_recap.py @@ -230,6 +230,19 @@ class RowJury(RowRecap): column_classes={"col_rcue"}, ) + # # --- Les ECTS validés + # ects_valides = 0.0 + # if deca.res_impair: + # ects_valides += deca.res_impair.get_etud_ects_valides(etudid) + # if deca.res_pair: + # ects_valides += deca.res_pair.get_etud_ects_valides(etudid) + # row.add_cell( + # "ects_annee", + # "ECTS", + # f"""{int(ects_valides)}""", + # "col_code_annee", + # ) + def formsemestre_saisie_jury_but( formsemestre: FormSemestre, @@ -316,7 +329,7 @@ def formsemestre_saisie_jury_but(
{table_html}
- +