2020-09-26 16:19:37 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2023-01-02 13:16:27 +01:00
|
|
|
# Copyright (c) 1999 - 2023 Emmanuel Viennet. All rights reserved.
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Génération des bulletins de notes
|
|
|
|
|
|
|
|
"""
|
2023-03-08 22:23:55 +01:00
|
|
|
import collections
|
2020-12-15 08:35:44 +01:00
|
|
|
import email
|
2022-02-14 23:21:42 +01:00
|
|
|
import time
|
2022-09-18 16:53:00 +02:00
|
|
|
import numpy as np
|
2021-07-29 16:31:15 +02:00
|
|
|
|
2021-09-18 10:10:02 +02:00
|
|
|
from flask import g, request
|
2022-04-26 07:35:06 +02:00
|
|
|
from flask import flash, jsonify, render_template, url_for
|
2021-07-29 16:31:15 +02:00
|
|
|
from flask_login import current_user
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-02-14 23:21:42 +01:00
|
|
|
from app import email
|
2021-08-29 19:57:32 +02:00
|
|
|
from app import log
|
2022-08-07 19:56:25 +02:00
|
|
|
from app.scodoc.sco_utils import json_error
|
2022-02-14 23:21:42 +01:00
|
|
|
from app.but import bulletin_but
|
2022-01-16 23:47:52 +01:00
|
|
|
from app.comp import res_sem
|
2022-03-27 22:25:00 +02:00
|
|
|
from app.comp.res_compat import NotesTableCompat
|
2023-02-18 00:13:00 +01:00
|
|
|
from app.models import Formation, FormSemestre, Identite, ModuleImplInscription
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc.sco_permissions import Permission
|
2021-09-18 13:42:19 +02:00
|
|
|
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import html_sco_header
|
2021-07-11 17:37:12 +02:00
|
|
|
from app.scodoc import htmlutils
|
2021-06-21 10:17:16 +02:00
|
|
|
from app.scodoc import sco_abs
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_abs_views
|
|
|
|
from app.scodoc import sco_bulletins_generator
|
|
|
|
from app.scodoc import sco_bulletins_json
|
2022-02-14 23:21:42 +01:00
|
|
|
from app.scodoc import sco_bulletins_pdf
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_bulletins_xml
|
2023-02-12 13:36:47 +01:00
|
|
|
from app.scodoc import codes_cursus
|
2021-07-05 23:41:22 +02:00
|
|
|
from app.scodoc import sco_etud
|
2021-11-12 22:17:46 +01:00
|
|
|
from app.scodoc import sco_evaluation_db
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_formsemestre
|
|
|
|
from app.scodoc import sco_groups
|
|
|
|
from app.scodoc import sco_preferences
|
2023-02-19 15:45:27 +01:00
|
|
|
from app.scodoc import sco_pv_dict
|
2021-07-05 23:41:22 +02:00
|
|
|
from app.scodoc import sco_users
|
2022-02-14 23:21:42 +01:00
|
|
|
import app.scodoc.sco_utils as scu
|
2022-02-21 19:25:38 +01:00
|
|
|
from app.scodoc.sco_utils import ModuleType, fmt_note
|
2022-02-14 23:21:42 +01:00
|
|
|
import app.scodoc.notesdb as ndb
|
2021-06-19 23:21:37 +02:00
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-04-26 07:35:06 +02:00
|
|
|
def get_formsemestre_bulletin_etud_json(
|
|
|
|
formsemestre: FormSemestre,
|
|
|
|
etud: Identite,
|
|
|
|
force_publishing=False,
|
|
|
|
version="long",
|
|
|
|
) -> str:
|
|
|
|
"""Le JSON du bulletin d'un étudiant, quel que soit le type de formation."""
|
|
|
|
if formsemestre.formation.is_apc():
|
2022-08-07 19:56:25 +02:00
|
|
|
bul = bulletin_but.BulletinBUT(formsemestre)
|
|
|
|
if not etud.id in bul.res.identdict:
|
2022-08-08 10:34:13 +02:00
|
|
|
return json_error(404, "get_formsemestre_bulletin_etud_json: invalid etud")
|
2022-04-26 07:35:06 +02:00
|
|
|
return jsonify(
|
2022-08-07 19:56:25 +02:00
|
|
|
bul.bulletin_etud(
|
2022-04-26 07:35:06 +02:00
|
|
|
etud,
|
|
|
|
formsemestre,
|
|
|
|
force_publishing=force_publishing,
|
|
|
|
version=version,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return formsemestre_bulletinetud(
|
|
|
|
etud,
|
|
|
|
formsemestre_id=formsemestre.id,
|
|
|
|
format="json",
|
|
|
|
version=version,
|
|
|
|
xml_with_decisions=True,
|
|
|
|
force_publishing=force_publishing,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# -------------
|
2022-03-05 12:47:08 +01:00
|
|
|
def make_context_dict(formsemestre: FormSemestre, etud: dict) -> dict:
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Construit dictionnaire avec valeurs pour substitution des textes
|
|
|
|
(preferences bul_pdf_*)
|
|
|
|
"""
|
2022-03-05 12:47:08 +01:00
|
|
|
C = formsemestre.get_infos_dict()
|
|
|
|
C["responsable"] = formsemestre.responsables_str()
|
|
|
|
C["anneesem"] = C["annee"] # backward compat
|
2020-09-26 16:19:37 +02:00
|
|
|
C.update(etud)
|
|
|
|
# copie preferences
|
2021-07-29 10:19:00 +02:00
|
|
|
for name in sco_preferences.get_base_preferences().prefs_name:
|
2022-03-05 12:47:08 +01:00
|
|
|
C[name] = sco_preferences.get_preference(name, formsemestre.id)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# ajoute groupes et group_0, group_1, ...
|
2022-03-05 12:47:08 +01:00
|
|
|
sco_groups.etud_add_group_infos(etud, formsemestre.id)
|
2020-09-26 16:19:37 +02:00
|
|
|
C["groupes"] = etud["groupes"]
|
|
|
|
n = 0
|
|
|
|
for partition_id in etud["partitions"]:
|
|
|
|
C["group_%d" % n] = etud["partitions"][partition_id]["group_name"]
|
|
|
|
n += 1
|
|
|
|
|
|
|
|
# ajoute date courante
|
|
|
|
t = time.localtime()
|
|
|
|
C["date_dmy"] = time.strftime("%d/%m/%Y", t)
|
|
|
|
C["date_iso"] = time.strftime("%Y-%m-%d", t)
|
|
|
|
|
|
|
|
return C
|
|
|
|
|
|
|
|
|
2021-09-18 13:42:19 +02:00
|
|
|
def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Collecte informations pour bulletin de notes
|
|
|
|
Retourne un dictionnaire (avec valeur par défaut chaine vide).
|
2020-12-02 01:00:23 +01:00
|
|
|
Le contenu du dictionnaire dépend des options (rangs, ...)
|
2020-09-26 16:19:37 +02:00
|
|
|
et de la version choisie (short, long, selectedevals).
|
|
|
|
|
2022-03-05 12:47:08 +01:00
|
|
|
Cette fonction est utilisée pour les bulletins CLASSIQUES (DUT, ...)
|
|
|
|
en HTML et PDF, mais pas ceux en XML.
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_abs
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
if not version in scu.BULLETINS_VERSIONS:
|
2020-09-26 16:19:37 +02:00
|
|
|
raise ValueError("invalid version code !")
|
|
|
|
|
2021-07-28 17:03:54 +02:00
|
|
|
prefs = sco_preferences.SemPreferences(formsemestre_id)
|
2022-01-16 23:47:52 +01:00
|
|
|
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
2022-02-06 16:09:17 +01:00
|
|
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
2021-09-30 17:50:37 +02:00
|
|
|
if not nt.get_etud_etat(etudid):
|
2022-09-03 11:41:56 +02:00
|
|
|
raise ScoValueError("Étudiant non inscrit à ce semestre")
|
2023-03-08 22:23:55 +01:00
|
|
|
I = collections.defaultdict(str)
|
2020-09-26 16:19:37 +02:00
|
|
|
I["etudid"] = etudid
|
|
|
|
I["formsemestre_id"] = formsemestre_id
|
2022-02-09 00:36:50 +01:00
|
|
|
I["sem"] = formsemestre.get_infos_dict()
|
2021-09-18 13:42:19 +02:00
|
|
|
I["server_name"] = request.url_root
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Formation et parcours
|
2022-06-23 17:53:27 +02:00
|
|
|
if I["sem"]["formation_id"]:
|
2023-02-18 00:13:00 +01:00
|
|
|
formation_dict = Formation.query.get_or_404(I["sem"]["formation_id"]).to_dict()
|
|
|
|
else: # what's the fuck ?
|
2022-07-13 12:03:53 +02:00
|
|
|
formation_dict = {
|
2022-06-23 17:53:27 +02:00
|
|
|
"acronyme": "?",
|
|
|
|
"code_specialite": "",
|
|
|
|
"dept_id": 1,
|
|
|
|
"formation_code": "?",
|
|
|
|
"formation_id": -1,
|
|
|
|
"id": -1,
|
|
|
|
"referentiel_competence_id": None,
|
|
|
|
"titre": "?",
|
|
|
|
"titre_officiel": "?",
|
|
|
|
"type_parcours": 0,
|
|
|
|
"version": 0,
|
|
|
|
}
|
2022-07-13 12:03:53 +02:00
|
|
|
I["formation"] = formation_dict
|
2023-02-12 13:36:47 +01:00
|
|
|
I["parcours"] = codes_cursus.get_cursus_from_code(I["formation"]["type_parcours"])
|
2020-09-26 16:19:37 +02:00
|
|
|
# Infos sur l'etudiant
|
2021-08-22 13:24:36 +02:00
|
|
|
I["etud"] = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
I["descr_situation"] = I["etud"]["inscriptionstr"]
|
|
|
|
if I["etud"]["inscription_formsemestre_id"]:
|
2020-12-02 01:00:23 +01:00
|
|
|
I[
|
|
|
|
"descr_situation_html"
|
2021-08-15 21:33:47 +02:00
|
|
|
] = f"""<a href="{url_for(
|
|
|
|
"notes.formsemestre_status",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
formsemestre_id=I["etud"]["inscription_formsemestre_id"],
|
|
|
|
)}">{I["descr_situation"]}</a>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
I["descr_situation_html"] = I["descr_situation"]
|
|
|
|
# Groupes:
|
2021-08-19 10:28:35 +02:00
|
|
|
partitions = sco_groups.get_partitions_list(formsemestre_id, with_default=False)
|
2020-09-26 16:19:37 +02:00
|
|
|
partitions_etud_groups = {} # { partition_id : { etudid : group } }
|
|
|
|
for partition in partitions:
|
|
|
|
pid = partition["partition_id"]
|
2021-08-19 10:28:35 +02:00
|
|
|
partitions_etud_groups[pid] = sco_groups.get_etud_groups_in_partition(pid)
|
2020-09-26 16:19:37 +02:00
|
|
|
# --- Absences
|
2021-07-19 19:53:01 +02:00
|
|
|
I["nbabs"], I["nbabsjust"] = sco_abs.get_abs_count(etudid, nt.sem)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# --- Decision Jury
|
|
|
|
infos, dpv = etud_descr_situation_semestre(
|
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
format="html",
|
|
|
|
show_date_inscr=prefs["bul_show_date_inscr"],
|
|
|
|
show_decisions=prefs["bul_show_decision"],
|
|
|
|
show_uevalid=prefs["bul_show_uevalid"],
|
|
|
|
show_mention=prefs["bul_show_mention"],
|
|
|
|
)
|
|
|
|
|
|
|
|
I.update(infos)
|
|
|
|
|
2022-01-16 23:47:52 +01:00
|
|
|
I["etud_etat_html"] = _get_etud_etat_html(
|
|
|
|
formsemestre.etuds_inscriptions[etudid].etat
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
I["etud_etat"] = nt.get_etud_etat(etudid)
|
2022-02-21 19:25:38 +01:00
|
|
|
I["filigranne"] = sco_bulletins_pdf.get_filigranne(
|
2022-03-05 12:47:08 +01:00
|
|
|
I["etud_etat"], prefs, decision_sem=I["decision_sem"]
|
2022-02-21 19:25:38 +01:00
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
I["demission"] = ""
|
2022-02-14 23:21:42 +01:00
|
|
|
if I["etud_etat"] == scu.DEMISSION:
|
2020-09-26 16:19:37 +02:00
|
|
|
I["demission"] = "(Démission)"
|
2023-02-12 13:36:47 +01:00
|
|
|
elif I["etud_etat"] == codes_cursus.DEF:
|
2020-09-26 16:19:37 +02:00
|
|
|
I["demission"] = "(Défaillant)"
|
|
|
|
|
|
|
|
# --- Appreciations
|
2022-02-21 19:25:38 +01:00
|
|
|
I.update(get_appreciations_list(formsemestre_id, etudid))
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# --- Notes
|
2021-12-24 00:08:25 +01:00
|
|
|
ues = nt.get_ues_stat_dict()
|
2021-12-26 19:15:47 +01:00
|
|
|
modimpls = nt.get_modimpls_dict()
|
2020-09-26 16:19:37 +02:00
|
|
|
moy_gen = nt.get_etud_moy_gen(etudid)
|
2021-12-24 00:08:25 +01:00
|
|
|
I["nb_inscrits"] = len(nt.etud_moy_gen_ranks)
|
2021-02-01 16:23:11 +01:00
|
|
|
I["moy_gen"] = scu.fmt_note(moy_gen)
|
|
|
|
I["moy_min"] = scu.fmt_note(nt.moy_min)
|
|
|
|
I["moy_max"] = scu.fmt_note(nt.moy_max)
|
2020-09-26 16:19:37 +02:00
|
|
|
I["mention"] = ""
|
|
|
|
if dpv:
|
|
|
|
decision_sem = dpv["decisions"][0]["decision_sem"]
|
2023-02-12 13:36:47 +01:00
|
|
|
if decision_sem and codes_cursus.code_semestre_validant(decision_sem["code"]):
|
2021-02-01 16:23:11 +01:00
|
|
|
I["mention"] = scu.get_mention(moy_gen)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if dpv and dpv["decisions"][0]:
|
|
|
|
I["sum_ects"] = dpv["decisions"][0]["sum_ects"]
|
|
|
|
I["sum_ects_capitalises"] = dpv["decisions"][0]["sum_ects_capitalises"]
|
|
|
|
else:
|
|
|
|
I["sum_ects"] = 0
|
|
|
|
I["sum_ects_capitalises"] = 0
|
2021-02-01 16:23:11 +01:00
|
|
|
I["moy_moy"] = scu.fmt_note(nt.moy_moy) # moyenne des moyennes generales
|
2021-07-11 18:18:44 +02:00
|
|
|
if (not isinstance(moy_gen, str)) and (not isinstance(nt.moy_moy, str)):
|
2020-09-26 16:19:37 +02:00
|
|
|
I["moy_gen_bargraph_html"] = " " + htmlutils.horizontal_bargraph(
|
|
|
|
moy_gen * 5, nt.moy_moy * 5
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
I["moy_gen_bargraph_html"] = ""
|
|
|
|
|
|
|
|
if prefs["bul_show_rangs"]:
|
|
|
|
rang = str(nt.get_etud_rang(etudid))
|
|
|
|
else:
|
|
|
|
rang = ""
|
|
|
|
|
|
|
|
rang_gr, ninscrits_gr, gr_name = get_etud_rangs_groups(
|
2022-05-18 20:43:01 +02:00
|
|
|
etudid, partitions, partitions_etud_groups, nt
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if nt.get_moduleimpls_attente():
|
|
|
|
# n'affiche pas le rang sur le bulletin s'il y a des
|
|
|
|
# notes en attente dans ce semestre
|
2021-02-01 16:23:11 +01:00
|
|
|
rang = scu.RANG_ATTENTE_STR
|
2023-03-08 22:23:55 +01:00
|
|
|
rang_gr = collections.defaultdict(lambda: scu.RANG_ATTENTE_STR)
|
2022-01-16 23:47:52 +01:00
|
|
|
inscriptions_counts = nt.get_inscriptions_counts()
|
2020-09-26 16:19:37 +02:00
|
|
|
I["rang"] = rang
|
|
|
|
I["rang_gr"] = rang_gr
|
|
|
|
I["gr_name"] = gr_name
|
|
|
|
I["ninscrits_gr"] = ninscrits_gr
|
2021-12-24 00:08:25 +01:00
|
|
|
I["nbetuds"] = len(nt.etud_moy_gen_ranks)
|
2022-01-16 23:47:52 +01:00
|
|
|
I["nb_demissions"] = inscriptions_counts[scu.DEMISSION]
|
|
|
|
I["nb_defaillants"] = inscriptions_counts[scu.DEF]
|
2020-09-26 16:19:37 +02:00
|
|
|
if prefs["bul_show_rangs"]:
|
|
|
|
I["rang_nt"] = "%s / %d" % (
|
|
|
|
rang,
|
2022-01-16 23:47:52 +01:00
|
|
|
inscriptions_counts[scu.INSCRIT],
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
I["rang_txt"] = "Rang " + I["rang_nt"]
|
|
|
|
else:
|
|
|
|
I["rang_nt"], I["rang_txt"] = "", ""
|
|
|
|
I["note_max"] = 20.0 # notes toujours sur 20
|
2022-01-25 10:45:13 +01:00
|
|
|
I["bonus_sport_culture"] = nt.bonus[etudid] if nt.bonus is not None else 0.0
|
2020-09-26 16:19:37 +02:00
|
|
|
# Liste les UE / modules /evals
|
|
|
|
I["ues"] = []
|
|
|
|
I["matieres_modules"] = {}
|
|
|
|
I["matieres_modules_capitalized"] = {}
|
|
|
|
for ue in ues:
|
2022-02-27 20:12:20 +01:00
|
|
|
u = ue.copy()
|
|
|
|
ue_status = nt.get_etud_ue_status(etudid, ue["ue_id"])
|
2022-01-25 10:45:13 +01:00
|
|
|
if (
|
|
|
|
ModuleImplInscription.nb_inscriptions_dans_ue(
|
|
|
|
formsemestre_id, etudid, ue["ue_id"]
|
|
|
|
)
|
|
|
|
== 0
|
2022-02-27 20:12:20 +01:00
|
|
|
) and not ue_status["is_capitalized"]:
|
|
|
|
# saute les UE où l'on est pas inscrit et n'avons pas de capitalisation
|
2022-01-25 10:45:13 +01:00
|
|
|
continue
|
2022-02-27 20:12:20 +01:00
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
u["ue_status"] = ue_status # { 'moy', 'coef_ue', ...}
|
2023-02-12 13:36:47 +01:00
|
|
|
if ue["type"] != codes_cursus.UE_SPORT:
|
2021-02-01 16:23:11 +01:00
|
|
|
u["cur_moy_ue_txt"] = scu.fmt_note(ue_status["cur_moy_ue"])
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2022-01-25 10:45:13 +01:00
|
|
|
if nt.bonus is not None:
|
|
|
|
x = scu.fmt_note(nt.bonus[etudid], keep_numeric=True)
|
|
|
|
else:
|
|
|
|
x = ""
|
2021-07-11 18:18:44 +02:00
|
|
|
if isinstance(x, str):
|
2022-01-29 22:45:39 +01:00
|
|
|
if nt.bonus_ues is None:
|
|
|
|
u["cur_moy_ue_txt"] = "pas de bonus"
|
|
|
|
else:
|
|
|
|
u["cur_moy_ue_txt"] = "bonus appliqué sur les UEs"
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2022-02-21 19:25:38 +01:00
|
|
|
u["cur_moy_ue_txt"] = f"bonus de {fmt_note(x)} points"
|
2022-02-18 14:15:29 +01:00
|
|
|
if nt.bonus_ues is not None:
|
|
|
|
u["cur_moy_ue_txt"] += " (+ues)"
|
2021-02-01 16:23:11 +01:00
|
|
|
u["moy_ue_txt"] = scu.fmt_note(ue_status["moy"])
|
2020-09-26 16:19:37 +02:00
|
|
|
if ue_status["coef_ue"] != None:
|
2021-02-01 16:23:11 +01:00
|
|
|
u["coef_ue_txt"] = scu.fmt_coef(ue_status["coef_ue"])
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2022-03-01 10:33:53 +01:00
|
|
|
u["coef_ue_txt"] = "-"
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if (
|
|
|
|
dpv
|
|
|
|
and dpv["decisions"][0]["decisions_ue"]
|
|
|
|
and ue["ue_id"] in dpv["decisions"][0]["decisions_ue"]
|
|
|
|
):
|
|
|
|
u["ects"] = dpv["decisions"][0]["decisions_ue"][ue["ue_id"]]["ects"]
|
2023-02-12 13:36:47 +01:00
|
|
|
if ue["type"] == codes_cursus.UE_ELECTIVE:
|
2020-09-26 16:19:37 +02:00
|
|
|
u["ects"] = (
|
|
|
|
"%g+" % u["ects"]
|
|
|
|
) # ajoute un "+" pour indiquer ECTS d'une UE élective
|
|
|
|
else:
|
|
|
|
if ue_status["is_capitalized"]:
|
|
|
|
u["ects"] = ue_status["ue"].get("ects", "-")
|
|
|
|
else:
|
|
|
|
u["ects"] = "-"
|
|
|
|
modules, ue_attente = _ue_mod_bulletin(
|
2021-08-21 00:24:51 +02:00
|
|
|
etudid, formsemestre_id, ue["ue_id"], modimpls, nt, version
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
#
|
|
|
|
u["modules"] = modules # detail des modules de l'UE (dans le semestre courant)
|
|
|
|
# auparavant on filtrait les modules sans notes
|
|
|
|
# si ue_status['cur_moy_ue'] != 'NA' alors u['modules'] = [] (pas de moyenne => pas de modules)
|
|
|
|
|
|
|
|
u[
|
|
|
|
"modules_capitalized"
|
|
|
|
] = [] # modules de l'UE capitalisée (liste vide si pas capitalisée)
|
2022-07-11 18:33:48 +02:00
|
|
|
if ue_status["is_capitalized"] and ue_status["formsemestre_id"] is not None:
|
|
|
|
sem_origin = FormSemestre.query.get(ue_status["formsemestre_id"])
|
2020-12-02 01:00:23 +01:00
|
|
|
u[
|
2022-07-11 18:33:48 +02:00
|
|
|
"ue_descr_txt"
|
|
|
|
] = f'capitalisée le {ndb.DateISOtoDMY(ue_status["event_date"])}'
|
|
|
|
u["ue_descr_html"] = (
|
|
|
|
f"""<a href="{ url_for( 'notes.formsemestre_bulletinetud',
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=sem_origin.id, etudid=etudid)}"
|
|
|
|
title="{sem_origin.titre_annee()}" class="bull_link"
|
|
|
|
>{u["ue_descr_txt"]}</a>
|
2022-02-10 11:54:03 +01:00
|
|
|
"""
|
2022-07-11 18:33:48 +02:00
|
|
|
if sem_origin
|
|
|
|
else ""
|
|
|
|
)
|
|
|
|
if ue_status["moy"] != "NA":
|
2022-02-13 23:53:11 +01:00
|
|
|
# détail des modules de l'UE capitalisée
|
2022-07-11 18:33:48 +02:00
|
|
|
formsemestre_cap = FormSemestre.query.get(ue_status["formsemestre_id"])
|
2022-02-09 23:22:00 +01:00
|
|
|
nt_cap: NotesTableCompat = res_sem.load_formsemestre_results(
|
|
|
|
formsemestre_cap
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2020-12-15 08:35:44 +01:00
|
|
|
u["modules_capitalized"], _ = _ue_mod_bulletin(
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
ue_status["capitalized_ue_id"],
|
2021-12-26 19:15:47 +01:00
|
|
|
nt_cap.get_modimpls_dict(),
|
2020-09-26 16:19:37 +02:00
|
|
|
nt_cap,
|
|
|
|
version,
|
|
|
|
)
|
|
|
|
I["matieres_modules_capitalized"].update(
|
|
|
|
_sort_mod_by_matiere(u["modules_capitalized"], nt_cap, etudid)
|
|
|
|
)
|
|
|
|
else:
|
2023-02-12 13:36:47 +01:00
|
|
|
if prefs["bul_show_ue_rangs"] and ue["type"] != codes_cursus.UE_SPORT:
|
2022-01-29 22:45:39 +01:00
|
|
|
if ue_attente or nt.ue_rangs[ue["ue_id"]][0] is None:
|
2020-09-26 16:19:37 +02:00
|
|
|
u["ue_descr_txt"] = "%s/%s" % (
|
2021-02-01 16:23:11 +01:00
|
|
|
scu.RANG_ATTENTE_STR,
|
2020-09-26 16:19:37 +02:00
|
|
|
nt.ue_rangs[ue["ue_id"]][1],
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
u["ue_descr_txt"] = "%s/%s" % (
|
|
|
|
nt.ue_rangs[ue["ue_id"]][0][etudid],
|
|
|
|
nt.ue_rangs[ue["ue_id"]][1],
|
|
|
|
)
|
|
|
|
u["ue_descr_html"] = u["ue_descr_txt"]
|
|
|
|
else:
|
|
|
|
u["ue_descr_txt"] = u["ue_descr_html"] = ""
|
|
|
|
|
|
|
|
if ue_status["is_capitalized"] or modules:
|
|
|
|
I["ues"].append(u) # ne montre pas les UE si non inscrit
|
|
|
|
|
|
|
|
# Accès par matieres
|
2022-01-29 22:45:39 +01:00
|
|
|
# En #sco92, pas d'information
|
|
|
|
I["matieres_modules"].update(_sort_mod_by_matiere(modules, nt, etudid))
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
#
|
2022-03-05 12:47:08 +01:00
|
|
|
C = make_context_dict(formsemestre, I["etud"])
|
2020-09-26 16:19:37 +02:00
|
|
|
C.update(I)
|
|
|
|
#
|
|
|
|
# log( 'C = \n%s\n' % pprint.pformat(C) ) # tres pratique pour voir toutes les infos dispo
|
|
|
|
return C
|
|
|
|
|
|
|
|
|
2022-02-21 19:25:38 +01:00
|
|
|
def get_appreciations_list(formsemestre_id: int, etudid: int) -> dict:
|
|
|
|
"""Appréciations pour cet étudiant dans ce semestre"""
|
|
|
|
cnx = ndb.GetDBConnexion()
|
|
|
|
apprecs = sco_etud.appreciations_list(
|
|
|
|
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
|
|
|
|
)
|
|
|
|
d = {
|
|
|
|
"appreciations_list": apprecs,
|
|
|
|
"appreciations_txt": [x["date"] + ": " + x["comment"] for x in apprecs],
|
|
|
|
}
|
|
|
|
# deprecated / keep it for backward compat in templates:
|
|
|
|
d["appreciations"] = d["appreciations_txt"]
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
2022-01-16 23:47:52 +01:00
|
|
|
def _get_etud_etat_html(etat: str) -> str:
|
|
|
|
"""chaine html représentant l'état (backward compat sco7)"""
|
2022-09-30 22:43:39 +02:00
|
|
|
if etat == scu.INSCRIT:
|
2022-01-16 23:47:52 +01:00
|
|
|
return ""
|
2022-09-30 22:43:39 +02:00
|
|
|
elif etat == scu.DEMISSION:
|
2022-01-16 23:47:52 +01:00
|
|
|
return ' <font color="red">(DEMISSIONNAIRE)</font> '
|
2022-09-30 22:43:39 +02:00
|
|
|
elif etat == scu.DEF:
|
2022-01-16 23:47:52 +01:00
|
|
|
return ' <font color="red">(DEFAILLANT)</font> '
|
|
|
|
else:
|
2022-07-08 18:09:45 +02:00
|
|
|
return f' <font color="red">({etat})</font> '
|
2022-01-16 23:47:52 +01:00
|
|
|
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
def _sort_mod_by_matiere(modlist, nt, etudid):
|
|
|
|
matmod = {} # { matiere_id : [] }
|
|
|
|
for mod in modlist:
|
|
|
|
matiere_id = mod["module"]["matiere_id"]
|
|
|
|
if matiere_id not in matmod:
|
|
|
|
moy = nt.get_etud_mat_moy(matiere_id, etudid)
|
|
|
|
matmod[matiere_id] = {
|
|
|
|
"titre": mod["mat"]["titre"],
|
|
|
|
"modules": mod,
|
|
|
|
"moy": moy,
|
2021-02-01 16:23:11 +01:00
|
|
|
"moy_txt": scu.fmt_note(moy),
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
return matmod
|
|
|
|
|
|
|
|
|
2022-03-03 23:02:24 +01:00
|
|
|
def _ue_mod_bulletin(
|
|
|
|
etudid, formsemestre_id, ue_id, modimpls, nt: NotesTableCompat, version
|
|
|
|
):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Infos sur les modules (et évaluations) dans une UE
|
|
|
|
(ajoute les informations aux modimpls)
|
|
|
|
Result: liste de modules de l'UE avec les infos dans chacun (seulement ceux où l'étudiant est inscrit).
|
|
|
|
"""
|
2021-06-13 23:37:14 +02:00
|
|
|
bul_show_mod_rangs = sco_preferences.get_preference(
|
2021-07-28 17:03:54 +02:00
|
|
|
"bul_show_mod_rangs", formsemestre_id
|
2021-06-13 23:37:14 +02:00
|
|
|
)
|
|
|
|
bul_show_abs_modules = sco_preferences.get_preference(
|
2021-07-28 17:03:54 +02:00
|
|
|
"bul_show_abs_modules", formsemestre_id
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
if bul_show_abs_modules:
|
2021-08-19 10:28:35 +02:00
|
|
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
2021-02-01 16:23:11 +01:00
|
|
|
debut_sem = ndb.DateDMYtoISO(sem["date_debut"])
|
|
|
|
fin_sem = ndb.DateDMYtoISO(sem["date_fin"])
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
ue_modimpls = [mod for mod in modimpls if mod["module"]["ue_id"] == ue_id]
|
|
|
|
mods = [] # result
|
|
|
|
ue_attente = False # true si une eval en attente dans cette UE
|
|
|
|
for modimpl in ue_modimpls:
|
|
|
|
mod_attente = False
|
|
|
|
mod = modimpl.copy()
|
|
|
|
mod_moy = nt.get_etud_mod_moy(
|
|
|
|
modimpl["moduleimpl_id"], etudid
|
|
|
|
) # peut etre 'NI'
|
2021-11-12 22:17:46 +01:00
|
|
|
is_malus = mod["module"]["module_type"] == ModuleType.MALUS
|
2020-09-26 16:19:37 +02:00
|
|
|
if bul_show_abs_modules:
|
2021-07-19 19:53:01 +02:00
|
|
|
nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem)
|
|
|
|
mod_abs = [nbabs, nbabsjust]
|
2021-02-01 16:23:11 +01:00
|
|
|
mod["mod_abs_txt"] = scu.fmt_abs(mod_abs)
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
mod["mod_abs_txt"] = ""
|
|
|
|
|
2021-02-01 16:23:11 +01:00
|
|
|
mod["mod_moy_txt"] = scu.fmt_note(mod_moy)
|
2020-09-26 16:19:37 +02:00
|
|
|
if mod["mod_moy_txt"][:2] == "NA":
|
|
|
|
mod["mod_moy_txt"] = "-"
|
|
|
|
if is_malus:
|
2021-09-13 17:10:38 +02:00
|
|
|
if isinstance(mod_moy, str):
|
|
|
|
mod["mod_moy_txt"] = "-"
|
|
|
|
mod["mod_coef_txt"] = "-"
|
|
|
|
elif mod_moy > 0:
|
2021-02-01 16:23:11 +01:00
|
|
|
mod["mod_moy_txt"] = scu.fmt_note(mod_moy)
|
2020-12-29 18:53:03 +01:00
|
|
|
mod["mod_coef_txt"] = "Malus"
|
|
|
|
elif mod_moy < 0:
|
2021-02-01 16:23:11 +01:00
|
|
|
mod["mod_moy_txt"] = scu.fmt_note(-mod_moy)
|
2020-12-29 18:53:03 +01:00
|
|
|
mod["mod_coef_txt"] = "Bonus"
|
|
|
|
else:
|
|
|
|
mod["mod_moy_txt"] = "-"
|
|
|
|
mod["mod_coef_txt"] = "-"
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2021-02-01 16:23:11 +01:00
|
|
|
mod["mod_coef_txt"] = scu.fmt_coef(modimpl["module"]["coefficient"])
|
2020-09-26 16:19:37 +02:00
|
|
|
if mod["mod_moy_txt"] != "NI": # ne montre pas les modules 'non inscrit'
|
|
|
|
mods.append(mod)
|
|
|
|
if is_malus: # n'affiche pas les statistiques sur les modules malus
|
|
|
|
mod["stats"] = {
|
|
|
|
"moy": "",
|
|
|
|
"max": "",
|
|
|
|
"min": "",
|
|
|
|
"nb_notes": "",
|
|
|
|
"nb_missing": "",
|
|
|
|
"nb_valid_evals": "",
|
|
|
|
}
|
|
|
|
else:
|
|
|
|
mod["stats"] = nt.get_mod_stats(modimpl["moduleimpl_id"])
|
|
|
|
mod["mod_descr_txt"] = "Module %s, coef. %s (%s)" % (
|
|
|
|
modimpl["module"]["titre"],
|
2021-02-01 16:23:11 +01:00
|
|
|
scu.fmt_coef(modimpl["module"]["coefficient"]),
|
2021-07-03 23:35:32 +02:00
|
|
|
sco_users.user_info(modimpl["responsable_id"])["nomcomplet"],
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
link_mod = (
|
|
|
|
'<a class="bull_link" href="moduleimpl_status?moduleimpl_id=%s" title="%s">'
|
|
|
|
% (modimpl["moduleimpl_id"], mod["mod_descr_txt"])
|
|
|
|
)
|
2021-07-28 17:03:54 +02:00
|
|
|
if sco_preferences.get_preference("bul_show_codemodules", formsemestre_id):
|
2020-09-26 16:19:37 +02:00
|
|
|
mod["code"] = modimpl["module"]["code"]
|
2022-02-14 10:05:55 +01:00
|
|
|
mod["code_html"] = link_mod + (mod["code"] or "") + "</a>"
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
mod["code"] = mod["code_html"] = ""
|
|
|
|
mod["name"] = (
|
|
|
|
modimpl["module"]["abbrev"] or modimpl["module"]["titre"] or ""
|
|
|
|
)
|
|
|
|
mod["name_html"] = link_mod + mod["name"] + "</a>"
|
|
|
|
|
|
|
|
mod_descr = "Module %s, coef. %s (%s)" % (
|
|
|
|
modimpl["module"]["titre"],
|
2021-02-01 16:23:11 +01:00
|
|
|
scu.fmt_coef(modimpl["module"]["coefficient"]),
|
2021-07-03 23:35:32 +02:00
|
|
|
sco_users.user_info(modimpl["responsable_id"])["nomcomplet"],
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
link_mod = (
|
|
|
|
'<a class="bull_link" href="moduleimpl_status?moduleimpl_id=%s" title="%s">'
|
|
|
|
% (modimpl["moduleimpl_id"], mod_descr)
|
|
|
|
)
|
2021-07-28 17:03:54 +02:00
|
|
|
if sco_preferences.get_preference("bul_show_codemodules", formsemestre_id):
|
2022-02-14 10:05:55 +01:00
|
|
|
mod["code_txt"] = modimpl["module"]["code"] or ""
|
2020-09-26 16:19:37 +02:00
|
|
|
mod["code_html"] = link_mod + mod["code_txt"] + "</a>"
|
|
|
|
else:
|
|
|
|
mod["code_txt"] = ""
|
|
|
|
mod["code_html"] = ""
|
|
|
|
# Evaluations: notes de chaque eval
|
|
|
|
evals = nt.get_evals_in_mod(modimpl["moduleimpl_id"])
|
|
|
|
mod["evaluations"] = []
|
|
|
|
for e in evals:
|
|
|
|
e = e.copy()
|
2021-08-11 00:36:07 +02:00
|
|
|
if e["visibulletin"] or version == "long":
|
2020-09-26 16:19:37 +02:00
|
|
|
# affiche "bonus" quand les points de malus sont négatifs
|
|
|
|
if is_malus:
|
|
|
|
val = e["notes"].get(etudid, {"value": "NP"})[
|
|
|
|
"value"
|
|
|
|
] # NA si etud demissionnaire
|
2021-09-03 17:09:16 +02:00
|
|
|
if val == "NP" or val > 0:
|
2020-09-26 16:19:37 +02:00
|
|
|
e["name"] = "Points de malus sur cette UE"
|
|
|
|
else:
|
|
|
|
e["name"] = "Points de bonus sur cette UE"
|
|
|
|
else:
|
2022-09-18 16:53:00 +02:00
|
|
|
e["name"] = e["description"] or f"le {e['jour']}"
|
|
|
|
e["target_html"] = url_for(
|
|
|
|
"notes.evaluation_listenotes",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
evaluation_id=e["evaluation_id"],
|
|
|
|
format="html",
|
|
|
|
tf_submitted=1,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2022-09-18 16:53:00 +02:00
|
|
|
e[
|
|
|
|
"name_html"
|
|
|
|
] = f"""<a class="bull_link" href="{
|
|
|
|
e['target_html']}">{e['name']}</a>"""
|
|
|
|
val = e["notes"].get(etudid, {"value": "NP"})["value"]
|
|
|
|
# val est NP si etud demissionnaire
|
2020-09-26 16:19:37 +02:00
|
|
|
if val == "NP":
|
|
|
|
e["note_txt"] = "nd"
|
|
|
|
e["note_html"] = '<span class="note_nd">nd</span>'
|
2021-02-01 16:23:11 +01:00
|
|
|
e["coef_txt"] = scu.fmt_coef(e["coefficient"])
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
# (-0.15) s'affiche "bonus de 0.15"
|
|
|
|
if is_malus:
|
|
|
|
val = abs(val)
|
2021-02-01 16:23:11 +01:00
|
|
|
e["note_txt"] = scu.fmt_note(val, note_max=e["note_max"])
|
2020-09-26 16:19:37 +02:00
|
|
|
e["note_html"] = e["note_txt"]
|
|
|
|
if is_malus:
|
|
|
|
e["coef_txt"] = ""
|
|
|
|
else:
|
2021-02-01 16:23:11 +01:00
|
|
|
e["coef_txt"] = scu.fmt_coef(e["coefficient"])
|
|
|
|
if e["evaluation_type"] == scu.EVALUATION_RATTRAPAGE:
|
2020-09-26 16:19:37 +02:00
|
|
|
e["coef_txt"] = "rat."
|
2021-03-11 14:49:37 +01:00
|
|
|
elif e["evaluation_type"] == scu.EVALUATION_SESSION2:
|
2022-09-18 16:53:00 +02:00
|
|
|
e["coef_txt"] = "Ses. 2"
|
2020-09-26 16:19:37 +02:00
|
|
|
if e["etat"]["evalattente"]:
|
|
|
|
mod_attente = True # une eval en attente dans ce module
|
2022-09-18 16:53:00 +02:00
|
|
|
if ((not is_malus) or (val != "NP")) and (
|
|
|
|
(
|
|
|
|
e["evaluation_type"] == scu.EVALUATION_NORMALE
|
|
|
|
or not np.isnan(val)
|
|
|
|
)
|
|
|
|
):
|
|
|
|
# ne liste pas les eval malus sans notes
|
|
|
|
# ni les rattrapages et sessions 2 si pas de note
|
|
|
|
mod["evaluations"].append(e)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Evaluations incomplètes ou futures:
|
|
|
|
mod["evaluations_incompletes"] = []
|
2021-07-28 17:03:54 +02:00
|
|
|
if sco_preferences.get_preference("bul_show_all_evals", formsemestre_id):
|
2020-12-02 01:00:23 +01:00
|
|
|
complete_eval_ids = set([e["evaluation_id"] for e in evals])
|
2021-11-12 22:17:46 +01:00
|
|
|
all_evals = sco_evaluation_db.do_evaluation_list(
|
2021-07-29 10:19:00 +02:00
|
|
|
args={"moduleimpl_id": modimpl["moduleimpl_id"]}
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
all_evals.reverse() # plus ancienne d'abord
|
|
|
|
for e in all_evals:
|
|
|
|
if e["evaluation_id"] not in complete_eval_ids:
|
|
|
|
e = e.copy()
|
|
|
|
mod["evaluations_incompletes"].append(e)
|
|
|
|
e["name"] = (e["description"] or "") + " (%s)" % e["jour"]
|
2021-08-15 09:55:35 +02:00
|
|
|
e["target_html"] = url_for(
|
|
|
|
"notes.evaluation_listenotes",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
evaluation_id=e["evaluation_id"],
|
|
|
|
tf_submitted=1,
|
|
|
|
format="html",
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
e["name_html"] = '<a class="bull_link" href="%s">%s</a>' % (
|
|
|
|
e["target_html"],
|
|
|
|
e["name"],
|
|
|
|
)
|
|
|
|
e["note_txt"] = e["note_html"] = ""
|
2021-02-01 16:23:11 +01:00
|
|
|
e["coef_txt"] = scu.fmt_coef(e["coefficient"])
|
2020-09-26 16:19:37 +02:00
|
|
|
# Classement
|
2022-02-11 16:34:02 +01:00
|
|
|
if (
|
|
|
|
bul_show_mod_rangs
|
|
|
|
and (nt.mod_rangs is not None)
|
|
|
|
and mod["mod_moy_txt"] != "-"
|
|
|
|
and not is_malus
|
|
|
|
):
|
2020-09-26 16:19:37 +02:00
|
|
|
rg = nt.mod_rangs[modimpl["moduleimpl_id"]]
|
2022-01-29 22:45:39 +01:00
|
|
|
if rg[0] is None:
|
|
|
|
mod["mod_rang_txt"] = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2022-01-29 22:45:39 +01:00
|
|
|
if mod_attente: # nt.get_moduleimpls_attente():
|
|
|
|
mod["mod_rang"] = scu.RANG_ATTENTE_STR
|
|
|
|
else:
|
|
|
|
mod["mod_rang"] = rg[0][etudid]
|
|
|
|
mod["mod_eff"] = rg[1] # effectif dans ce module
|
|
|
|
mod["mod_rang_txt"] = "%s/%s" % (mod["mod_rang"], mod["mod_eff"])
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
mod["mod_rang_txt"] = ""
|
|
|
|
if mod_attente:
|
|
|
|
ue_attente = True
|
|
|
|
return mods, ue_attente
|
|
|
|
|
|
|
|
|
|
|
|
def get_etud_rangs_groups(
|
2022-05-18 20:43:01 +02:00
|
|
|
etudid: int, partitions, partitions_etud_groups, nt: NotesTableCompat
|
2020-09-26 16:19:37 +02:00
|
|
|
):
|
2020-12-02 01:00:23 +01:00
|
|
|
"""Ramene rang et nb inscrits dans chaque partition"""
|
2020-09-26 16:19:37 +02:00
|
|
|
rang_gr, ninscrits_gr, gr_name = {}, {}, {}
|
|
|
|
for partition in partitions:
|
|
|
|
if partition["partition_name"] != None:
|
|
|
|
partition_id = partition["partition_id"]
|
|
|
|
|
|
|
|
if etudid in partitions_etud_groups[partition_id]:
|
|
|
|
group = partitions_etud_groups[partition_id][etudid]
|
|
|
|
|
|
|
|
(
|
|
|
|
rang_gr[partition_id],
|
|
|
|
ninscrits_gr[partition_id],
|
|
|
|
) = nt.get_etud_rang_group(etudid, group["group_id"])
|
|
|
|
gr_name[partition_id] = group["group_name"]
|
|
|
|
else: # etudiant non present dans cette partition
|
|
|
|
rang_gr[partition_id], ninscrits_gr[partition_id] = "", ""
|
|
|
|
gr_name[partition_id] = ""
|
|
|
|
|
|
|
|
return rang_gr, ninscrits_gr, gr_name
|
|
|
|
|
|
|
|
|
|
|
|
def etud_descr_situation_semestre(
|
|
|
|
etudid,
|
|
|
|
formsemestre_id,
|
|
|
|
ne="",
|
|
|
|
format="html", # currently unused
|
|
|
|
show_decisions=True,
|
|
|
|
show_uevalid=True,
|
|
|
|
show_date_inscr=True,
|
|
|
|
show_mention=False,
|
|
|
|
):
|
|
|
|
"""Dict décrivant la situation de l'étudiant dans ce semestre.
|
|
|
|
Si format == 'html', peut inclure du balisage html (actuellement inutilisé)
|
|
|
|
|
|
|
|
situation : chaine résumant en français la situation de l'étudiant.
|
|
|
|
Par ex. "Inscrit le 31/12/1999. Décision jury: Validé. ..."
|
2020-12-02 01:00:23 +01:00
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
date_inscription : (vide si show_date_inscr est faux)
|
|
|
|
date_demission : (vide si pas demission ou si show_date_inscr est faux)
|
|
|
|
descr_inscription : "Inscrit" ou "Pas inscrit[e]"
|
|
|
|
descr_demission : "Démission le 01/02/2000" ou vide si pas de démission
|
|
|
|
descr_defaillance : "Défaillant" ou vide si non défaillant.
|
|
|
|
decision_jury : "Validé", "Ajourné", ... (code semestre)
|
|
|
|
descr_decision_jury : "Décision jury: Validé" (une phrase)
|
2022-02-14 23:21:42 +01:00
|
|
|
decision_sem :
|
2020-09-26 16:19:37 +02:00
|
|
|
decisions_ue : noms (acronymes) des UE validées, séparées par des virgules.
|
|
|
|
descr_decisions_ue : ' UE acquises: UE1, UE2', ou vide si pas de dec. ou si pas show_uevalid
|
|
|
|
descr_mention : 'Mention Bien', ou vide si pas de mention ou si pas show_mention
|
2023-03-08 22:23:55 +01:00
|
|
|
descr_parcours : le nom (libelle) du parcours dans lequel est inscrit l'étudiant en BUT (vide ailleurs)
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2022-07-08 18:09:45 +02:00
|
|
|
# Fonction utilisée par tous les bulletins (APC ou classiques)
|
2023-03-08 22:23:55 +01:00
|
|
|
infos = collections.defaultdict(str)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# --- Situation et décisions jury
|
2023-03-08 22:23:55 +01:00
|
|
|
|
|
|
|
date_inscr, date_dem, date_def = _dates_insc_dem_def(etudid, formsemestre_id)
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
if show_date_inscr:
|
|
|
|
if not date_inscr:
|
|
|
|
infos["date_inscription"] = ""
|
2022-07-16 09:39:46 +02:00
|
|
|
infos["descr_inscription"] = f"Pas inscrit{ne}"
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
infos["date_inscription"] = date_inscr
|
2022-07-16 09:39:46 +02:00
|
|
|
infos["descr_inscription"] = f"Inscrit{ne} le {date_inscr}"
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
infos["date_inscription"] = ""
|
|
|
|
infos["descr_inscription"] = ""
|
|
|
|
|
2022-07-16 09:39:46 +02:00
|
|
|
infos["descr_defaillance"] = ""
|
|
|
|
|
2022-07-11 18:33:48 +02:00
|
|
|
# Décision: valeurs par defaut vides:
|
|
|
|
infos["decision_jury"] = infos["descr_decision_jury"] = ""
|
|
|
|
infos["decision_sem"] = ""
|
|
|
|
infos["decisions_ue"] = infos["descr_decisions_ue"] = ""
|
|
|
|
infos["descr_decisions_niveaux"] = infos["descr_decisions_rcue"] = ""
|
|
|
|
infos["descr_decision_annee"] = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if date_dem:
|
2022-07-08 18:09:45 +02:00
|
|
|
infos["descr_demission"] = f"Démission le {date_dem}."
|
2020-09-26 16:19:37 +02:00
|
|
|
infos["date_demission"] = date_dem
|
2022-07-11 18:33:48 +02:00
|
|
|
infos["decision_jury"] = infos["descr_decision_jury"] = "Démission"
|
2022-07-16 09:39:46 +02:00
|
|
|
infos["situation"] = ". ".join(
|
|
|
|
[x for x in [infos["descr_inscription"], infos["descr_demission"]] if x]
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
return infos, None # ne donne pas les dec. de jury pour les demissionnaires
|
|
|
|
if date_def:
|
2022-07-08 18:09:45 +02:00
|
|
|
infos["descr_defaillance"] = f"Défaillant{ne}"
|
2020-09-26 16:19:37 +02:00
|
|
|
infos["date_defaillance"] = date_def
|
2022-07-08 18:09:45 +02:00
|
|
|
infos["descr_decision_jury"] = f"Défaillant{ne}"
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2023-02-19 15:45:27 +01:00
|
|
|
dpv = sco_pv_dict.dict_pvjury(formsemestre_id, etudids=[etudid])
|
2022-02-14 23:21:42 +01:00
|
|
|
if dpv:
|
|
|
|
infos["decision_sem"] = dpv["decisions"][0]["decision_sem"]
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if not show_decisions:
|
|
|
|
return infos, dpv
|
|
|
|
|
2022-02-14 23:21:42 +01:00
|
|
|
# Décisions de jury:
|
2020-09-26 16:19:37 +02:00
|
|
|
pv = dpv["decisions"][0]
|
2022-07-16 09:39:46 +02:00
|
|
|
descr_dec = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
if pv["decision_sem_descr"]:
|
|
|
|
infos["decision_jury"] = pv["decision_sem_descr"]
|
2022-07-16 09:39:46 +02:00
|
|
|
infos["descr_decision_jury"] = "Décision jury: " + pv["decision_sem_descr"]
|
|
|
|
descr_dec = infos["descr_decision_jury"]
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
infos["descr_decision_jury"] = ""
|
2022-07-08 18:09:45 +02:00
|
|
|
infos["decision_jury"] = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if pv["decisions_ue_descr"] and show_uevalid:
|
|
|
|
infos["decisions_ue"] = pv["decisions_ue_descr"]
|
2022-07-16 09:39:46 +02:00
|
|
|
infos["descr_decisions_ue"] = " UE acquises: " + pv["decisions_ue_descr"]
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2022-07-11 18:33:48 +02:00
|
|
|
infos["decisions_ue"] = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
infos["descr_decisions_ue"] = ""
|
|
|
|
|
|
|
|
infos["mention"] = pv["mention"]
|
|
|
|
if pv["mention"] and show_mention:
|
2022-07-16 09:39:46 +02:00
|
|
|
descr_mention = f"Mention {pv['mention']}"
|
|
|
|
else:
|
|
|
|
descr_mention = ""
|
2022-07-08 18:09:45 +02:00
|
|
|
|
|
|
|
# Décisions APC / BUT
|
|
|
|
if pv.get("decision_annee", {}):
|
|
|
|
infos["descr_decision_annee"] = "Décision année: " + pv.get(
|
|
|
|
"decision_annee", {}
|
|
|
|
).get("code", "")
|
|
|
|
else:
|
|
|
|
infos["descr_decision_annee"] = ""
|
2022-07-08 23:58:27 +02:00
|
|
|
|
|
|
|
infos["descr_decisions_rcue"] = pv.get("descr_decisions_rcue", "")
|
|
|
|
infos["descr_decisions_niveaux"] = pv.get("descr_decisions_niveaux", "")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-07-16 09:39:46 +02:00
|
|
|
descr_autorisations = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
if not pv["validation_parcours"]: # parcours non terminé
|
|
|
|
if pv["autorisations_descr"]:
|
2022-07-16 09:39:46 +02:00
|
|
|
descr_autorisations = (
|
|
|
|
f"Autorisé à s'inscrire en {pv['autorisations_descr']}."
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2022-07-16 09:39:46 +02:00
|
|
|
descr_dec += " Diplôme obtenu."
|
|
|
|
_format_situation_fields(
|
|
|
|
infos,
|
|
|
|
[
|
|
|
|
"descr_inscription",
|
|
|
|
"descr_defaillance",
|
|
|
|
"descr_decisions_ue",
|
|
|
|
"descr_decision_annee",
|
|
|
|
],
|
|
|
|
[descr_dec, descr_mention, descr_autorisations],
|
|
|
|
)
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
return infos, dpv
|
|
|
|
|
|
|
|
|
2023-03-08 22:23:55 +01:00
|
|
|
def _dates_insc_dem_def(etudid, formsemestre_id) -> tuple:
|
|
|
|
"Cherche les dates d'inscription, démission et défaillance de l'étudiant"
|
|
|
|
cnx = ndb.GetDBConnexion()
|
|
|
|
events = sco_etud.scolar_events_list(
|
|
|
|
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
|
|
|
|
)
|
|
|
|
date_inscr = None
|
|
|
|
date_dem = None
|
|
|
|
date_def = None
|
|
|
|
for event in events:
|
|
|
|
event_type = event["event_type"]
|
|
|
|
if event_type == "INSCRIPTION":
|
|
|
|
if date_inscr:
|
|
|
|
# plusieurs inscriptions ???
|
|
|
|
# date_inscr += ', ' + event['event_date'] + ' (!)'
|
|
|
|
# il y a eu une erreur qui a laissé un event 'inscription'
|
|
|
|
# on l'efface:
|
|
|
|
log(
|
|
|
|
f"etud_descr_situation_semestre: removing duplicate INSCRIPTION event for etudid={etudid} !"
|
|
|
|
)
|
|
|
|
sco_etud.scolar_events_delete(cnx, event["event_id"])
|
|
|
|
else:
|
|
|
|
date_inscr = event["event_date"]
|
|
|
|
elif event_type == "DEMISSION":
|
|
|
|
# assert date_dem == None, 'plusieurs démissions !'
|
|
|
|
if date_dem: # cela ne peut pas arriver sauf bug (signale a Evry 2013?)
|
|
|
|
log(
|
|
|
|
f"etud_descr_situation_semestre: removing duplicate DEMISSION event for etudid={etudid} !"
|
|
|
|
)
|
|
|
|
sco_etud.scolar_events_delete(cnx, event["event_id"])
|
|
|
|
else:
|
|
|
|
date_dem = event["event_date"]
|
|
|
|
elif event_type == "DEFAILLANCE":
|
|
|
|
if date_def:
|
|
|
|
log(
|
|
|
|
f"etud_descr_situation_semestre: removing duplicate DEFAILLANCE event for etudid={etudid} !"
|
|
|
|
)
|
|
|
|
sco_etud.scolar_events_delete(cnx, event["event_id"])
|
|
|
|
else:
|
|
|
|
date_def = event["event_date"]
|
|
|
|
return date_inscr, date_dem, date_def
|
|
|
|
|
|
|
|
|
2022-07-16 09:39:46 +02:00
|
|
|
def _format_situation_fields(
|
|
|
|
infos, field_names: list[str], extra_values: list[str]
|
|
|
|
) -> None:
|
|
|
|
"""Réuni les champs pour former le paragraphe "situation", et ajoute la pontuation aux champs."""
|
|
|
|
infos["situation"] = ". ".join(
|
|
|
|
x
|
|
|
|
for x in [infos.get(field_name, "") for field_name in field_names]
|
|
|
|
+ [field for field in extra_values if field]
|
|
|
|
if x
|
|
|
|
)
|
|
|
|
for field_name in field_names:
|
|
|
|
field = infos.get(field_name, "")
|
|
|
|
if field and not field.endswith("."):
|
2022-09-14 21:44:38 +02:00
|
|
|
infos[field_name] += "."
|
2022-07-16 09:39:46 +02:00
|
|
|
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
# ------ Page bulletin
|
|
|
|
def formsemestre_bulletinetud(
|
2022-03-14 15:30:51 +01:00
|
|
|
etud: Identite = None,
|
2020-09-26 16:19:37 +02:00
|
|
|
formsemestre_id=None,
|
2022-03-07 21:49:11 +01:00
|
|
|
format=None,
|
2020-09-26 16:19:37 +02:00
|
|
|
version="long",
|
|
|
|
xml_with_decisions=False,
|
|
|
|
force_publishing=False, # force publication meme si semestre non publie sur "portail"
|
|
|
|
prefer_mail_perso=False,
|
|
|
|
):
|
2022-07-11 18:33:48 +02:00
|
|
|
"""Page bulletin de notes pour
|
|
|
|
- HTML des formations classiques (non BUT)
|
|
|
|
- le format "oldjson" (les "json" sont générés à part, voir get_formsemestre_bulletin_etud_json)
|
|
|
|
- les formats PDF, XML et mail pdf (toutes formations)
|
|
|
|
|
|
|
|
Note: le format XML n'est plus maintenu et pour les BUT ne contient pas
|
|
|
|
toutes les informations. Privilégier le format JSON.
|
|
|
|
|
|
|
|
Paramètres:
|
|
|
|
- version: pour les formations classqiues, versions short/selectedevals/long
|
|
|
|
- xml_with_decisions: inclue ou non les
|
|
|
|
- force_publishing: renvoie le bulletin même si semestre non publie sur "portail"
|
|
|
|
- prefer_mail_perso: pour pdfmail, utilise adresse mail perso en priorité.
|
|
|
|
|
2022-04-26 07:35:06 +02:00
|
|
|
"""
|
2022-03-07 21:49:11 +01:00
|
|
|
format = format or "html"
|
2022-02-14 23:21:42 +01:00
|
|
|
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
|
|
|
|
if not formsemestre:
|
|
|
|
raise ScoValueError(f"semestre {formsemestre_id} inconnu !")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-07-13 17:00:25 +02:00
|
|
|
bulletin = do_formsemestre_bulletinetud(
|
2022-02-14 23:21:42 +01:00
|
|
|
formsemestre,
|
2022-03-14 15:30:51 +01:00
|
|
|
etud.id,
|
2021-07-13 17:00:25 +02:00
|
|
|
format=format,
|
|
|
|
version=version,
|
|
|
|
xml_with_decisions=xml_with_decisions,
|
|
|
|
force_publishing=force_publishing,
|
|
|
|
prefer_mail_perso=prefer_mail_perso,
|
|
|
|
)[0]
|
|
|
|
if format not in {"html", "pdfmail"}:
|
2022-03-06 22:40:20 +01:00
|
|
|
filename = scu.bul_filename(formsemestre, etud, format)
|
2023-02-21 21:34:38 +01:00
|
|
|
mime, suffix = scu.get_mime_suffix(format)
|
|
|
|
return scu.send_file(bulletin, filename, mime=mime, suffix=suffix)
|
2022-03-22 19:18:25 +01:00
|
|
|
elif format == "pdfmail":
|
|
|
|
return ""
|
2021-07-13 17:00:25 +02:00
|
|
|
H = [
|
2022-03-06 22:40:20 +01:00
|
|
|
_formsemestre_bulletinetud_header_html(etud, formsemestre, format, version),
|
2021-07-13 17:00:25 +02:00
|
|
|
bulletin,
|
2022-03-07 23:43:48 +01:00
|
|
|
render_template(
|
2023-01-30 22:25:17 +01:00
|
|
|
"bul_foot.j2",
|
2022-03-16 00:13:58 +01:00
|
|
|
appreciations=None, # déjà affichées
|
|
|
|
css_class="bul_classic_foot",
|
2022-03-07 23:43:48 +01:00
|
|
|
etud=etud,
|
|
|
|
formsemestre=formsemestre,
|
|
|
|
inscription_courante=etud.inscription_courante(),
|
|
|
|
inscription_str=etud.inscription_descr()["inscription_str"],
|
|
|
|
),
|
|
|
|
html_sco_header.sco_footer(),
|
2021-07-13 17:00:25 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
return "".join(H)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2021-08-20 10:51:42 +02:00
|
|
|
def can_send_bulletin_by_mail(formsemestre_id):
|
2020-12-02 01:00:23 +01:00
|
|
|
"""True if current user is allowed to send a bulletin by mail"""
|
2021-08-19 10:28:35 +02:00
|
|
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
return (
|
2021-07-28 17:03:54 +02:00
|
|
|
sco_preferences.get_preference("bul_mail_allowed_for_all", formsemestre_id)
|
2021-07-29 16:31:15 +02:00
|
|
|
or current_user.has_permission(Permission.ScoImplement)
|
2021-08-22 13:24:36 +02:00
|
|
|
or current_user.id in sem["responsables"]
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def do_formsemestre_bulletinetud(
|
2022-02-14 23:21:42 +01:00
|
|
|
formsemestre: FormSemestre,
|
|
|
|
etudid: int,
|
2020-09-26 16:19:37 +02:00
|
|
|
version="long", # short, long, selectedevals
|
2022-03-07 21:49:11 +01:00
|
|
|
format=None,
|
2023-02-15 16:15:53 +01:00
|
|
|
xml_with_decisions: bool = False,
|
|
|
|
force_publishing: bool = False,
|
|
|
|
prefer_mail_perso: bool = False,
|
|
|
|
with_img_signatures_pdf: bool = True,
|
2020-09-26 16:19:37 +02:00
|
|
|
):
|
|
|
|
"""Génère le bulletin au format demandé.
|
2022-07-11 18:33:48 +02:00
|
|
|
Utilisé pour:
|
|
|
|
- HTML des formations classiques (non BUT)
|
|
|
|
- le format "oldjson" (les json sont générés à part, voir get_formsemestre_bulletin_etud_json)
|
|
|
|
- les formats PDF, XML et mail pdf (toutes formations)
|
|
|
|
|
2023-02-15 16:15:53 +01:00
|
|
|
Options:
|
|
|
|
- xml_with_decisions: force décisions dans XML
|
|
|
|
- force_publishing: force publication meme si semestre non publié sur "portail"
|
|
|
|
- prefer_mail_perso: mails envoyés sur adresse perso si non vide
|
|
|
|
- with_img_signatures_pdf: si faux, ne met pas les signatures dans le footer PDF.
|
|
|
|
|
2022-07-11 18:33:48 +02:00
|
|
|
Résultat: (bul, filigranne)
|
2021-09-18 13:42:19 +02:00
|
|
|
où bul est str ou bytes au format demandé (html, pdf, pdfmail, pdfpart, xml, json)
|
2020-09-26 16:19:37 +02:00
|
|
|
et filigranne est un message à placer en "filigranne" (eg "Provisoire").
|
|
|
|
"""
|
2022-03-07 21:49:11 +01:00
|
|
|
format = format or "html"
|
2020-09-26 16:19:37 +02:00
|
|
|
if format == "xml":
|
2021-07-10 16:01:37 +02:00
|
|
|
bul = sco_bulletins_xml.make_xml_formsemestre_bulletinetud(
|
2022-02-14 23:21:42 +01:00
|
|
|
formsemestre.id,
|
2021-07-10 16:01:37 +02:00
|
|
|
etudid,
|
|
|
|
xml_with_decisions=xml_with_decisions,
|
|
|
|
force_publishing=force_publishing,
|
|
|
|
version=version,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2021-07-10 16:01:37 +02:00
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
return bul, ""
|
|
|
|
|
2022-07-11 18:33:48 +02:00
|
|
|
elif format == "json": # utilisé pour classic et "oldjson"
|
2020-09-26 16:19:37 +02:00
|
|
|
bul = sco_bulletins_json.make_json_formsemestre_bulletinetud(
|
2022-02-14 23:21:42 +01:00
|
|
|
formsemestre.id,
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid,
|
|
|
|
xml_with_decisions=xml_with_decisions,
|
|
|
|
force_publishing=force_publishing,
|
|
|
|
version=version,
|
|
|
|
)
|
|
|
|
return bul, ""
|
2022-11-27 23:31:48 +01:00
|
|
|
if version.endswith("_mat"):
|
|
|
|
version = version[:-4] # enlève le "_mat"
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-02-14 23:21:42 +01:00
|
|
|
if formsemestre.formation.is_apc():
|
2022-03-14 20:20:49 +01:00
|
|
|
etudiant = Identite.query.get(etudid)
|
2022-02-14 23:21:42 +01:00
|
|
|
r = bulletin_but.BulletinBUT(formsemestre)
|
2022-07-11 18:33:48 +02:00
|
|
|
infos = r.bulletin_etud_complet(etudiant, version=version)
|
2022-02-14 23:21:42 +01:00
|
|
|
else:
|
2022-07-11 18:33:48 +02:00
|
|
|
infos = formsemestre_bulletinetud_dict(formsemestre.id, etudid)
|
|
|
|
etud = infos["etud"]
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if format == "html":
|
2021-02-01 16:23:11 +01:00
|
|
|
htm, _ = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
2022-07-11 18:33:48 +02:00
|
|
|
infos, version=version, format="html"
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2022-07-11 18:33:48 +02:00
|
|
|
return htm, infos["filigranne"]
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
elif format == "pdf" or format == "pdfpart":
|
|
|
|
bul, filename = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
2022-07-11 18:33:48 +02:00
|
|
|
infos,
|
2020-09-26 16:19:37 +02:00
|
|
|
version=version,
|
|
|
|
format="pdf",
|
|
|
|
stand_alone=(format != "pdfpart"),
|
2023-02-15 16:15:53 +01:00
|
|
|
with_img_signatures_pdf=with_img_signatures_pdf,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
if format == "pdf":
|
|
|
|
return (
|
2021-09-21 15:53:33 +02:00
|
|
|
scu.sendPDFFile(bul, filename),
|
2022-07-11 18:33:48 +02:00
|
|
|
infos["filigranne"],
|
2020-09-26 16:19:37 +02:00
|
|
|
) # unused ret. value
|
|
|
|
else:
|
2022-07-11 18:33:48 +02:00
|
|
|
return bul, infos["filigranne"]
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
elif format == "pdfmail":
|
|
|
|
# format pdfmail: envoie le pdf par mail a l'etud, et affiche le html
|
|
|
|
# check permission
|
2022-02-14 23:21:42 +01:00
|
|
|
if not can_send_bulletin_by_mail(formsemestre.id):
|
2020-09-26 16:19:37 +02:00
|
|
|
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
|
|
|
|
|
|
|
|
pdfdata, filename = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
2022-07-11 18:33:48 +02:00
|
|
|
infos, version=version, format="pdf"
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if prefer_mail_perso:
|
|
|
|
recipient_addr = etud.get("emailperso", "") or etud.get("email", "")
|
|
|
|
else:
|
2022-03-14 20:20:49 +01:00
|
|
|
recipient_addr = etud.get("email", "") or etud.get("emailperso", "")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if not recipient_addr:
|
2022-03-22 19:18:25 +01:00
|
|
|
flash(f"{etud['nomprenom']} n'a pas d'adresse e-mail !")
|
2022-07-11 18:33:48 +02:00
|
|
|
return False, infos["filigranne"]
|
2022-03-22 19:18:25 +01:00
|
|
|
else:
|
2022-07-11 18:33:48 +02:00
|
|
|
mail_bulletin(formsemestre.id, infos, pdfdata, filename, recipient_addr)
|
2022-03-22 19:18:25 +01:00
|
|
|
flash(f"mail envoyé à {recipient_addr}")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-07-11 18:33:48 +02:00
|
|
|
return True, infos["filigranne"]
|
2022-03-22 19:18:25 +01:00
|
|
|
|
|
|
|
raise ValueError("do_formsemestre_bulletinetud: invalid format (%s)" % format)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2022-07-11 18:33:48 +02:00
|
|
|
def mail_bulletin(formsemestre_id, infos, pdfdata, filename, recipient_addr):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Send bulletin by email to etud
|
|
|
|
If bul_mail_list_abs pref is true, put list of absences in mail body (text).
|
|
|
|
"""
|
2022-07-11 18:33:48 +02:00
|
|
|
etud = infos["etud"]
|
2021-07-28 17:03:54 +02:00
|
|
|
webmaster = sco_preferences.get_preference("bul_mail_contact_addr", formsemestre_id)
|
2021-06-13 23:37:14 +02:00
|
|
|
dept = scu.unescape_html(
|
2021-07-28 17:03:54 +02:00
|
|
|
sco_preferences.get_preference("DeptName", formsemestre_id)
|
2021-06-13 23:37:14 +02:00
|
|
|
)
|
2021-07-28 17:03:54 +02:00
|
|
|
copy_addr = sco_preferences.get_preference("email_copy_bulletins", formsemestre_id)
|
|
|
|
intro_mail = sco_preferences.get_preference("bul_intro_mail", formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if intro_mail:
|
2022-02-23 20:21:13 +01:00
|
|
|
try:
|
|
|
|
hea = intro_mail % {
|
|
|
|
"nomprenom": etud["nomprenom"],
|
|
|
|
"dept": dept,
|
|
|
|
"webmaster": webmaster,
|
|
|
|
}
|
|
|
|
except KeyError as e:
|
|
|
|
raise ScoValueError(
|
|
|
|
"format 'Message d'accompagnement' (bul_intro_mail) invalide, revoir les réglages dans les préférences"
|
2022-03-10 09:28:59 +01:00
|
|
|
) from e
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
|
|
|
hea = ""
|
|
|
|
|
2021-07-28 17:03:54 +02:00
|
|
|
if sco_preferences.get_preference("bul_mail_list_abs"):
|
2020-09-26 16:19:37 +02:00
|
|
|
hea += "\n\n" + sco_abs_views.ListeAbsEtud(
|
2021-08-21 00:24:51 +02:00
|
|
|
etud["etudid"], with_evals=False, format="text"
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
2022-07-11 18:33:48 +02:00
|
|
|
subject = f"""Relevé de notes de {etud["nomprenom"]}"""
|
2020-09-26 16:19:37 +02:00
|
|
|
recipients = [recipient_addr]
|
2023-02-28 19:43:48 +01:00
|
|
|
sender = email.get_from_addr()
|
2020-09-26 16:19:37 +02:00
|
|
|
if copy_addr:
|
2023-01-19 15:51:57 +01:00
|
|
|
bcc = copy_addr.strip().split(",")
|
2021-08-26 23:43:54 +02:00
|
|
|
else:
|
|
|
|
bcc = ""
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
# Attach pdf
|
2022-07-11 18:33:48 +02:00
|
|
|
log(f"""mail bulletin a {recipient_addr}""")
|
2022-03-04 20:02:50 +01:00
|
|
|
email.send_email(
|
|
|
|
subject,
|
|
|
|
sender,
|
|
|
|
recipients,
|
2023-01-19 15:51:57 +01:00
|
|
|
bcc=bcc,
|
2022-03-04 20:02:50 +01:00
|
|
|
text_body=hea,
|
|
|
|
attachments=[
|
|
|
|
{"filename": filename, "mimetype": scu.PDF_MIMETYPE, "data": pdfdata}
|
|
|
|
],
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2022-03-06 22:40:20 +01:00
|
|
|
def make_menu_autres_operations(
|
|
|
|
formsemestre: FormSemestre, etud: Identite, endpoint: str, version: str
|
|
|
|
) -> str:
|
|
|
|
etud_email = etud.get_first_email() or ""
|
|
|
|
etud_perso = etud.get_first_email("emailperso") or ""
|
|
|
|
menu_items = [
|
2020-09-26 16:19:37 +02:00
|
|
|
{
|
|
|
|
"title": "Réglages bulletins",
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": "notes.formsemestre_edit_options",
|
2021-09-18 10:10:02 +02:00
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2021-09-18 10:10:02 +02:00
|
|
|
# "target_url": url_for(
|
|
|
|
# "notes.formsemestre_bulletinetud",
|
|
|
|
# scodoc_dept=g.scodoc_dept,
|
|
|
|
# formsemestre_id=formsemestre_id,
|
|
|
|
# etudid=etudid,
|
|
|
|
# ),
|
|
|
|
},
|
2022-03-05 12:47:08 +01:00
|
|
|
"enabled": formsemestre.can_be_edited_by(current_user),
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": 'Version papier (pdf, format "%s")'
|
|
|
|
% sco_bulletins_generator.bulletin_get_class_name_displayed(
|
2022-03-05 12:47:08 +01:00
|
|
|
formsemestre.id
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": endpoint,
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-06-14 18:08:52 +02:00
|
|
|
"version": version,
|
|
|
|
"format": "pdf",
|
|
|
|
},
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
{
|
2022-03-06 22:40:20 +01:00
|
|
|
"title": f"Envoi par mail à {etud_email}",
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": endpoint,
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-06-14 18:08:52 +02:00
|
|
|
"version": version,
|
|
|
|
"format": "pdfmail",
|
|
|
|
},
|
2021-08-20 10:51:42 +02:00
|
|
|
# possible slt si on a un mail...
|
2022-03-06 22:40:20 +01:00
|
|
|
"enabled": etud_email and can_send_bulletin_by_mail(formsemestre.id),
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
{
|
2022-03-06 22:40:20 +01:00
|
|
|
"title": f"Envoi par mail à {etud_perso} (adr. personnelle)",
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": endpoint,
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-06-14 18:08:52 +02:00
|
|
|
"version": version,
|
|
|
|
"format": "pdfmail",
|
|
|
|
"prefer_mail_perso": 1,
|
|
|
|
},
|
2021-08-20 10:51:42 +02:00
|
|
|
# possible slt si on a un mail...
|
2022-03-06 22:40:20 +01:00
|
|
|
"enabled": etud_perso and can_send_bulletin_by_mail(formsemestre.id),
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
2021-09-18 13:42:19 +02:00
|
|
|
{
|
|
|
|
"title": "Version json",
|
|
|
|
"endpoint": endpoint,
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-09-18 13:42:19 +02:00
|
|
|
"version": version,
|
|
|
|
"format": "json",
|
|
|
|
},
|
|
|
|
},
|
2020-09-26 16:19:37 +02:00
|
|
|
{
|
|
|
|
"title": "Version XML",
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": endpoint,
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-06-14 18:08:52 +02:00
|
|
|
"version": version,
|
|
|
|
"format": "xml",
|
|
|
|
},
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Ajouter une appréciation",
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": "notes.appreciation_add_form",
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-06-14 18:08:52 +02:00
|
|
|
},
|
2020-09-26 16:19:37 +02:00
|
|
|
"enabled": (
|
2022-03-05 12:47:08 +01:00
|
|
|
formsemestre.can_be_edited_by(current_user)
|
|
|
|
or current_user.has_permission(Permission.ScoEtudInscrit)
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Enregistrer un semestre effectué ailleurs",
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": "notes.formsemestre_ext_create_form",
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-06-14 18:08:52 +02:00
|
|
|
},
|
2021-08-22 13:24:36 +02:00
|
|
|
"enabled": current_user.has_permission(Permission.ScoImplement),
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Enregistrer une validation d'UE antérieure",
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": "notes.formsemestre_validate_previous_ue",
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-06-14 18:08:52 +02:00
|
|
|
},
|
2023-02-12 01:13:43 +01:00
|
|
|
"enabled": formsemestre.can_edit_jury(),
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Enregistrer note d'une UE externe",
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": "notes.external_ue_create_form",
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-06-14 18:08:52 +02:00
|
|
|
},
|
2023-02-12 01:13:43 +01:00
|
|
|
"enabled": formsemestre.can_edit_jury()
|
2022-12-18 03:14:13 +01:00
|
|
|
and not formsemestre.formation.is_apc(),
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Entrer décisions jury",
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": "notes.formsemestre_validation_etud_form",
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-06-14 18:08:52 +02:00
|
|
|
},
|
2023-02-12 01:13:43 +01:00
|
|
|
"enabled": formsemestre.can_edit_jury(),
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
{
|
2022-03-07 21:49:11 +01:00
|
|
|
"title": "Éditer PV jury",
|
2021-06-14 18:08:52 +02:00
|
|
|
"endpoint": "notes.formsemestre_pvjury_pdf",
|
|
|
|
"args": {
|
2022-03-05 12:47:08 +01:00
|
|
|
"formsemestre_id": formsemestre.id,
|
2022-03-06 22:40:20 +01:00
|
|
|
"etudid": etud.id,
|
2021-06-14 18:08:52 +02:00
|
|
|
},
|
2020-09-26 16:19:37 +02:00
|
|
|
"enabled": True,
|
|
|
|
},
|
|
|
|
]
|
2022-03-06 22:40:20 +01:00
|
|
|
return htmlutils.make_menu("Autres opérations", menu_items, alone=True)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-03-06 22:40:20 +01:00
|
|
|
|
|
|
|
def _formsemestre_bulletinetud_header_html(
|
|
|
|
etud,
|
|
|
|
formsemestre: FormSemestre,
|
|
|
|
format=None,
|
|
|
|
version=None,
|
|
|
|
):
|
|
|
|
H = [
|
|
|
|
html_sco_header.sco_header(
|
|
|
|
page_title=f"Bulletin de {etud.nomprenom}",
|
|
|
|
javascripts=[
|
|
|
|
"js/bulletin.js",
|
|
|
|
"libjs/d3.v3.min.js",
|
|
|
|
"js/radar_bulletin.js",
|
|
|
|
],
|
|
|
|
cssstyles=["css/radar_bulletin.css"],
|
|
|
|
),
|
|
|
|
render_template(
|
2023-01-30 22:25:17 +01:00
|
|
|
"bul_head.j2",
|
2022-03-06 22:40:20 +01:00
|
|
|
etud=etud,
|
|
|
|
format=format,
|
|
|
|
formsemestre=formsemestre,
|
|
|
|
menu_autres_operations=make_menu_autres_operations(
|
|
|
|
etud=etud,
|
|
|
|
formsemestre=formsemestre,
|
|
|
|
endpoint="notes.formsemestre_bulletinetud",
|
2021-09-18 10:10:02 +02:00
|
|
|
version=version,
|
|
|
|
),
|
2022-03-06 22:40:20 +01:00
|
|
|
scu=scu,
|
|
|
|
time=time,
|
|
|
|
version=version,
|
|
|
|
),
|
|
|
|
]
|
|
|
|
return "\n".join(H)
|