This commit is contained in:
Jean-Marie Place 2023-06-09 07:27:15 +02:00
parent e9008f8dfa
commit 3eeae16b92
2 changed files with 65 additions and 33 deletions

View File

@ -55,7 +55,7 @@ class NiveauDesc:
if not scodocUe.is_external:
self.ue[parite(scodocUe.semestre_idx)] = scodocUe
def generate_header(self, header):
def generate_header(self, ws: ScoExcelSheet, column: int):
rcue_signature = FMT.FILL_BGCOLOR.write(
value=header_colors[self.fromScodoc.annee]["RCUE"].value,
signature=base_signature,
@ -64,22 +64,39 @@ class NiveauDesc:
value=header_colors[self.fromScodoc.annee]["UE"].value,
signature=base_signature,
)
header.setLabelOnce(1, self.fromScodoc.competence.titre)
header.setSignatures([1], rcue_signature)
header.setSignatures([2, 3], ue_signature)
merge = ws.get_merge_engine(start_row=2, start_column=column)
frame = ws.get_frame_engine(
start_row=2, start_column=column, thickness=SCO_BORDERTHICKNESS.BORDER_THIN
)
ws.set_cell(2, column, self.fromScodoc.libelle, from_signature=rcue_signature)
for ue in self.ue:
frame_ue = ws.get_frame_engine(
start_row=3,
start_column=column,
thickness=SCO_BORDERTHICKNESS.BORDER_THIN,
color=SCO_COLORS.GREY,
)
merge_ue = ws.get_merge_engine(start_row=3, start_column=column)
if ue is None:
header.setLabelOnce(2, "XXX")
header.add_column(label3="Note")
header.add_column(label3="Res.")
ws.set_cell(3, column, "XXX", ue_signature)
else:
header.setLabelOnce(2, ue.acronyme)
header.add_column(label3="Note")
header.add_column(label3="Res.")
header.setSignatures([1, 2, 3], rcue_signature)
header.add_column(label2="RCUE", label3="Note")
header.add_column(label3="Res.")
return header
ws.set_cell(3, column, ue.acronyme, ue_signature)
ws.set_cell(4, column, "Note", ue_signature)
column += 1
ws.set_cell(4, column, "Rés.", ue_signature)
column += 1
merge_ue.close(end_row=3, end_column=column - 1)
frame_ue.close(end_row=4, end_column=column - 1)
merge_rcue = ws.get_merge_engine(start_row=3, start_column=column)
ws.set_cell(3, column, "Competence", rcue_signature)
ws.set_cell(4, column, "Note", rcue_signature)
column += 1
ws.set_cell(4, column, "Rés.", rcue_signature)
column += 1
merge_rcue.close(end_row=3, end_column=column - 1)
frame.close(end_row=4, end_column=column - 1)
merge.close(end_row=2, end_column=column - 1)
return column
def get_ues(self, etudiant):
"""get list of candidates UEs for Niveau"""
@ -120,16 +137,18 @@ class AnneeDesc:
for niveau in niveaux:
self.niveaux[niveau.fromScodoc.id] = niveau
def generate_blank_niveau(self, header):
header.setlabel(1, "-")
for _ in range(3):
header.add_column()
def generate_blank_niveau(self, ws: ScoExcelSheet, column: int):
return column
def generate_header(self, ws: ScoExcelSheet, column: int):
start = column
but_signature = FMT.FILL_BGCOLOR.write(
signature=base_signature, value=header_colors[self.codeAnnee]["BUT"].value
)
merge = ws.get_merge_engine(start_row=1, start_column=column)
frame = ws.get_frame_engine(
start_row=1, start_column=column, thickness=SCO_BORDERTHICKNESS.BORDER_THICK
)
ws.set_cell(
1,
column,
@ -140,25 +159,37 @@ class AnneeDesc:
(FMT.BORDER_LEFT_STYLE, SCO_BORDERTHICKNESS.BORDER_MEDIUM.value),
],
)
# for niveau in self.niveaux.values():
# column = niveau.generate_header(ws, column)
# for i in range(len(self.niveaux), 6):
# column = self.generate_blank_niveau(ws, column)
ws.set_cell(2, column, "Année")
for niveau in self.niveaux.values():
column = niveau.generate_header(ws, column)
for i in range(len(self.niveaux), 6):
column = self.generate_blank_niveau(ws, column)
merge_annee = ws.get_merge_engine(start_row=2, start_column=column)
ws.set_cell(2, column, "Année", from_signature=but_signature)
# cell_format(ws.cell(2, column), but_signature, [(FMT.FONT_BOLD, True)])
ws.set_cell(3, column, "Nb")
ws.set_cell(4, column, "RCUE")
ws.set_cell(3, column, "Nb", from_signature=but_signature)
ws.set_cell(4, column, "RCUE", from_signature=but_signature)
column += 1
ws.set_cell(2, column, "Année")
ws.set_cell(4, column, "Moy.")
ws.set_cell(3, column, from_signature=but_signature)
ws.set_cell(4, column, "Moy.", from_signature=but_signature)
column += 1
ws.set_cell(3, column, from_signature=but_signature)
ws.set_cell(4, column, "Rés.", from_signature=but_signature)
column += 1
merge_annee.close(end_row=2, end_column=column - 1)
if self.codeAnnee == "BUT2":
ws.set_cell(3, column, "DUT")
ws.set_cell(3, column, "Rés.")
ws.set_cell(2, column, "DUT", from_signature=but_signature)
ws.set_cell(3, column, from_signature=but_signature)
ws.set_cell(4, column, "Rés.", from_signature=but_signature)
column += 1
if self.codeAnnee == "BUT3":
ws.set_cell(3, column, "BUT")
ws.set_cell(3, column, "Rés.")
ws.set_cell(2, column, "BUT", from_signature=but_signature)
ws.set_cell(3, column, from_signature=but_signature)
ws.set_cell(4, column, "Rés.", from_signature=but_signature)
column += 1
frame.close(end_row=4, end_column=column - 1)
merge.close(end_row=1, end_column=column - 1)
# ws.merge_cells(start_column=start, end_column=column, start_row=1, end_row=1)
return column
@ -228,8 +259,8 @@ class ParcoursDesc:
title, content_list = description
frame_thickness, frame_color = [
(SCO_BORDERTHICKNESS.BORDER_THICK, SCO_COLORS.BLACK),
(SCO_BORDERTHICKNESS.BORDER_THIN, SCO_COLORS.BLUE),
(SCO_BORDERTHICKNESS.BORDER_HAIR, SCO_COLORS.GREEN),
(SCO_BORDERTHICKNESS.BORDER_HAIR, SCO_COLORS.BLACK),
(SCO_BORDERTHICKNESS.BORDER_HAIR, SCO_COLORS.BLACK),
(SCO_BORDERTHICKNESS.NONE, SCO_COLORS.NONE),
][row - 1]
frame = ws.get_frame_engine(

View File

@ -26,6 +26,7 @@ class SCO_COLORS(Enum):
ORANGE = (7, "FFFF3300")
LIGHT_YELLOW = (8, "FFFFFF99")
GREEN = (9, "FF00FF00")
GREY = (10, "FF101010")
BUT1 = (23, "FF95B3D7")
RCUE1 = (24, "FFB8CCE4")
UE1 = (25, "FFDCE6F1")