forked from ScoDoc/ScoDoc
Bulletins PDV BUT, v0
This commit is contained in:
parent
fe6790738f
commit
a83d491874
@ -177,7 +177,7 @@ class BulletinBUT:
|
|||||||
"date": e.jour.isoformat() if e.jour else None,
|
"date": e.jour.isoformat() if e.jour else None,
|
||||||
"heure_debut": e.heure_debut.strftime("%H:%M") if e.heure_debut else None,
|
"heure_debut": e.heure_debut.strftime("%H:%M") if e.heure_debut else None,
|
||||||
"heure_fin": e.heure_fin.strftime("%H:%M") if e.heure_debut else None,
|
"heure_fin": e.heure_fin.strftime("%H:%M") if e.heure_debut else None,
|
||||||
"coef": e.coefficient,
|
"coef": fmt_note(e.coefficient),
|
||||||
"poids": {p.ue.acronyme: p.poids for p in e.ue_poids},
|
"poids": {p.ue.acronyme: p.poids for p in e.ue_poids},
|
||||||
"note": {
|
"note": {
|
||||||
"value": fmt_note(
|
"value": fmt_note(
|
||||||
|
@ -7,19 +7,12 @@
|
|||||||
"""Génération bulletin BUT au format PDF standard
|
"""Génération bulletin BUT au format PDF standard
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
from reportlab.platypus import KeepInFrame, Paragraph, Spacer
|
||||||
|
|
||||||
from app.scodoc.sco_pdf import blue, cm, mm
|
from app.scodoc.sco_pdf import blue, cm, mm
|
||||||
|
|
||||||
from flask import url_for, g
|
|
||||||
from app.models.formsemestre import FormSemestre
|
|
||||||
|
|
||||||
from app.scodoc import gen_tables
|
from app.scodoc import gen_tables
|
||||||
from app.scodoc import sco_utils as scu
|
|
||||||
from app.scodoc import sco_bulletins_json
|
|
||||||
from app.scodoc import sco_preferences
|
|
||||||
from app.scodoc.sco_codes_parcours import UE_SPORT
|
|
||||||
from app.scodoc.sco_utils import fmt_note
|
from app.scodoc.sco_utils import fmt_note
|
||||||
from app.comp.res_but import ResultatsSemestreBUT
|
|
||||||
|
|
||||||
from app.scodoc.sco_bulletins_standard import BulletinGeneratorStandard
|
from app.scodoc.sco_bulletins_standard import BulletinGeneratorStandard
|
||||||
|
|
||||||
@ -31,6 +24,7 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
list_in_menu = False # spécialisation du BulletinGeneratorStandard, ne pas présenter à l'utilisateur
|
list_in_menu = False # spécialisation du BulletinGeneratorStandard, ne pas présenter à l'utilisateur
|
||||||
|
scale_table_in_page = False
|
||||||
|
|
||||||
def bul_table(self, format="html"):
|
def bul_table(self, format="html"):
|
||||||
"""Génère la table centrale du bulletin de notes
|
"""Génère la table centrale du bulletin de notes
|
||||||
@ -38,31 +32,35 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard):
|
|||||||
- en HTML: une chaine
|
- en HTML: une chaine
|
||||||
- en PDF: une liste d'objets PLATYPUS (eg instance de Table).
|
- en PDF: une liste d'objets PLATYPUS (eg instance de Table).
|
||||||
"""
|
"""
|
||||||
formsemestre_id = self.infos["formsemestre_id"]
|
tables_infos = [
|
||||||
(
|
# ---- TABLE SYNTHESE UES
|
||||||
synth_col_keys,
|
self.but_table_synthese_ues(),
|
||||||
synth_P,
|
# ---- TABLE RESSOURCES
|
||||||
synth_pdf_style,
|
self.but_table_ressources(),
|
||||||
synth_col_widths,
|
# ---- TABLE SAE
|
||||||
) = self.but_table_synthese()
|
self.but_table_saes(),
|
||||||
#
|
]
|
||||||
table_synthese = gen_tables.GenTable(
|
objects = []
|
||||||
rows=synth_P,
|
for i, (col_keys, rows, pdf_style, col_widths) in enumerate(tables_infos):
|
||||||
columns_ids=synth_col_keys,
|
table = gen_tables.GenTable(
|
||||||
pdf_table_style=synth_pdf_style,
|
rows=rows,
|
||||||
pdf_col_widths=[synth_col_widths[k] for k in synth_col_keys],
|
columns_ids=col_keys,
|
||||||
preferences=self.preferences,
|
pdf_table_style=pdf_style,
|
||||||
html_class="notes_bulletin",
|
pdf_col_widths=[col_widths[k] for k in col_keys],
|
||||||
html_class_ignore_default=True,
|
preferences=self.preferences,
|
||||||
html_with_td_classes=True,
|
html_class="notes_bulletin",
|
||||||
)
|
html_class_ignore_default=True,
|
||||||
# Ici on ajoutera table des ressources, tables des UE
|
html_with_td_classes=True,
|
||||||
# TODO
|
)
|
||||||
|
table_objects = table.gen(format=format)
|
||||||
|
objects += table_objects
|
||||||
|
# objects += [KeepInFrame(0, 0, table_objects, mode="shrink")]
|
||||||
|
if i != 2:
|
||||||
|
objects.append(Spacer(1, 6 * mm))
|
||||||
|
|
||||||
# XXX à modifier pour générer plusieurs tables:
|
return objects
|
||||||
return table_synthese.gen(format=format)
|
|
||||||
|
|
||||||
def but_table_synthese(self):
|
def but_table_synthese_ues(self, title_bg=(182, 235, 255)):
|
||||||
"""La table de synthèse; pour chaque UE, liste des ressources et SAÉs avec leurs notes
|
"""La table de synthèse; pour chaque UE, liste des ressources et SAÉs avec leurs notes
|
||||||
et leurs coefs.
|
et leurs coefs.
|
||||||
Renvoie: colkeys, P, pdf_style, colWidths
|
Renvoie: colkeys, P, pdf_style, colWidths
|
||||||
@ -76,8 +74,30 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard):
|
|||||||
"moyenne": 2 * cm,
|
"moyenne": 2 * cm,
|
||||||
"coef": 2 * cm,
|
"coef": 2 * cm,
|
||||||
}
|
}
|
||||||
P = [] # elems pour générer table avec gen_table (liste de dicts)
|
title_bg = tuple(x / 255.0 for x in title_bg)
|
||||||
col_keys = ["titre", "moyenne"] # noms des colonnes à afficher
|
# elems pour générer table avec gen_table (liste de dicts)
|
||||||
|
rows = [
|
||||||
|
# Ligne de titres
|
||||||
|
{
|
||||||
|
"titre": "Unités d'enseignement",
|
||||||
|
"moyenne": "Note/20",
|
||||||
|
"coef": "Coef.",
|
||||||
|
"_css_row_class": "note_bold",
|
||||||
|
"_pdf_row_markup": ["b"],
|
||||||
|
"_pdf_style": [
|
||||||
|
("BACKGROUND", (0, 0), (-1, 0), title_bg),
|
||||||
|
("BOTTOMPADDING", (0, 0), (-1, 0), 7),
|
||||||
|
(
|
||||||
|
"LINEBELOW",
|
||||||
|
(0, 0),
|
||||||
|
(-1, 0),
|
||||||
|
self.PDF_LINEWIDTH,
|
||||||
|
blue,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
col_keys = ["titre", "moyenne", "coef"] # noms des colonnes à afficher
|
||||||
for ue_acronym, ue in self.infos["ues"].items():
|
for ue_acronym, ue in self.infos["ues"].items():
|
||||||
# 1er ligne titre UE
|
# 1er ligne titre UE
|
||||||
moy_ue = ue.get("moyenne")
|
moy_ue = ue.get("moyenne")
|
||||||
@ -86,31 +106,163 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard):
|
|||||||
"moyenne": moy_ue.get("value", "-") if moy_ue is not None else "-",
|
"moyenne": moy_ue.get("value", "-") if moy_ue is not None else "-",
|
||||||
"_css_row_class": "note_bold",
|
"_css_row_class": "note_bold",
|
||||||
"_pdf_row_markup": ["b"],
|
"_pdf_row_markup": ["b"],
|
||||||
"_pdf_style": [],
|
"_pdf_style": [
|
||||||
|
(
|
||||||
|
"LINEABOVE",
|
||||||
|
(0, 0),
|
||||||
|
(-1, 0),
|
||||||
|
self.PDF_LINEWIDTH,
|
||||||
|
self.PDF_LINECOLOR,
|
||||||
|
),
|
||||||
|
("BACKGROUND", (0, 0), (-1, 0), title_bg),
|
||||||
|
("BOTTOMPADDING", (0, 0), (-1, 0), 7),
|
||||||
|
],
|
||||||
}
|
}
|
||||||
P.append(t)
|
rows.append(t)
|
||||||
# 2eme ligne titre UE (bonus/malus/ects)
|
# 2eme ligne titre UE (bonus/malus/ects)
|
||||||
t = {
|
t = {
|
||||||
"titre": "",
|
"titre": f"""Bonus: {ue['bonus']} - Malus: {
|
||||||
"moyenne": f"""Bonus: {ue['bonus']} - Malus: {
|
ue["malus"]}""",
|
||||||
ue["malus"]} - ECTS: {ue["ECTS"]["acquis"]} / {ue["ECTS"]["total"]}""",
|
"moyenne": f"""ECTS: {ue["ECTS"]["acquis"]} / {ue["ECTS"]["total"]}""",
|
||||||
"_css_row_class": "note_bold",
|
"_moyenne_colspan": 2,
|
||||||
"_pdf_row_markup": ["b"],
|
# "_css_row_class": "",
|
||||||
|
# "_pdf_row_markup": [""],
|
||||||
"_pdf_style": [
|
"_pdf_style": [
|
||||||
|
("ALIGN", (0, 0), (1, 0), "RIGHT"),
|
||||||
|
("TEXTCOLOR", (0, 0), (-1, 0), blue),
|
||||||
|
("BACKGROUND", (0, 0), (-1, 0), title_bg),
|
||||||
(
|
(
|
||||||
"LINEBELOW",
|
"LINEBELOW",
|
||||||
(0, 0),
|
(0, 0),
|
||||||
(-1, 0),
|
(-1, 0),
|
||||||
self.PDF_LINEWIDTH,
|
self.PDF_LINEWIDTH,
|
||||||
self.PDF_LINECOLOR,
|
self.PDF_LINECOLOR,
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
P.append(t)
|
rows.append(t)
|
||||||
|
# Liste chaque ressource
|
||||||
|
for mod_code, mod in ue["ressources"].items():
|
||||||
|
t = {
|
||||||
|
"titre": f"{mod_code} {self.infos['ressources'][mod_code]['titre']}",
|
||||||
|
"moyenne": mod["moyenne"],
|
||||||
|
"coef": mod["coef"],
|
||||||
|
"_coef_pdf": Paragraph(
|
||||||
|
f"<para align=right><i>{mod['coef']}</i></para>"
|
||||||
|
),
|
||||||
|
"_pdf_style": [
|
||||||
|
(
|
||||||
|
"LINEBELOW",
|
||||||
|
(0, 0),
|
||||||
|
(-1, 0),
|
||||||
|
self.PDF_LINEWIDTH,
|
||||||
|
(0.7, 0.7, 0.7), # gris clair
|
||||||
|
)
|
||||||
|
],
|
||||||
|
}
|
||||||
|
rows.append(t)
|
||||||
# Global pdf style commands:
|
# Global pdf style commands:
|
||||||
pdf_style = [
|
pdf_style = [
|
||||||
("VALIGN", (0, 0), (-1, -1), "TOP"),
|
("VALIGN", (0, 0), (-1, -1), "TOP"),
|
||||||
("BOX", (0, 0), (-1, -1), 0.4, blue), # ajoute cadre extérieur bleu:
|
("BOX", (0, 0), (-1, -1), 0.4, blue), # ajoute cadre extérieur bleu:
|
||||||
]
|
]
|
||||||
return col_keys, P, pdf_style, col_widths
|
return col_keys, rows, pdf_style, col_widths
|
||||||
|
|
||||||
|
def but_table_ressources(self):
|
||||||
|
"""La table de synthèse; pour chaque ressources, note et liste d'évaluations
|
||||||
|
Renvoie: colkeys, P, pdf_style, colWidths
|
||||||
|
"""
|
||||||
|
return self.bul_table_modules(
|
||||||
|
mod_type="ressources", title="Ressources", title_bg=(248, 200, 68)
|
||||||
|
)
|
||||||
|
|
||||||
|
def but_table_saes(self):
|
||||||
|
"table des SAEs"
|
||||||
|
return self.bul_table_modules(
|
||||||
|
mod_type="saes",
|
||||||
|
title="Situations d'apprentissage et d'évaluation",
|
||||||
|
title_bg=(198, 255, 171),
|
||||||
|
)
|
||||||
|
|
||||||
|
def bul_table_modules(self, mod_type=None, title="", title_bg=(248, 200, 68)):
|
||||||
|
"""Table ressources ou SAEs
|
||||||
|
- colkeys: nom des colonnes de la table (clés)
|
||||||
|
- P : table (liste de dicts de chaines de caracteres)
|
||||||
|
- pdf_style : commandes table Platypus
|
||||||
|
- largeurs de colonnes pour PDF
|
||||||
|
"""
|
||||||
|
col_widths = {
|
||||||
|
"titre": None,
|
||||||
|
"moyenne": 2 * cm,
|
||||||
|
"coef": 2 * cm,
|
||||||
|
}
|
||||||
|
title_bg = tuple(x / 255.0 for x in title_bg)
|
||||||
|
# elems pour générer table avec gen_table (liste de dicts)
|
||||||
|
rows = [
|
||||||
|
# Ligne de titres
|
||||||
|
{
|
||||||
|
"titre": title,
|
||||||
|
"moyenne": "Note/20",
|
||||||
|
"coef": "Coef.",
|
||||||
|
"_css_row_class": "note_bold",
|
||||||
|
"_pdf_row_markup": ["b"],
|
||||||
|
"_pdf_style": [
|
||||||
|
("BACKGROUND", (0, 0), (-1, 0), title_bg),
|
||||||
|
("BOTTOMPADDING", (0, 0), (-1, 0), 7),
|
||||||
|
(
|
||||||
|
"LINEBELOW",
|
||||||
|
(0, 0),
|
||||||
|
(-1, 0),
|
||||||
|
self.PDF_LINEWIDTH,
|
||||||
|
blue,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
col_keys = ["titre", "moyenne", "coef"] # noms des colonnes à afficher
|
||||||
|
for mod_code, mod in self.infos[mod_type].items():
|
||||||
|
# 1er ligne titre module
|
||||||
|
t = {
|
||||||
|
"titre": f"{mod_code} - {mod['titre']}",
|
||||||
|
"moyenne": "", # pas de moyenne
|
||||||
|
"_css_row_class": "note_bold",
|
||||||
|
"_pdf_row_markup": ["b"],
|
||||||
|
"_pdf_style": [
|
||||||
|
(
|
||||||
|
"LINEABOVE",
|
||||||
|
(0, 0),
|
||||||
|
(-1, 0),
|
||||||
|
self.PDF_LINEWIDTH,
|
||||||
|
self.PDF_LINECOLOR,
|
||||||
|
),
|
||||||
|
("BACKGROUND", (0, 0), (-1, 0), title_bg),
|
||||||
|
("BOTTOMPADDING", (0, 0), (-1, 0), 7),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
rows.append(t)
|
||||||
|
# Evaluations:
|
||||||
|
for e in mod["evaluations"]:
|
||||||
|
t = {
|
||||||
|
"titre": f"{e['description']}",
|
||||||
|
"moyenne": e["note"]["value"],
|
||||||
|
"coef": e["coef"],
|
||||||
|
"_coef_pdf": Paragraph(
|
||||||
|
f"<para align=right><i>{e['coef']}</i></para>"
|
||||||
|
),
|
||||||
|
"_pdf_style": [
|
||||||
|
(
|
||||||
|
"LINEBELOW",
|
||||||
|
(0, 0),
|
||||||
|
(-1, 0),
|
||||||
|
self.PDF_LINEWIDTH,
|
||||||
|
(0.7, 0.7, 0.7), # gris clair
|
||||||
|
)
|
||||||
|
],
|
||||||
|
}
|
||||||
|
rows.append(t)
|
||||||
|
# Global pdf style commands:
|
||||||
|
pdf_style = [
|
||||||
|
("VALIGN", (0, 0), (-1, -1), "TOP"),
|
||||||
|
("BOX", (0, 0), (-1, -1), 0.4, blue), # ajoute cadre extérieur bleu:
|
||||||
|
]
|
||||||
|
return col_keys, rows, pdf_style, col_widths
|
||||||
|
@ -71,6 +71,7 @@ class BulletinGenerator:
|
|||||||
supported_formats = [] # should list supported formats, eg [ 'html', 'pdf' ]
|
supported_formats = [] # should list supported formats, eg [ 'html', 'pdf' ]
|
||||||
description = "superclass for bulletins" # description for user interface
|
description = "superclass for bulletins" # description for user interface
|
||||||
list_in_menu = True # la classe doit-elle est montrée dans le menu de config ?
|
list_in_menu = True # la classe doit-elle est montrée dans le menu de config ?
|
||||||
|
scale_table_in_page = True # rescale la table sur 1 page
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -163,8 +164,9 @@ class BulletinGenerator:
|
|||||||
# signatures
|
# signatures
|
||||||
objects += self.bul_signatures_pdf() # pylint: disable=no-member
|
objects += self.bul_signatures_pdf() # pylint: disable=no-member
|
||||||
|
|
||||||
# Réduit sur une page
|
if self.scale_table_in_page:
|
||||||
objects = [KeepInFrame(0, 0, objects, mode="shrink")]
|
# Réduit sur une page
|
||||||
|
objects = [KeepInFrame(0, 0, objects, mode="shrink")]
|
||||||
#
|
#
|
||||||
if not stand_alone:
|
if not stand_alone:
|
||||||
objects.append(PageBreak()) # insert page break at end
|
objects.append(PageBreak()) # insert page break at end
|
||||||
@ -219,7 +221,7 @@ class BulletinGenerator:
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
def make_formsemestre_bulletinetud(
|
def make_formsemestre_bulletinetud(
|
||||||
infos,
|
infos,
|
||||||
version="long", # short, long, selectedevals
|
version=None, # short, long, selectedevals
|
||||||
format="pdf", # html, pdf
|
format="pdf", # html, pdf
|
||||||
stand_alone=True,
|
stand_alone=True,
|
||||||
):
|
):
|
||||||
@ -231,6 +233,7 @@ def make_formsemestre_bulletinetud(
|
|||||||
"""
|
"""
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
|
|
||||||
|
version = version or "long"
|
||||||
if not version in scu.BULLETINS_VERSIONS:
|
if not version in scu.BULLETINS_VERSIONS:
|
||||||
raise ValueError("invalid version code !")
|
raise ValueError("invalid version code !")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user