From 577cac00eeabde3fb9c441e5a0ab8d7ba8e4b5dd Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 2 Mar 2022 23:14:04 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Export=20des=20annotations=20sur=20des=20gr?= =?UTF-8?q?oupes=20d'=C3=A9tudiants.=20Closes=20#327?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_groups_exports.py | 96 ++++++++++++++++++++++++++++++++ app/scodoc/sco_groups_view.py | 2 + app/scodoc/sco_utils.py | 2 +- app/views/scolar.py | 13 +++-- sco_version.py | 2 +- 5 files changed, 107 insertions(+), 8 deletions(-) create mode 100644 app/scodoc/sco_groups_exports.py diff --git a/app/scodoc/sco_groups_exports.py b/app/scodoc/sco_groups_exports.py new file mode 100644 index 00000000..b2e95545 --- /dev/null +++ b/app/scodoc/sco_groups_exports.py @@ -0,0 +1,96 @@ +# -*- mode: python -*- +# -*- coding: utf-8 -*- + +############################################################################## +# +# Gestion scolarite IUT +# +# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Emmanuel Viennet emmanuel.viennet@viennet.net +# +############################################################################## + +"""Exports groupes +""" +from flask import request + +from app.scodoc import notesdb as ndb +from app.scodoc import sco_excel +from app.scodoc import sco_groups_view +from app.scodoc import sco_preferences +from app.scodoc.gen_tables import GenTable +import app.scodoc.sco_utils as scu +import sco_version + + +def groups_list_annotation(group_ids: list[int]) -> list[dict]: + """Renvoie la liste des annotations pour les groupes d"étudiants indiqués + Arg: liste des id de groupes + Clés: etudid, ine, nip, nom, prenom, date, comment + """ + cnx = ndb.GetDBConnexion() + cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) + annotations = [] + for group_id in group_ids: + cursor.execute( + """SELECT i.id AS etudid, i.code_nip, i.code_ine, i.nom, i.prenom, ea.date, ea.comment + FROM group_membership gm, identite i, etud_annotations ea + WHERE gm.group_id=%(group_ids)s + AND gm.etudid=i.id + AND i.id=ea.etudid + """, + {"group_ids": group_id}, + ) + annotations += cursor.dictfetchall() + return annotations + + +def groups_export_annotations(group_ids, formsemestre_id=None, format="html"): + """Les annotations""" + groups_infos = sco_groups_view.DisplayedGroupsInfos( + group_ids, formsemestre_id=formsemestre_id + ) + annotations = groups_list_annotation(groups_infos.group_ids) + for annotation in annotations: + annotation["date_str"] = annotation["date"].strftime("%d/%m/%Y à %Hh%M") + if format == "xls": + columns_ids = ("etudid", "nom", "prenom", "date", "comment") + else: + columns_ids = ("etudid", "nom", "prenom", "date_str", "comment") + table = GenTable( + rows=annotations, + columns_ids=columns_ids, + titles={ + "etudid": "etudid", + "nom": "Nom", + "prenom": "Prénom", + "date": "Date", + "date_str": "Date", + "comment": "Annotation", + }, + origin="Généré par %s le " % sco_version.SCONAME + + scu.timedate_human_repr() + + "", + page_title=f"Annotations sur les étudiants de {groups_infos.groups_titles}", + caption="Annotations", + base_url=groups_infos.base_url, + html_sortable=True, + html_class="table_leftalign", + preferences=sco_preferences.SemPreferences(formsemestre_id), + ) + return table.make_page(format=format) diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index 5b89ab44..259256bd 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -826,6 +826,8 @@ def tab_absences_html(groups_infos, etat=None): % groups_infos.groups_query_args, """
  • Liste d'appel avec photos
  • """ % groups_infos.groups_query_args, + """
  • Liste des annotations
  • """ + % groups_infos.groups_query_args, "", ] ) diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 7af19bc1..196c2c21 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -810,7 +810,7 @@ def abbrev_prenom(prenom): # def timedate_human_repr(): - "representation du temps courant pour utilisateur: a localiser" + "representation du temps courant pour utilisateur" return time.strftime("%d/%m/%Y à %Hh%M") diff --git a/app/views/scolar.py b/app/views/scolar.py index 060fd4c3..680f1dd2 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -68,8 +68,6 @@ from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message import app from app.scodoc.gen_tables import GenTable from app.scodoc import html_sco_header -from app.scodoc import html_sidebar -from app.scodoc import imageresize from app.scodoc import sco_import_etuds from app.scodoc import sco_abs from app.scodoc import sco_archives_etud @@ -87,12 +85,9 @@ from app.scodoc import sco_formsemestre_edit from app.scodoc import sco_formsemestre_inscriptions from app.scodoc import sco_groups from app.scodoc import sco_groups_edit +from app.scodoc import sco_groups_exports from app.scodoc import sco_groups_view -from app.scodoc import sco_logos -from app.scodoc import sco_news from app.scodoc import sco_page_etud -from app.scodoc import sco_parcours_dut -from app.scodoc import sco_permissions from app.scodoc import sco_permissions_check from app.scodoc import sco_photos from app.scodoc import sco_portal_apogee @@ -364,6 +359,12 @@ sco_publish( methods=["GET", "POST"], ) +sco_publish( + "/groups_export_annotations", + sco_groups_exports.groups_export_annotations, + Permission.ScoView, +) + @bp.route("/groups_view") @scodoc diff --git a/sco_version.py b/sco_version.py index 19d27aea..337ea606 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.1.69" +SCOVERSION = "9.1.70" SCONAME = "ScoDoc" From e6be8d9ecb4385f03a73aa10cd33c91dc2e1b46e Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 3 Mar 2022 09:42:12 +0100 Subject: [PATCH 2/2] Bonus Calais --- app/comp/bonus_spo.py | 39 +++++++++++++++++++++++++++++++++++++++ sco_version.py | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/app/comp/bonus_spo.py b/app/comp/bonus_spo.py index d1c3ddca..1cbe4e59 100644 --- a/app/comp/bonus_spo.py +++ b/app/comp/bonus_spo.py @@ -21,6 +21,7 @@ from flask import g from app.models.formsemestre import FormSemestre from app.scodoc.sco_codes_parcours import UE_SPORT +from app.scodoc.sco_codes_parcours import ParcoursDUT, ParcoursDUTMono from app.scodoc.sco_utils import ModuleType @@ -538,6 +539,44 @@ class BonusCachan1(BonusSportAdditif): self.bonus_ues[ue.id] = 0.0 +class BonusCalais(BonusSportAdditif): + """Calcul bonus modules optionnels (sport, culture), règle IUT LCO. + + Les étudiants de l'IUT LCO peuvent suivre des enseignements optionnels non + rattachés à une unité d'enseignement. Les points au-dessus de 10 + sur 20 obtenus dans chacune des matières optionnelles sont cumulés + dans la limite de 10 points. 6% de ces points cumulés s'ajoutent : + + """ + + name = "bonus_calais" + displayed_name = "IUT du Littoral" + bonus_max = 0.6 + seuil_moy_gen = 10.0 # au dessus de 10 + proportion_point = 0.06 # 6% + + def compute_bonus(self, sem_modimpl_moys_inscrits, modimpl_coefs_etuds_no_nan): + parcours = self.formsemestre.formation.get_parcours() + # Variantes de DUT ? + if ( + isinstance(parcours, ParcoursDUT) + or parcours.TYPE_PARCOURS == ParcoursDUTMono.TYPE_PARCOURS + ): # DUT + super().compute_bonus(sem_modimpl_moys_inscrits, modimpl_coefs_etuds_no_nan) + else: + self.classic_use_bonus_ues = True # pour les LP + super().compute_bonus(sem_modimpl_moys_inscrits, modimpl_coefs_etuds_no_nan) + ues = self.formsemestre.query_ues(with_sport=False).all() + ues_sans_bs = [ + ue for ue in ues if ue.acronyme[-2:].upper() != "BS" + ] # les 2 derniers cars forcés en majus + for ue in ues_sans_bs: + self.bonus_ues[ue.id] = 0.0 + + class BonusColmar(BonusSportAdditif): """Calcul bonus modules optionnels (sport, culture), règle IUT Colmar. diff --git a/sco_version.py b/sco_version.py index 337ea606..55ce771d 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.1.70" +SCOVERSION = "9.1.71" SCONAME = "ScoDoc"