2020-09-26 16:19:37 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2022-01-01 14:49:42 +01:00
|
|
|
# Copyright (c) 1999 - 2022 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
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Feuille excel pour preparation des jurys
|
|
|
|
"""
|
2021-02-04 20:02:44 +01:00
|
|
|
import time
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-08-23 17:47:49 +02:00
|
|
|
from openpyxl.styles.numbers import FORMAT_NUMBER_00
|
|
|
|
|
2021-09-18 10:10:02 +02:00
|
|
|
from flask import request
|
2021-09-18 13:42:19 +02:00
|
|
|
from flask_login import current_user
|
2021-09-18 10:10:02 +02:00
|
|
|
|
2021-06-19 23:21:37 +02:00
|
|
|
import app.scodoc.sco_utils as scu
|
2021-07-19 19:53:01 +02:00
|
|
|
from app.scodoc import sco_abs
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_groups
|
2021-07-19 19:53:01 +02:00
|
|
|
from app.scodoc import sco_cache
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_excel
|
|
|
|
from app.scodoc import sco_formsemestre
|
|
|
|
from app.scodoc import sco_parcours_dut
|
|
|
|
from app.scodoc import sco_codes_parcours
|
2021-08-21 17:07:44 +02:00
|
|
|
import sco_version
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_etud
|
|
|
|
from app.scodoc import sco_preferences
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2021-09-27 10:20:10 +02:00
|
|
|
def feuille_preparation_jury(formsemestre_id):
|
2020-09-26 16:19:37 +02:00
|
|
|
"Feuille excel pour preparation des jurys"
|
2022-02-12 22:57:46 +01:00
|
|
|
nt = sco_cache.NotesTableCache.get(formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
etudids = nt.get_etudids(sorted=True) # tri par moy gen
|
2021-08-19 10:28:35 +02:00
|
|
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-08-19 10:28:35 +02:00
|
|
|
etud_groups = sco_groups.formsemestre_get_etud_groupnames(formsemestre_id)
|
|
|
|
main_partition_id = sco_groups.formsemestre_get_main_partition(formsemestre_id)[
|
|
|
|
"partition_id"
|
|
|
|
]
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-02-04 20:02:44 +01:00
|
|
|
prev_moy_ue = scu.DictDefault(defaultvalue={}) # ue_code_s : { etudid : moy ue }
|
2020-09-26 16:19:37 +02:00
|
|
|
prev_ue_acro = {} # ue_code_s : acronyme (à afficher)
|
|
|
|
prev_moy = {} # moyennes gen sem prec
|
2021-02-04 20:02:44 +01:00
|
|
|
moy_ue = scu.DictDefault(defaultvalue={}) # ue_acro : moyennes { etudid : moy ue }
|
2021-08-13 12:18:22 +02:00
|
|
|
ue_acro = {} # ue_code_s : acronyme (à afficher)
|
2020-09-26 16:19:37 +02:00
|
|
|
moy = {} # moyennes gen
|
|
|
|
moy_inter = {} # moyenne gen. sur les 2 derniers semestres
|
|
|
|
code = {} # decision existantes s'il y en a
|
|
|
|
autorisations = {}
|
|
|
|
prev_code = {} # decisions sem prec
|
|
|
|
assidu = {}
|
|
|
|
parcours = {} # etudid : parcours, sous la forme S1, S2, S2, S3
|
|
|
|
groupestd = {} # etudid : nom groupe principal
|
|
|
|
nbabs = {}
|
|
|
|
nbabsjust = {}
|
|
|
|
for etudid in etudids:
|
2021-06-19 23:21:37 +02:00
|
|
|
info = sco_etud.get_etud_info(etudid=etudid, filled=True)
|
2020-09-26 16:19:37 +02:00
|
|
|
if not info:
|
|
|
|
continue # should not occur...
|
|
|
|
etud = info[0]
|
2021-08-19 10:28:35 +02:00
|
|
|
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
if Se.prev:
|
2022-02-12 22:57:46 +01:00
|
|
|
ntp = sco_cache.NotesTableCache.get(Se.prev["formsemestre_id"])
|
2021-12-24 00:08:25 +01:00
|
|
|
for ue in ntp.get_ues_stat_dict(filter_sport=True):
|
2020-09-26 16:19:37 +02:00
|
|
|
ue_status = ntp.get_etud_ue_status(etudid, ue["ue_id"])
|
|
|
|
ue_code_s = (
|
|
|
|
ue["ue_code"] + "_%s" % ntp.sem["semestre_id"]
|
|
|
|
) # code indentifiant l'UE
|
2022-02-12 22:57:46 +01:00
|
|
|
prev_moy_ue[ue_code_s][etudid] = ue_status["moy"] if ue_status else ""
|
2020-09-26 16:19:37 +02:00
|
|
|
prev_ue_acro[ue_code_s] = (ue["numero"], ue["acronyme"], ue["titre"])
|
|
|
|
prev_moy[etudid] = ntp.get_etud_moy_gen(etudid)
|
|
|
|
prev_decision = ntp.get_etud_decision_sem(etudid)
|
|
|
|
if prev_decision:
|
|
|
|
prev_code[etudid] = prev_decision["code"]
|
|
|
|
if prev_decision["compense_formsemestre_id"]:
|
|
|
|
prev_code[etudid] += "+" # indique qu'il a servi a compenser
|
|
|
|
|
|
|
|
moy[etudid] = nt.get_etud_moy_gen(etudid)
|
2021-12-24 00:08:25 +01:00
|
|
|
for ue in nt.get_ues_stat_dict(filter_sport=True):
|
2020-09-26 16:19:37 +02:00
|
|
|
ue_status = nt.get_etud_ue_status(etudid, ue["ue_id"])
|
|
|
|
ue_code_s = ue["ue_code"] + "_%s" % nt.sem["semestre_id"]
|
2022-02-12 22:57:46 +01:00
|
|
|
moy_ue[ue_code_s][etudid] = ue_status["moy"] if ue_status else ""
|
2020-09-26 16:19:37 +02:00
|
|
|
ue_acro[ue_code_s] = (ue["numero"], ue["acronyme"], ue["titre"])
|
|
|
|
|
|
|
|
if Se.prev:
|
|
|
|
try:
|
|
|
|
moy_inter[etudid] = (moy[etudid] + prev_moy[etudid]) / 2.0
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
decision = nt.get_etud_decision_sem(etudid)
|
|
|
|
if decision:
|
|
|
|
code[etudid] = decision["code"]
|
|
|
|
if decision["compense_formsemestre_id"]:
|
|
|
|
code[etudid] += "+" # indique qu'il a servi a compenser
|
2021-08-11 00:36:07 +02:00
|
|
|
assidu[etudid] = {False: "Non", True: "Oui"}.get(decision["assidu"], "")
|
2020-09-26 16:19:37 +02:00
|
|
|
aut_list = sco_parcours_dut.formsemestre_get_autorisation_inscription(
|
2021-08-21 00:24:51 +02:00
|
|
|
etudid, formsemestre_id
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
autorisations[etudid] = ", ".join(["S%s" % x["semestre_id"] for x in aut_list])
|
|
|
|
# parcours:
|
|
|
|
parcours[etudid] = Se.get_parcours_descr()
|
|
|
|
# groupe principal (td)
|
|
|
|
groupestd[etudid] = ""
|
|
|
|
for s in etud["sems"]:
|
|
|
|
if s["formsemestre_id"] == formsemestre_id:
|
|
|
|
groupestd[etudid] = etud_groups.get(etudid, {}).get(
|
|
|
|
main_partition_id, ""
|
|
|
|
)
|
|
|
|
# absences:
|
2021-08-13 12:18:22 +02:00
|
|
|
e_nbabs, e_nbabsjust = sco_abs.get_abs_count(etudid, sem)
|
|
|
|
nbabs[etudid] = e_nbabs
|
|
|
|
nbabsjust[etudid] = e_nbabs - e_nbabsjust
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Codes des UE "semestre précédent":
|
2021-07-09 17:47:06 +02:00
|
|
|
ue_prev_codes = list(prev_moy_ue.keys())
|
2020-09-26 16:19:37 +02:00
|
|
|
ue_prev_codes.sort(
|
2021-07-09 23:19:30 +02:00
|
|
|
key=lambda x, prev_ue_acro=prev_ue_acro: prev_ue_acro[ # pylint: disable=undefined-variable
|
|
|
|
x
|
|
|
|
]
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
# Codes des UE "semestre courant":
|
2021-07-09 17:47:06 +02:00
|
|
|
ue_codes = list(moy_ue.keys())
|
2021-02-01 23:54:46 +01:00
|
|
|
ue_codes.sort(
|
2021-07-09 23:19:30 +02:00
|
|
|
key=lambda x, ue_acro=ue_acro: ue_acro[x] # pylint: disable=undefined-variable
|
2021-02-01 23:54:46 +01:00
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
sid = sem["semestre_id"]
|
|
|
|
sn = sp = ""
|
|
|
|
if sid >= 0:
|
|
|
|
sn = "S%s" % sid
|
|
|
|
if prev_moy: # si qq chose dans precedent
|
|
|
|
sp = "S%s" % (sid - 1)
|
|
|
|
|
2021-08-13 12:18:22 +02:00
|
|
|
ws = sco_excel.ScoExcelSheet(sheet_name="Prepa Jury %s" % sn)
|
|
|
|
# génération des styles
|
|
|
|
style_bold = sco_excel.excel_make_style(size=10, bold=True)
|
|
|
|
style_center = sco_excel.excel_make_style(halign="center")
|
|
|
|
style_boldcenter = sco_excel.excel_make_style(bold=True, halign="center")
|
|
|
|
style_moy = sco_excel.excel_make_style(
|
|
|
|
bold=True, halign="center", bgcolor=sco_excel.COLORS.LIGHT_YELLOW
|
|
|
|
)
|
2021-08-23 17:47:49 +02:00
|
|
|
style_note = sco_excel.excel_make_style(
|
|
|
|
halign="right", number_format=FORMAT_NUMBER_00
|
|
|
|
)
|
2021-08-13 12:18:22 +02:00
|
|
|
style_note_bold = sco_excel.excel_make_style(
|
2021-08-23 17:47:49 +02:00
|
|
|
halign="right", bold=True, number_format="General"
|
2021-08-13 12:18:22 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# Première ligne
|
|
|
|
ws.append_single_cell_row(
|
|
|
|
"Feuille préparation Jury %s" % scu.unescape_html(sem["titreannee"]), style_bold
|
|
|
|
)
|
|
|
|
ws.append_blank_row()
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-08-13 12:18:22 +02:00
|
|
|
# Ligne de titre
|
2020-09-26 16:19:37 +02:00
|
|
|
titles = ["Rang"]
|
2021-07-28 17:03:54 +02:00
|
|
|
if sco_preferences.get_preference("prepa_jury_nip"):
|
2020-09-26 16:19:37 +02:00
|
|
|
titles.append("NIP")
|
2021-07-28 17:03:54 +02:00
|
|
|
if sco_preferences.get_preference("prepa_jury_ine"):
|
2020-09-26 16:19:37 +02:00
|
|
|
titles.append("INE")
|
|
|
|
titles += [
|
|
|
|
"etudid",
|
|
|
|
"Civ.",
|
|
|
|
"Nom",
|
|
|
|
"Prénom",
|
|
|
|
"Naissance",
|
|
|
|
"Bac",
|
|
|
|
"Spe",
|
|
|
|
"Rg Adm",
|
|
|
|
"Parcours",
|
|
|
|
"Groupe",
|
|
|
|
]
|
|
|
|
if prev_moy: # si qq chose dans precedent
|
|
|
|
titles += [prev_ue_acro[x][1] for x in ue_prev_codes] + [
|
|
|
|
"Moy %s" % sp,
|
|
|
|
"Décision %s" % sp,
|
|
|
|
]
|
|
|
|
titles += [ue_acro[x][1] for x in ue_codes] + ["Moy %s" % sn]
|
|
|
|
if moy_inter:
|
|
|
|
titles += ["Moy %s-%s" % (sp, sn)]
|
|
|
|
titles += ["Abs", "Abs Injust."]
|
|
|
|
if code:
|
|
|
|
titles.append("Proposit. %s" % sn)
|
|
|
|
if autorisations:
|
|
|
|
titles.append("Autorisations")
|
|
|
|
# titles.append('Assidu')
|
2021-08-13 12:18:22 +02:00
|
|
|
ws.append_row(ws.make_row(titles, style_boldcenter))
|
2020-09-26 16:19:37 +02:00
|
|
|
if prev_moy:
|
|
|
|
tit_prev_moy = "Moy " + sp
|
|
|
|
col_prev_moy = titles.index(tit_prev_moy)
|
|
|
|
tit_moy = "Moy " + sn
|
|
|
|
col_moy = titles.index(tit_moy)
|
|
|
|
col_abs = titles.index("Abs")
|
|
|
|
|
|
|
|
def fmt(x):
|
|
|
|
"reduit les notes a deux chiffres"
|
2021-02-04 20:02:44 +01:00
|
|
|
x = scu.fmt_note(x, keep_numeric=False)
|
2020-09-26 16:19:37 +02:00
|
|
|
try:
|
|
|
|
return float(x)
|
|
|
|
except:
|
|
|
|
return x
|
|
|
|
|
|
|
|
i = 1 # numero etudiant
|
|
|
|
for etudid in etudids:
|
2021-08-13 12:18:22 +02:00
|
|
|
cells = []
|
2020-09-26 16:19:37 +02:00
|
|
|
etud = nt.identdict[etudid]
|
2021-08-13 12:18:22 +02:00
|
|
|
cells.append(ws.make_cell(str(i)))
|
2021-07-28 17:03:54 +02:00
|
|
|
if sco_preferences.get_preference("prepa_jury_nip"):
|
2021-08-13 12:18:22 +02:00
|
|
|
cells.append(ws.make_cell(etud["code_nip"]))
|
2021-07-28 17:03:54 +02:00
|
|
|
if sco_preferences.get_preference("prepa_jury_ine"):
|
2021-12-07 10:15:14 +01:00
|
|
|
cells.append(ws.make_cell(etud["code_ine"]))
|
2021-08-13 12:18:22 +02:00
|
|
|
cells += ws.make_row(
|
|
|
|
[
|
|
|
|
etudid,
|
|
|
|
etud["civilite_str"],
|
|
|
|
sco_etud.format_nom(etud["nom"]),
|
|
|
|
sco_etud.format_prenom(etud["prenom"]),
|
|
|
|
etud["date_naissance"],
|
|
|
|
etud["bac"],
|
|
|
|
etud["specialite"],
|
|
|
|
etud["classement"],
|
|
|
|
parcours[etudid],
|
|
|
|
groupestd[etudid],
|
|
|
|
]
|
|
|
|
)
|
|
|
|
co = len(cells)
|
2020-09-26 16:19:37 +02:00
|
|
|
if prev_moy:
|
|
|
|
for ue_acro in ue_prev_codes:
|
2021-08-13 12:18:22 +02:00
|
|
|
cells.append(
|
|
|
|
ws.make_cell(
|
|
|
|
fmt(prev_moy_ue.get(ue_acro, {}).get(etudid, "")), style_note
|
|
|
|
)
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
co += 1
|
2021-08-13 12:18:22 +02:00
|
|
|
cells.append(
|
|
|
|
ws.make_cell(fmt(prev_moy.get(etudid, "")), style_bold)
|
|
|
|
) # moy gen prev
|
|
|
|
cells.append(
|
|
|
|
ws.make_cell(fmt(prev_code.get(etudid, "")), style_moy)
|
|
|
|
) # decision prev
|
2020-09-26 16:19:37 +02:00
|
|
|
co += 2
|
|
|
|
|
|
|
|
for ue_acro in ue_codes:
|
2021-08-13 12:18:22 +02:00
|
|
|
cells.append(
|
|
|
|
ws.make_cell(fmt(moy_ue.get(ue_acro, {}).get(etudid, "")), style_note)
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
co += 1
|
2021-08-13 12:18:22 +02:00
|
|
|
cells.append(ws.make_cell(fmt(moy.get(etudid, "")), style_note_bold)) # moy gen
|
2020-09-26 16:19:37 +02:00
|
|
|
co += 1
|
|
|
|
if moy_inter:
|
2021-08-13 12:18:22 +02:00
|
|
|
cells.append(ws.make_cell(fmt(moy_inter.get(etudid, "")), style_note))
|
|
|
|
cells.append(ws.make_cell(str(nbabs.get(etudid, "")), style_center))
|
|
|
|
cells.append(ws.make_cell(str(nbabsjust.get(etudid, "")), style_center))
|
2020-09-26 16:19:37 +02:00
|
|
|
if code:
|
2021-08-13 12:18:22 +02:00
|
|
|
cells.append(ws.make_cell(code.get(etudid, ""), style_moy))
|
|
|
|
cells.append(ws.make_cell(autorisations.get(etudid, ""), style_moy))
|
2020-09-26 16:19:37 +02:00
|
|
|
# l.append(assidu.get(etudid, ''))
|
2021-08-13 12:18:22 +02:00
|
|
|
ws.append_row(cells)
|
2020-09-26 16:19:37 +02:00
|
|
|
i += 1
|
|
|
|
#
|
2021-08-13 12:18:22 +02:00
|
|
|
ws.append_blank_row()
|
2020-09-26 16:19:37 +02:00
|
|
|
# Explications des codes
|
2021-07-09 17:47:06 +02:00
|
|
|
codes = list(sco_codes_parcours.CODES_EXPL.keys())
|
2020-09-26 16:19:37 +02:00
|
|
|
codes.sort()
|
2021-08-13 12:18:22 +02:00
|
|
|
ws.append_single_cell_row("Explication des codes")
|
2020-09-26 16:19:37 +02:00
|
|
|
for code in codes:
|
2021-08-13 12:18:22 +02:00
|
|
|
ws.append_row(
|
|
|
|
ws.make_row(["", "", "", code, sco_codes_parcours.CODES_EXPL[code]])
|
|
|
|
)
|
|
|
|
ws.append_row(
|
|
|
|
ws.make_row(
|
|
|
|
[
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"ADM+",
|
|
|
|
"indique que le semestre a déjà servi à en compenser un autre",
|
|
|
|
]
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
# UE : Correspondances acronyme et titre complet
|
2021-08-13 12:18:22 +02:00
|
|
|
ws.append_blank_row()
|
|
|
|
ws.append_single_cell_row("Titre des UE")
|
2020-09-26 16:19:37 +02:00
|
|
|
if prev_moy:
|
2021-12-24 00:08:25 +01:00
|
|
|
for ue in ntp.get_ues_stat_dict(filter_sport=True):
|
2021-08-13 12:18:22 +02:00
|
|
|
ws.append_row(ws.make_row(["", "", "", ue["acronyme"], ue["titre"]]))
|
2021-12-24 00:08:25 +01:00
|
|
|
for ue in nt.get_ues_stat_dict(filter_sport=True):
|
2021-08-13 12:18:22 +02:00
|
|
|
ws.append_row(ws.make_row(["", "", "", ue["acronyme"], ue["titre"]]))
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
2021-08-13 12:18:22 +02:00
|
|
|
ws.append_blank_row()
|
|
|
|
ws.append_single_cell_row(
|
|
|
|
"Préparé par %s le %s sur %s pour %s"
|
|
|
|
% (
|
2021-08-21 17:07:44 +02:00
|
|
|
sco_version.SCONAME,
|
2021-08-13 12:18:22 +02:00
|
|
|
time.strftime("%d/%m/%Y"),
|
2021-09-18 10:10:02 +02:00
|
|
|
request.url_root,
|
2021-09-18 13:42:19 +02:00
|
|
|
current_user,
|
2021-08-13 12:18:22 +02:00
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2021-09-18 01:30:47 +02:00
|
|
|
xls = ws.generate()
|
2021-09-18 10:11:46 +02:00
|
|
|
return scu.send_file(
|
|
|
|
xls,
|
2021-09-25 09:07:05 +02:00
|
|
|
f"PrepaJury{sn}",
|
2021-09-18 10:11:46 +02:00
|
|
|
scu.XLSX_SUFFIX,
|
2021-09-21 22:19:08 +02:00
|
|
|
mime=scu.XLSX_MIMETYPE,
|
2021-09-18 10:11:46 +02:00
|
|
|
)
|