Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc into assi_ev

This commit is contained in:
Emmanuel Viennet 2023-12-03 16:20:52 +01:00
commit 7d4d26fe2b
2 changed files with 28 additions and 2 deletions

View File

@ -218,6 +218,7 @@ class ScoExcelSheet:
self.rows = [] # list of list of cells
self.column_dimensions = {}
self.row_dimensions = {}
self.auto_filter = None
def excel_make_composite_style(
self,
@ -283,6 +284,16 @@ class ScoExcelSheet:
"""
self.ws.row_dimensions[cle].hidden = value
def set_column_dimension_hidden(self, cle, value):
"""Masque ou affiche une ligne.
cle -- identifie la colonne (1...)
value -- boolean (vrai = colonne cachée)
"""
self.ws.column_dimensions[cle].hidden = value
def set_auto_filter(self, range):
self.auto_filter = range
def make_cell(self, value: any = None, style=None, comment=None):
"""Construit une cellule.
value -- contenu de la cellule (texte, numérique, booléen ou date)
@ -383,6 +394,8 @@ class ScoExcelSheet:
# construction d'un flux (https://openpyxl.readthedocs.io/en/stable/tutorial.html#saving-as-a-stream)
self.prepare()
if self.auto_filter is not None:
self.ws.auto_filter.ref = self.auto_filter
with NamedTemporaryFile() as tmp:
self.wb.save(tmp.name)
tmp.seek(0)
@ -450,6 +463,8 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line
ws.set_column_dimension_width("D", 164.0 / 7) # groupes
ws.set_column_dimension_width("E", 115.0 / 7) # notes
ws.set_column_dimension_width("F", 355.0 / 7) # remarques
ws.set_column_dimension_width("G", 72.0 / 7) # colonne NIP
ws.set_column_dimension_hidden("G", True) # colonne NIP cachée
# fontes
font_base = Font(name="Arial", size=12)
@ -498,6 +513,13 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line
"border": border_top,
}
# filtre
filter_top = 8
filter_bottom = 8 + len(lines)
filter_left = "A"
filter_right = "G"
ws.set_auto_filter(f"${filter_left}${filter_top}:${filter_right}${filter_bottom}")
# ligne de titres
ws.append_single_cell_row(
"Feuille saisie note (à enregistrer au format excel)", style_titres
@ -526,6 +548,7 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line
ws.make_cell("Groupe", style_titres),
ws.make_cell("Note sur %g" % (evaluation.note_max or 0.0), style_titres),
ws.make_cell("Remarque", style_titres),
ws.make_cell("NIP", style_titres),
]
)
@ -552,9 +575,13 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line
ws.make_cell(s, st),
ws.make_cell(val, style_notes), # note
ws.make_cell(line[6], style_comment), # comment
ws.make_cell(line[7], style_ro), # NIP
]
)
# ligne blanche
ws.append_blank_row()
# explication en bas
ws.append_row([None, ws.make_cell("Code notes", style_titres)])
ws.append_row(

View File

@ -922,13 +922,11 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]):
# une liste de liste de chaines: lignes de la feuille de calcul
rows = []
etuds = _get_sorted_etuds(evaluation, etudids, formsemestre.id)
for e in etuds:
etudid = e["etudid"]
groups = sco_groups.get_etud_groups(etudid, formsemestre.id)
grc = sco_groups.listgroups_abbrev(groups)
rows.append(
[
str(etudid),
@ -938,6 +936,7 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]):
grc,
e["val"],
e["explanation"],
e["code_nip"],
]
)