notes alpha

This commit is contained in:
Jean-Marie Place 2024-07-01 07:30:45 +02:00
parent db39c89257
commit 5a96e42b6d
2 changed files with 162 additions and 11 deletions

View File

@ -410,7 +410,7 @@ class ScoExcelSheet:
]
else:
return [
self.make_cell(value, style, comment)
self.make_cell(value, styles, comment)
for value, comment in zip(values, comments)
]

View File

@ -39,7 +39,7 @@ from flask import request
from flask_login import current_user
from app import db
from app.but import bulletin_but, cursus_but
from app.but import bulletin_but, cursus_but, jury_but
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import (
@ -58,8 +58,9 @@ from app.scodoc import sco_cursus
from app.scodoc import sco_preferences
import app.scodoc.sco_utils as scu
import sco_version
from app.scodoc.sco_excel import excel_make_style, COLORS
from app.scodoc.sco_excel import excel_make_style, COLORS, ScoExcelSheet
from app.scodoc.sco_excel_add import make_pattern
from app.scodoc.sco_portal_apogee import get_etud_apogee, query_apogee_portal
from app.scodoc.sco_prepajury_formats import Formatter
from app.tables.jury_recap import TableJury
from app.tables.recap import TableRecap
@ -385,6 +386,13 @@ class Export:
self.formsemestre_id: int = formsemestre_id
self.formsemestre: FormSemestre = FormSemestre.get_formsemestre(formsemestre_id)
self.nt: NotesTableCompat = res_sem.load_formsemestre_results(self.formsemestre)
self.recap = TableJury(
self.nt,
convert_values=False,
include_evaluations=False,
mode_jury=True,
read_only=True,
)
etud_groups = sco_groups.formsemestre_get_etud_groupnames(formsemestre_id)
main_partition_id = sco_groups.formsemestre_get_main_partition(formsemestre_id)
self.etuds = self.nt.get_inscrits(order_by="moy")
@ -453,13 +461,21 @@ class Export:
# sexe=quote_xml_attr(etud.civilite_str), # compat
bulletins_sem = bulletin_but.BulletinBUT(self.formsemestre)
self.data_etud[etud.id]["bulletin_but"] = bulletins_sem.bulletin_etud(etud)
self.data_etud[etud.id]["cursus"] = cursus_but.EtudCursusBUT(
etud, self.formsemestre.formation
)
# self.data_etud[etud.id]["bulletin_sem"] = bulletins_sem.bulletin_etud(etud)
# self.data_etud[etud.id]["cursus"] = (
# self.recap.row_by_id[etud.id].cells["code_cursus"].raw_content
# )
self.data_etud[etud.id]["bulletin_sem"] = bulletins_sem.bulletin_etud(etud)
# self.data_etud[etud.id]["nbabs"] = (
# self.recap.row_by_id[etud.id].cells["nbabs"].raw_content
# )
# self.data_etud[etud.id]["nbabsjust"] = (
# self.recap.row_by_id[etud.id].cells["nbabsjust"].raw_content
# )
# self.data_etud[etud.id]["parcours"] = self.recap.row_by_id[etud.id].cells[].raw_content
def load_data(self):
self.load_parcours()
breakpoint()
for etud in self.etuds:
self.data_etud[etud.id] = {}
self.data_etud[etud.id]["etud"] = etud
@ -467,6 +483,33 @@ class Export:
self.load_etu(etud)
session = sco_cursus.get_situation_etud_cursus(etud, self.formsemestre_id)
self.data_etud[etud.id]["cursus"] = session.parcours
nbabsinj, nbabsjust, nbabs = self.formsemestre.get_abs_count(etud.id)
self.data_etud[etud.id]["abs_tot"] = nbabs
self.data_etud[etud.id]["abs_just"] = nbabsjust
self.data_etud[etud.id]["abs_non_just"] = nbabsinj
cursus = " ".join(
[
f"S{ins.formsemestre.semestre_id}"
for ins in reversed(etud.inscriptions())
if ins.formsemestre.formation.formation_code
== self.formsemestre.formation.formation_code
]
)
self.data_etud[etud.id]["code_cursus"] = cursus
self.data_etud[etud.id]["deca"] = [
jury_but.DecisionsProposeesAnnee(etud, ins.formsemestre)
for ins in reversed(etud.inscriptions())
]
self.data_etud[etud.id]["history"] = {
1: None,
2: None,
3: None,
4: None,
5: None,
6: None,
}
for deca in self.data_etud[etud.id]["deca"]:
self.data_etud[etud.id]["history"][deca.formsemestre.semestre_id] = deca
self.load_formsemestre(etud, session)
def build_formator(self):
@ -555,8 +598,6 @@ class Export:
# ),
)
)
# sheet.ws.merge_cells(start_row=5, end_row=5, start_column=1, end_column=9)
# sheet.ws.merge_cells("A5:J5")
def merge_header(self, frames, element, top, left):
if element is None or top >= 8:
@ -577,6 +618,117 @@ class Export:
frames.append((top, left, top, next - 1))
return next
def translate_ue(self, code):
return {
"ADM": "VAL",
"AJ": "AJ",
"ADJ": "ADJI",
"PASD": "PASD",
"CMP": "COMP",
}.get(code, f"<{code}>")
def translate_rcue(self, code):
return {
"ADM": "VAL",
"AJ": "AJ",
"ADJ": "ADJI",
"PASD": "PASD",
"CMP": "COMP",
}.get(code, f"<{code}>")
def translate_ann(self, code):
return {
"ADM": "VAL",
"AJ": "AJ",
"ADJ": "ADJI",
"PASD": "PASD",
"ADSUP": "VALR",
}.get(code, f"<{code}>")
def detail_competence(self, etud, semestre, comp_no):
history = self.data_etud[etud.id]["history"][semestre]
if semestre % 2 == 0:
result = ["", "", "", ""]
else:
result = ["", ""]
if history is not None and comp_no < len(history.niveaux_competences):
niveau = history.niveaux_competences[comp_no]
rcue = history.rcue_by_niveau[niveau.id]
if semestre % 2 == 1:
ue1 = rcue.ue_1
val_ue1 = (
None if ue1 is None else history.decisions_ues[ue1.id].validation
)
dec_ue1 = "" if val_ue1 is None else self.translate_ue(val_ue1.code)
result = [rcue.moy_ue_1, dec_ue1]
else:
ue2 = rcue.ue_2
val_ue2 = (
None if ue2 is None else history.decisions_ues[ue2.id].validation
)
dec_ue2 = "" if val_ue2 is None else self.translate_ue(val_ue2.code)
val_niv = history.decisions_rcue_by_niveau[niveau.id].validation
dec_niv = "" if val_niv is None else self.translate_rcue(val_niv.code)
result = [rcue.moy_ue_2, dec_ue2, rcue.moy_rcue, dec_niv]
return result
def detail_annuel(self, etud, but):
result = ["", "", ""] if but == 1 else ["", "", "", ""]
history = self.data_etud[etud.id]["history"].get(but * 2, None)
if history is not None:
nb_rcue_valides = history.nb_rcue_valides
moy_gen = self.calcul_moy_ann(etud, but)
if history.validation:
dec_ann = self.translate_ann(history.validation.code)
else:
dec_ann = ""
result = [nb_rcue_valides, moy_gen, dec_ann]
if but != 1:
if dec_ann in {"ADM"}:
result.append("ADM")
else:
result.append("AJ")
return result
def calcul_moy_ann(self, etud, but):
pass
history = self.data_etud[etud.id]["history"].get(but * 2, None)
nb_rcues = 0
tot_rcues = 0.0
for rcue in history.rcue_by_niveau.values():
if rcue.moy_rcue is not None:
tot_rcues += rcue.moy_rcue
nb_rcues += 1
if nb_rcues > 0:
return tot_rcues / nb_rcues
else:
return ""
def display(self, sheet: ScoExcelSheet):
for etud in self.etuds:
values = [
etud.id,
etud.code_nip,
etud.civilite,
etud.nom,
etud.prenom,
""
if self.data_etud[etud.id]["deca"][-1].parcour is None
else self.data_etud[etud.id]["deca"][-1].parcour.code,
self.data_etud[etud.id]["code_cursus"],
self.data_etud[etud.id]["abs_tot"],
self.data_etud[etud.id]["abs_non_just"],
]
for but in range(1, 4):
sImpair = 2 * but - 1
sPair = 2 * but
for comp in range(0, 6):
values += self.detail_competence(etud, sImpair, comp)
values += self.detail_competence(etud, sPair, comp)
values += self.detail_annuel(etud, but)
row = sheet.make_row(values)
sheet.append_row(row)
def feuille_preparation_lille(formsemestre_id):
"""Feuille excel pour préparation des jurys classiques."""
@ -722,7 +874,7 @@ def feuille_preparation_lille(formsemestre_id):
# )
# UE : Correspondances acronyme et titre complet
sheet.append_blank_row()
export.display(sheet)
# export.merge_header(sheet, CATEGORIES["ETUDIANT"]["Absences"]["Tot."], 6, 8, 5)
# sheet.append_single_cell_row("Titre des UE")
# if prev_moy:
@ -741,7 +893,6 @@ def feuille_preparation_lille(formsemestre_id):
# current_user,
# )
# )
breakpoint()
merged = []
export.merge_header(merged, CATEGORIES, 4, 1)
xls = sheet.generate(merged=merged)