Merge branch 'dev92' of https://scodoc.org/git/viennet/ScoDoc into new_api

This commit is contained in:
Emmanuel Viennet 2022-04-11 08:16:23 +02:00
commit ed09d6263b
40 changed files with 1324 additions and 1233 deletions

View File

@ -228,7 +228,7 @@ class BonusSportAdditif(BonusSport):
axis=1,
)
# Seuil: bonus dans [min, max] (défaut [0,20])
bonus_max = self.bonus_max or 0.0
bonus_max = self.bonus_max or 20.0
np.clip(bonus_moy_arr, self.bonus_min, bonus_max, out=bonus_moy_arr)
self.bonus_additif(bonus_moy_arr)
@ -418,17 +418,46 @@ class BonusAmiens(BonusSportAdditif):
class BonusBethune(BonusSportMultiplicatif):
"""Calcul bonus modules optionnels (sport), règle IUT de Béthune.
Les points au dessus de la moyenne de 10 apportent un bonus pour le semestre.
Ce bonus est égal au nombre de points divisé par 200 et multiplié par la
moyenne générale du semestre de l'étudiant.
"""
Calcul bonus modules optionnels (sport, culture), règle IUT de Béthune.
<p>
<b>Pour le BUT :</b>
La note de sport est sur 20, et on calcule une bonification (en %)
qui va s'appliquer à <b>la moyenne de chaque UE</b> du semestre en appliquant
la formule : bonification (en %) = max(note-10, 0)*(1/<b>500</b>).
</p><p>
<em>La bonification ne s'applique que si la note est supérieure à 10.</em>
</p><p>
(Une note de 10 donne donc 0% de bonif,
1 point au dessus de 10 augmente la moyenne des UE de 0.2%)
</p>
<p>
<b>Pour le DUT/LP :</b>
La note de sport est sur 20, et on calcule une bonification (en %)
qui va s'appliquer à <b>la moyenne générale</b> du semestre en appliquant
la formule : bonification (en %) = max(note-10, 0)*(1/<b>200</b>).
</p><p>
<em>La bonification ne s'applique que si la note est supérieure à 10.</em>
</p><p>
(Une note de 10 donne donc 0% de bonif,
1 point au dessus de 10 augmente la moyenne des UE de 0.5%)
</p>
"""
name = "bonus_iutbethune"
displayed_name = "IUT de Béthune"
seuil_moy_gen = 10.0
amplitude = 0.005
seuil_moy_gen = 10.0 # points comptés au dessus de 10.
def compute_bonus(self, sem_modimpl_moys_inscrits, modimpl_coefs_etuds_no_nan):
"""calcul du bonus"""
if self.formsemestre.formation.is_apc():
self.amplitude = 0.002
else:
self.amplitude = 0.005
return super().compute_bonus(
sem_modimpl_moys_inscrits, modimpl_coefs_etuds_no_nan
)
class BonusBezier(BonusSportAdditif):
@ -502,10 +531,11 @@ class BonusCachan1(BonusSportAdditif):
<ul>
<li> DUT/LP : la meilleure note d'option, si elle est supérieure à 10,
bonifie les moyennes d'UE (<b>sauf l'UE41 dont le code est UE41_E</b>) à raison
bonifie les moyennes d'UE (uniquement UE13_E pour le semestre 1, UE23_E
pour le semestre 2, UE33_E pour le semestre 3 et UE43_E pour le semestre
4) à raison
de <em>bonus = (option - 10)/10</em>.
</li>
<li> BUT : la meilleure note d'option, si elle est supérieure à 10, bonifie
les moyennes d'UE à raison de <em>bonus = (option - 10) * 3%</em>.</li>
</ul>
@ -516,6 +546,7 @@ class BonusCachan1(BonusSportAdditif):
seuil_moy_gen = 10.0 # tous les points sont comptés
proportion_point = 0.03
classic_use_bonus_ues = True
ues_bonifiables_cachan = {"UE13_E", "UE23_E", "UE33_E", "UE43_E"}
def compute_bonus(self, sem_modimpl_moys_inscrits, modimpl_coefs_etuds_no_nan):
"""calcul du bonus, avec réglage différent suivant le type de formation"""
@ -540,7 +571,7 @@ class BonusCachan1(BonusSportAdditif):
dtype=float,
)
else: # --- DUT
# pareil mais proportion différente et exclusion d'une UE
# pareil mais proportion différente et application à certaines UEs
proportion_point = 0.1
bonus_moy_arr = np.where(
note_bonus_max > self.seuil_moy_gen,
@ -553,10 +584,10 @@ class BonusCachan1(BonusSportAdditif):
columns=ues_idx,
dtype=float,
)
# Pas de bonus sur la ou les ue de code "UE41_E"
ue_exclues = [ue for ue in ues if ue.ue_code == "UE41_E"]
for ue in ue_exclues:
self.bonus_ues[ue.id] = 0.0
# Applique bonus seulement sur certaines UE de code connu:
for ue in ues:
if ue.ue_code not in self.ues_bonifiables_cachan:
self.bonus_ues[ue.id] = 0.0 # annule
class BonusCalais(BonusSportAdditif):
@ -982,7 +1013,7 @@ class BonusTarbes(BonusSportAdditif):
"""
name = "bonus_tarbes"
displayed_name = "IUT de Tazrbes"
displayed_name = "IUT de Tarbes"
seuil_moy_gen = 10.0
proportion_point = 1 / 30.0
classic_use_bonus_ues = True

View File

@ -92,6 +92,8 @@ class ModuleImplResults:
ou NaN si les évaluations (dans lesquelles l'étudiant a des notes)
ne donnent pas de coef vers cette UE.
"""
self.evals_etudids_sans_note = {}
"""dict: evaluation_id : set des etudids non notés dans cette eval, sans les démissions."""
self.load_notes()
self.etuds_use_session2 = pd.Series(False, index=self.evals_notes.index)
"""1 bool par etud, indique si sa moyenne de module vient de la session2"""
@ -142,12 +144,13 @@ class ModuleImplResults:
# ou évaluation déclarée "à prise en compte immédiate"
# Les évaluations de rattrapage et 2eme session sont toujours incomplètes
# car on calcule leur moyenne à part.
etudids_sans_note = inscrits_module - set(eval_df.index) # sans les dem.
is_complete = (evaluation.evaluation_type == scu.EVALUATION_NORMALE) and (
evaluation.publish_incomplete
or (not (inscrits_module - set(eval_df.index)))
evaluation.publish_incomplete or (not etudids_sans_note)
)
self.evaluations_completes.append(is_complete)
self.evaluations_completes_dict[evaluation.id] = is_complete
self.evals_etudids_sans_note[evaluation.id] = etudids_sans_note
# NULL en base => ABS (= -999)
eval_df.fillna(scu.NOTES_ABSENCE, inplace=True)
@ -193,7 +196,9 @@ class ModuleImplResults:
return eval_df
def _etudids(self):
"""L'index du dataframe est la liste de tous les étudiants inscrits au semestre"""
"""L'index du dataframe est la liste de tous les étudiants inscrits au semestre
(incluant les DEM et DEF)
"""
return [
inscr.etudid
for inscr in ModuleImpl.query.get(

View File

@ -14,18 +14,19 @@ import pandas as pd
from flask import g, url_for
from app.auth.models import User
from app.comp.res_cache import ResultatsCache
from app.comp import res_sem
from app.comp.moy_mod import ModuleImplResults
from app.models import FormSemestre, FormSemestreUECoef
from app.models import FormSemestre, FormSemestreUECoef, formsemestre
from app.models import Identite
from app.models import ModuleImpl, ModuleImplInscription
from app.models.ues import UniteEns
from app.scodoc.sco_cache import ResultatsSemestreCache
from app.scodoc.sco_codes_parcours import UE_SPORT, DEF, DEM
from app.scodoc import sco_evaluation_db
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc import sco_groups
from app.scodoc import sco_users
from app.scodoc import sco_utils as scu
# Il faut bien distinguer
@ -387,7 +388,9 @@ class ResultatsSemestre(ResultatsCache):
# --- TABLEAU RECAP
def get_table_recap(self, convert_values=False):
def get_table_recap(
self, convert_values=False, include_evaluations=False, modejury=False
):
"""Result: tuple avec
- rows: liste de dicts { column_id : value }
- titles: { column_id : title }
@ -413,7 +416,6 @@ class ResultatsSemestre(ResultatsCache):
- les colonnes de modules (SAE ou res.) d'une UE ont la classe mod_ue_<ue_id>
_<column_id>_order : clé de tri
"""
if convert_values:
fmt_note = scu.fmt_note
else:
@ -429,6 +431,7 @@ class ResultatsSemestre(ResultatsCache):
titles = {}
# les titres en footer: les mêmes, mais avec des bulles et liens:
titles_bot = {}
dict_nom_res = {} # cache uid : nomcomplet
def add_cell(
row: dict,
@ -457,6 +460,11 @@ class ResultatsSemestre(ResultatsCache):
idx = 0 # index de la colonne
etud = Identite.query.get(etudid)
row = {"etudid": etudid}
# --- Codes (seront cachés, mais exportés en excel)
idx = add_cell(row, "etudid", "etudid", etudid, "codes", idx)
idx = add_cell(
row, "code_nip", "code_nip", etud.code_nip or "", "codes", idx
)
# --- Rang
idx = add_cell(
row, "rang", "Rg", self.etud_moy_gen_ranks[etudid], "rang", idx
@ -532,22 +540,28 @@ class ResultatsSemestre(ResultatsCache):
titles_bot[
f"_{col_id}_target_attrs"
] = f"""title="{ue.titre} S{ue.semestre_idx or '?'}" """
if modejury:
# pas d'autre colonnes de résultats
continue
# Bonus (sport) dans cette UE ?
# Le bonus sport appliqué sur cette UE
if (self.bonus_ues is not None) and (ue.id in self.bonus_ues):
val = self.bonus_ues[ue.id][etud.id] or ""
val_fmt = fmt_note(val)
val_fmt = val_fmt_html = fmt_note(val)
if val:
val_fmt = f'<span class="green-arrow-up"></span><span class="sp2l">{val_fmt}</span>'
val_fmt_html = f'<span class="green-arrow-up"></span><span class="sp2l">{val_fmt}</span>'
idx = add_cell(
row,
f"bonus_ue_{ue.id}",
f"Bonus {ue.acronyme}",
val_fmt,
val_fmt_html,
"col_ue_bonus",
idx,
)
row[f"_bonus_ue_{ue.id}_xls"] = val_fmt
# Les moyennes des modules (ou ressources et SAÉs) dans cette UE
idx_malus = idx # place pour colonne malus à gauche des modules
idx += 1
for modimpl in self.modimpls_in_ue(ue.id, etudid, with_bonus=False):
if ue_status["is_capitalized"]:
val = "-c-"
@ -573,63 +587,87 @@ class ResultatsSemestre(ResultatsCache):
col_id = (
f"moy_{modimpl.module.type_abbrv()}_{modimpl.id}_{ue.id}"
)
val_fmt = fmt_note(val)
val_fmt = val_fmt_html = fmt_note(val)
if modimpl.module.module_type == scu.ModuleType.MALUS:
val_fmt = (
val_fmt_html = (
(scu.EMO_RED_TRIANGLE_DOWN + val_fmt) if val else ""
)
idx = add_cell(
row,
col_id,
modimpl.module.code,
val_fmt,
val_fmt_html,
# class col_res mod_ue_123
f"col_{modimpl.module.type_abbrv()} mod_ue_{ue.id}",
idx,
)
row[f"_{col_id}_xls"] = val_fmt
if modimpl.module.module_type == scu.ModuleType.MALUS:
titles[f"_{col_id}_col_order"] = idx_malus
titles_bot[f"_{col_id}_target"] = url_for(
"notes.moduleimpl_status",
scodoc_dept=g.scodoc_dept,
moduleimpl_id=modimpl.id,
)
nom_resp = dict_nom_res.get(modimpl.responsable_id)
if nom_resp is None:
user = User.query.get(modimpl.responsable_id)
nom_resp = user.get_nomcomplet() if user else ""
dict_nom_res[modimpl.responsable_id] = nom_resp
titles_bot[
f"_{col_id}_target_attrs"
] = f"""
title="{modimpl.module.titre}
({sco_users.user_info(modimpl.responsable_id)['nomcomplet']})" """
] = f""" title="{modimpl.module.titre} ({nom_resp})" """
modimpl_ids.add(modimpl.id)
ue_valid_txt = f"{nb_ues_validables}/{len(ues_sans_bonus)}"
ue_valid_txt = (
ue_valid_txt_html
) = f"{nb_ues_validables}/{len(ues_sans_bonus)}"
if nb_ues_warning:
ue_valid_txt += " " + scu.EMO_WARNING
ue_valid_txt_html += " " + scu.EMO_WARNING
add_cell(
row,
"ues_validables",
"UEs",
ue_valid_txt,
ue_valid_txt_html,
"col_ue col_ues_validables",
29, # juste avant moy. gen.
)
row["_ues_validables_xls"] = ue_valid_txt
if nb_ues_warning:
row["_ues_validables_class"] += " moy_ue_warning"
elif nb_ues_validables < len(ues_sans_bonus):
row["_ues_validables_class"] += " moy_inf"
row["_ues_validables_order"] = nb_ues_validables # pour tri
if modejury:
idx = add_cell(
row,
"jury_link",
"",
f"""<a href="{url_for('notes.formsemestre_validation_etud_form',
scodoc_dept=g.scodoc_dept, formsemestre_id=self.formsemestre.id, etudid=etudid
)
}">saisir décision</a>""",
"col_jury_link",
1000,
)
rows.append(row)
self._recap_add_partitions(rows, titles)
self._recap_add_admissions(rows, titles)
# tri par rang croissant
rows.sort(key=lambda e: e["_rang_order"])
# INFOS POUR FOOTER
bottom_infos = self._recap_bottom_infos(ues_sans_bonus, modimpl_ids, fmt_note)
if include_evaluations:
self._recap_add_evaluations(rows, titles, bottom_infos)
# Ajoute style "col_empty" aux colonnes de modules vides
for col_id in titles:
c_class = f"_{col_id}_class"
if "col_empty" in bottom_infos["moy"].get(c_class, ""):
for row in rows:
row[c_class] += " col_empty"
row[c_class] = row.get(c_class, "") + " col_empty"
titles[c_class] += " col_empty"
for row in bottom_infos.values():
row[c_class] = row.get(c_class, "") + " col_empty"
@ -641,7 +679,9 @@ class ResultatsSemestre(ResultatsCache):
row["moy_gen"] = row.get("moy_gen", "")
row["_moy_gen_class"] = "col_moy_gen"
# titre de la ligne:
row["prenom"] = row["nom_short"] = bottom_line.capitalize()
row["prenom"] = row["nom_short"] = (
row.get("_title", "") or bottom_line.capitalize()
)
row["_tr_class"] = bottom_line.lower() + (
(" " + row["_tr_class"]) if "_tr_class" in row else ""
)
@ -656,53 +696,58 @@ class ResultatsSemestre(ResultatsCache):
def _recap_bottom_infos(self, ues, modimpl_ids: set, fmt_note) -> dict:
"""Les informations à mettre en bas de la table: min, max, moy, ECTS"""
row_min, row_max, row_moy, row_coef, row_ects = (
{"_tr_class": "bottom_info"},
row_min, row_max, row_moy, row_coef, row_ects, row_apo = (
{"_tr_class": "bottom_info", "_title": "Min."},
{"_tr_class": "bottom_info"},
{"_tr_class": "bottom_info"},
{"_tr_class": "bottom_info"},
{"_tr_class": "bottom_info"},
{"_tr_class": "bottom_info", "_title": "Code Apogée"},
)
# --- ECTS
for ue in ues:
row_ects[f"moy_ue_{ue.id}"] = ue.ects
row_ects[f"_moy_ue_{ue.id}_class"] = "col_ue"
colid = f"moy_ue_{ue.id}"
row_ects[colid] = ue.ects
row_ects[f"_{colid}_class"] = "col_ue"
# style cases vides pour borders verticales
row_coef[f"moy_ue_{ue.id}"] = ""
row_coef[f"_moy_ue_{ue.id}_class"] = "col_ue"
row_coef[colid] = ""
row_coef[f"_{colid}_class"] = "col_ue"
# row_apo[colid] = ue.code_apogee or ""
row_ects["moy_gen"] = sum([ue.ects or 0 for ue in ues if ue.type != UE_SPORT])
row_ects["_moy_gen_class"] = "col_moy_gen"
# --- MIN, MAX, MOY
# --- MIN, MAX, MOY, APO
row_min["moy_gen"] = fmt_note(self.etud_moy_gen.min())
row_max["moy_gen"] = fmt_note(self.etud_moy_gen.max())
row_moy["moy_gen"] = fmt_note(self.etud_moy_gen.mean())
for ue in ues:
col_id = f"moy_ue_{ue.id}"
row_min[col_id] = fmt_note(self.etud_moy_ue[ue.id].min())
row_max[col_id] = fmt_note(self.etud_moy_ue[ue.id].max())
row_moy[col_id] = fmt_note(self.etud_moy_ue[ue.id].mean())
row_min[f"_{col_id}_class"] = "col_ue"
row_max[f"_{col_id}_class"] = "col_ue"
row_moy[f"_{col_id}_class"] = "col_ue"
colid = f"moy_ue_{ue.id}"
row_min[colid] = fmt_note(self.etud_moy_ue[ue.id].min())
row_max[colid] = fmt_note(self.etud_moy_ue[ue.id].max())
row_moy[colid] = fmt_note(self.etud_moy_ue[ue.id].mean())
row_min[f"_{colid}_class"] = "col_ue"
row_max[f"_{colid}_class"] = "col_ue"
row_moy[f"_{colid}_class"] = "col_ue"
row_apo[colid] = ue.code_apogee or ""
for modimpl in self.formsemestre.modimpls_sorted:
if modimpl.id in modimpl_ids:
col_id = f"moy_{modimpl.module.type_abbrv()}_{modimpl.id}_{ue.id}"
colid = f"moy_{modimpl.module.type_abbrv()}_{modimpl.id}_{ue.id}"
if self.is_apc:
coef = self.modimpl_coefs_df[modimpl.id][ue.id]
else:
coef = modimpl.module.coefficient or 0
row_coef[col_id] = fmt_note(coef)
row_coef[colid] = fmt_note(coef)
notes = self.modimpl_notes(modimpl.id, ue.id)
row_min[col_id] = fmt_note(np.nanmin(notes))
row_max[col_id] = fmt_note(np.nanmax(notes))
row_min[colid] = fmt_note(np.nanmin(notes))
row_max[colid] = fmt_note(np.nanmax(notes))
moy = np.nanmean(notes)
row_moy[col_id] = fmt_note(moy)
row_moy[colid] = fmt_note(moy)
if np.isnan(moy):
# aucune note dans ce module
row_moy[f"_{col_id}_class"] = "col_empty"
row_moy[f"_{colid}_class"] = "col_empty"
row_apo[colid] = modimpl.module.code_apogee or ""
return { # { key : row } avec key = min, max, moy, coef
"min": row_min,
@ -710,6 +755,7 @@ class ResultatsSemestre(ResultatsCache):
"moy": row_moy,
"coef": row_coef,
"ects": row_ects,
"apo": row_apo,
}
def _recap_etud_groups_infos(self, etudid: int, row: dict, titles: dict):
@ -803,3 +849,68 @@ class ResultatsSemestre(ResultatsCache):
row[f"{cid}"] = gr_name
row[f"_{cid}_class"] = klass
first_partition = False
def _recap_add_evaluations(
self, rows: list[dict], titles: dict, bottom_infos: dict
):
"""Ajoute les colonnes avec les notes aux évaluations
rows est une liste de dict avec une clé "etudid"
Les colonnes ont la classe css "evaluation"
"""
# nouvelle ligne pour description évaluations:
bottom_infos["descr_evaluation"] = {
"_tr_class": "bottom_info",
"_title": "Description évaluation",
}
first_eval = True
index_col = 9000 # à droite
for modimpl in self.formsemestre.modimpls_sorted:
evals = self.modimpls_results[modimpl.id].get_evaluations_completes(modimpl)
eval_index = len(evals) - 1
inscrits = {i.etudid for i in modimpl.inscriptions}
first_eval_of_mod = True
for e in evals:
cid = f"eval_{e.id}"
titles[
cid
] = f'{modimpl.module.code} {eval_index} {e.jour.isoformat() if e.jour else ""}'
klass = "evaluation"
if first_eval:
klass += " first"
elif first_eval_of_mod:
klass += " first_of_mod"
titles[f"_{cid}_class"] = klass
first_eval_of_mod = first_eval = False
titles[f"_{cid}_col_order"] = index_col
index_col += 1
eval_index -= 1
notes_db = sco_evaluation_db.do_evaluation_get_all_notes(
e.evaluation_id
)
for row in rows:
etudid = row["etudid"]
if etudid in inscrits:
if etudid in notes_db:
val = notes_db[etudid]["value"]
else:
# Note manquante mais prise en compte immédiate: affiche ATT
val = scu.NOTES_ATTENTE
row[cid] = scu.fmt_note(val)
row[f"_{cid}_class"] = klass + {
"ABS": " abs",
"ATT": " att",
"EXC": " exc",
}.get(row[cid], "")
else:
row[cid] = "ni"
row[f"_{cid}_class"] = klass + " non_inscrit"
bottom_infos["coef"][cid] = e.coefficient
bottom_infos["min"][cid] = "0"
bottom_infos["max"][cid] = scu.fmt_note(e.note_max)
bottom_infos["descr_evaluation"][cid] = e.description or ""
bottom_infos["descr_evaluation"][f"_{cid}_target"] = url_for(
"notes.evaluation_listenotes",
scodoc_dept=g.scodoc_dept,
evaluation_id=e.id,
)

View File

@ -70,5 +70,16 @@ class CodesDecisionsForm(FlaskForm):
DEM = _build_code_field("DEM")
NAR = _build_code_field("NAR")
RAT = _build_code_field("RAT")
NOTES_FMT = StringField(
label="Format notes exportées",
description="""Format des notes. Par défaut <tt style="font-family: monotype;">%3.2f</tt> (deux chiffres après la virgule)""",
validators=[
validators.Length(
max=SHORT_STR_LEN,
message=f"Le format ne doit pas dépasser {SHORT_STR_LEN} caractères",
),
validators.DataRequired("format requis"),
],
)
submit = SubmitField("Valider")
cancel = SubmitField("Annuler", render_kw={"formnovalidate": True})

View File

@ -36,6 +36,7 @@ CODES_SCODOC_TO_APO = {
DEM: "NAR",
NAR: "NAR",
RAT: "ATT",
"NOTES_FMT": "%3.2f",
}
@ -157,32 +158,6 @@ class ScoDocSiteConfig(db.Model):
class_list.sort(key=lambda x: x[1].replace(" du ", " de "))
return [("", "")] + class_list
@classmethod
def get_bonus_sport_func(cls):
"""Fonction bonus_sport ScoDoc 7 XXX
Transitoire pour les tests durant la transition #sco92
"""
"""returns bonus func with specified name.
If name not specified, return the configured function.
None if no bonus function configured.
Raises ScoValueError if func_name not found in module bonus_sport.
"""
from app.scodoc import bonus_sport
c = ScoDocSiteConfig.query.filter_by(name=cls.BONUS_SPORT).first()
if c is None:
return None
func_name = c.value
if func_name == "": # pas de bonus défini
return None
try:
return getattr(bonus_sport, func_name)
except AttributeError:
raise ScoValueError(
f"""Fonction de calcul de l'UE bonus inexistante: "{func_name}".
(contacter votre administrateur local)."""
)
@classmethod
def get_code_apo(cls, code: str) -> str:
"""La représentation d'un code pour les exports Apogée.

View File

@ -16,6 +16,7 @@ from app import models
from app.scodoc import notesdb as ndb
from app.scodoc.sco_bac import Baccalaureat
from app.scodoc.sco_exceptions import ScoValueError
import app.scodoc.sco_utils as scu
@ -354,7 +355,10 @@ def make_etud_args(
"""
args = None
if etudid:
args = {"etudid": etudid}
try:
args = {"etudid": int(etudid)}
except ValueError as exc:
raise ScoValueError("Adresse invalide") from exc
elif code_nip:
args = {"code_nip": code_nip}
elif use_request: # use form from current request (Flask global)

View File

@ -74,6 +74,10 @@ class GroupDescr(db.Model):
f"""<{self.__class__.__name__} {self.id} "{self.group_name or '(tous)'}">"""
)
def get_nom_with_part(self) -> str:
"Nom avec partition: 'TD A'"
return f"{self.partition.partition_name or ''} {self.group_name or '-'}"
group_membership = db.Table(
"group_membership",

View File

@ -9,7 +9,6 @@ from app.comp import df_cache
from app.models.etudiants import Identite
from app.models.modules import Module
import app.scodoc.notesdb as ndb
from app.scodoc import sco_utils as scu

View File

@ -209,7 +209,8 @@ class GenTable(object):
omit_hidden_lines=False,
pdf_mode=False, # apply special pdf reportlab processing
pdf_style_list=[], # modified: list of platypus table style commands
):
xls_mode=False, # get xls content if available
) -> list:
"table data as a list of lists (rows)"
T = []
line_num = 0 # line number in input data
@ -237,9 +238,14 @@ class GenTable(object):
# if colspan_count > 0:
# continue # skip cells after a span
if pdf_mode:
content = row.get(f"_{cid}_pdf", "") or row.get(cid, "") or ""
content = row.get(f"_{cid}_pdf", False) or row.get(cid, "")
elif xls_mode:
content = row.get(f"_{cid}_xls", False) or row.get(cid, "")
else:
content = row.get(cid, "") or "" # nota: None converted to ''
content = row.get(cid, "")
# Convert None to empty string ""
content = "" if content is None else content
colspan = row.get("_%s_colspan" % cid, 0)
if colspan > 1:
pdf_style_list.append(
@ -299,7 +305,7 @@ class GenTable(object):
return self.xml()
elif format == "json":
return self.json()
raise ValueError("GenTable: invalid format: %s" % format)
raise ValueError(f"GenTable: invalid format: {format}")
def _gen_html_row(self, row, line_num=0, elem="td", css_classes=""):
"row is a dict, returns a string <tr...>...</tr>"
@ -479,23 +485,23 @@ class GenTable(object):
def excel(self, wb=None):
"""Simple Excel representation of the table"""
if wb is None:
ses = sco_excel.ScoExcelSheet(sheet_name=self.xls_sheet_name, wb=wb)
sheet = sco_excel.ScoExcelSheet(sheet_name=self.xls_sheet_name, wb=wb)
else:
ses = wb.create_sheet(sheet_name=self.xls_sheet_name)
ses.rows += self.xls_before_table
sheet = wb.create_sheet(sheet_name=self.xls_sheet_name)
sheet.rows += self.xls_before_table
style_bold = sco_excel.excel_make_style(bold=True)
style_base = sco_excel.excel_make_style()
ses.append_row(ses.make_row(self.get_titles_list(), style_bold))
for line in self.get_data_list():
ses.append_row(ses.make_row(line, style_base))
sheet.append_row(sheet.make_row(self.get_titles_list(), style_bold))
for line in self.get_data_list(xls_mode=True):
sheet.append_row(sheet.make_row(line, style_base))
if self.caption:
ses.append_blank_row() # empty line
ses.append_single_cell_row(self.caption, style_base)
sheet.append_blank_row() # empty line
sheet.append_single_cell_row(self.caption, style_base)
if self.origin:
ses.append_blank_row() # empty line
ses.append_single_cell_row(self.origin, style_base)
sheet.append_blank_row() # empty line
sheet.append_single_cell_row(self.origin, style_base)
if wb is None:
return ses.generate()
return sheet.generate()
def text(self):
"raw text representation of the table"

View File

@ -88,7 +88,7 @@ def sidebar():
<div class="box-chercheetud">Chercher étudiant:<br/>
<form method="get" id="form-chercheetud"
action="{url_for('scolar.search_etud_in_dept', scodoc_dept=g.scodoc_dept) }">
<div><input type="text" size="12" id="in-expnom" name="expnom" spellcheck="false"></input></div>
<div><input type="text" size="12" class="in-expnom" name="expnom" spellcheck="false"></input></div>
</form></div>
<div class="etud-insidebar">
"""

View File

@ -31,9 +31,7 @@
import calendar
import datetime
import html
import string
import time
import types
from app.scodoc import notesdb as ndb
from app import log
@ -42,9 +40,9 @@ from app.scodoc.sco_exceptions import ScoValueError, ScoInvalidDateError
from app.scodoc import sco_abs_notification
from app.scodoc import sco_cache
from app.scodoc import sco_etud
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_preferences
import app.scodoc.sco_utils as scu
# --- Misc tools.... ------------------
@ -247,9 +245,9 @@ def day_names():
If work_saturday property is set, include saturday
"""
if is_work_saturday():
return ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"]
return scu.DAY_NAMES[:-1]
else:
return ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi"]
return scu.DAY_NAMES[:-2]
def next_iso_day(date):

View File

@ -83,6 +83,7 @@ XXX A vérifier:
import collections
import datetime
from functools import reduce
import functools
import io
import os
import pprint
@ -125,7 +126,7 @@ APO_SEP = "\t"
APO_NEWLINE = "\r\n"
def _apo_fmt_note(note):
def _apo_fmt_note(note, fmt="%3.2f"):
"Formatte une note pour Apogée (séparateur décimal: ',')"
# if not note and isinstance(note, float): changé le 31/1/2022, étrange ?
# return ""
@ -133,7 +134,7 @@ def _apo_fmt_note(note):
val = float(note)
except ValueError:
return ""
return ("%3.2f" % val).replace(".", APO_DECIMAL_SEP)
return (fmt % val).replace(".", APO_DECIMAL_SEP)
def guess_data_encoding(text, threshold=0.6):
@ -270,6 +271,9 @@ class ApoEtud(dict):
self.export_res_modules = export_res_modules
self.export_res_sdj = export_res_sdj # export meme si pas de decision de jury
self.export_res_rat = export_res_rat
self.fmt_note = functools.partial(
_apo_fmt_note, fmt=ScoDocSiteConfig.get_code_apo("NOTES_FMT") or "3.2f"
)
def __repr__(self):
return "ApoEtud( nom='%s', nip='%s' )" % (self["nom"], self["nip"])
@ -423,7 +427,7 @@ class ApoEtud(dict):
ue_status = nt.get_etud_ue_status(etudid, ue["ue_id"])
code_decision_ue = decisions_ue[ue["ue_id"]]["code"]
return dict(
N=_apo_fmt_note(ue_status["moy"] if ue_status else ""),
N=self.fmt_note(ue_status["moy"] if ue_status else ""),
B=20,
J="",
R=ScoDocSiteConfig.get_code_apo(code_decision_ue),
@ -443,7 +447,7 @@ class ApoEtud(dict):
].split(","):
n = nt.get_etud_mod_moy(modimpl["moduleimpl_id"], etudid)
if n != "NI" and self.export_res_modules:
return dict(N=_apo_fmt_note(n), B=20, J="", R="")
return dict(N=self.fmt_note(n), B=20, J="", R="")
else:
module_code_found = True
if module_code_found:
@ -465,7 +469,7 @@ class ApoEtud(dict):
if decision_apo == "DEF" or decision["code"] == DEM or decision["code"] == DEF:
note_str = "0,01" # note non nulle pour les démissionnaires
else:
note_str = _apo_fmt_note(note)
note_str = self.fmt_note(note)
return dict(N=note_str, B=20, J="", R=decision_apo, M="")
def comp_elt_annuel(self, etudid, cur_sem, autre_sem):
@ -531,7 +535,7 @@ class ApoEtud(dict):
moy_annuelle = (note + autre_note) / 2
except TypeError:
moy_annuelle = ""
note_str = _apo_fmt_note(moy_annuelle)
note_str = self.fmt_note(moy_annuelle)
if code_semestre_validant(autre_decision["code"]):
decision_apo_annuelle = decision_apo

View File

@ -47,14 +47,15 @@
qui est une description (humaine, format libre) de l'archive.
"""
import chardet
import datetime
import glob
import json
import mimetypes
import os
import re
import shutil
import time
import chardet
import flask
from flask import g, request
@ -63,7 +64,9 @@ from flask_login import current_user
import app.scodoc.sco_utils as scu
from config import Config
from app import log
from app.models import Departement
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import Departement, FormSemestre
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc.sco_exceptions import (
AccessDenied,
@ -95,8 +98,8 @@ class BaseArchiver(object):
self.root = os.path.join(*dirs)
log("initialized archiver, path=" + self.root)
path = dirs[0]
for dir in dirs[1:]:
path = os.path.join(path, dir)
for directory in dirs[1:]:
path = os.path.join(path, directory)
try:
scu.GSL.acquire()
if not os.path.isdir(path):
@ -117,11 +120,11 @@ class BaseArchiver(object):
try:
scu.GSL.acquire()
if not os.path.isdir(dept_dir):
log("creating directory %s" % dept_dir)
log(f"creating directory {dept_dir}")
os.mkdir(dept_dir)
obj_dir = os.path.join(dept_dir, str(oid))
if not os.path.isdir(obj_dir):
log("creating directory %s" % obj_dir)
log(f"creating directory {obj_dir}")
os.mkdir(obj_dir)
finally:
scu.GSL.release()
@ -163,8 +166,9 @@ class BaseArchiver(object):
def get_archive_date(self, archive_id):
"""Returns date (as a DateTime object) of an archive"""
dt = [int(x) for x in os.path.split(archive_id)[1].split("-")]
return datetime.datetime(*dt)
return datetime.datetime(
*[int(x) for x in os.path.split(archive_id)[1].split("-")]
)
def list_archive(self, archive_id: str) -> str:
"""Return list of filenames (without path) in archive"""
@ -195,8 +199,7 @@ class BaseArchiver(object):
archive_id = os.path.join(self.get_obj_dir(oid), archive_name)
if not os.path.isdir(archive_id):
log(
"invalid archive name: %s, oid=%s, archive_id=%s"
% (archive_name, oid, archive_id)
f"invalid archive name: {archive_name}, oid={oid}, archive_id={archive_id}"
)
raise ValueError("invalid archive name")
return archive_id
@ -223,7 +226,7 @@ class BaseArchiver(object):
+ os.path.sep
+ "-".join(["%02d" % x for x in time.localtime()[:6]])
)
log("creating archive: %s" % archive_id)
log(f"creating archive: {archive_id}")
try:
scu.GSL.acquire()
os.mkdir(archive_id) # if exists, raises an OSError
@ -302,9 +305,14 @@ def do_formsemestre_archive(
Store:
- tableau recap (xls), pv jury (xls et pdf), bulletins (xml et pdf), lettres individuelles (pdf)
"""
from app.scodoc.sco_recapcomplet import make_formsemestre_recapcomplet
from app.scodoc.sco_recapcomplet import (
gen_formsemestre_recapcomplet_excel,
gen_formsemestre_recapcomplet_html,
gen_formsemestre_recapcomplet_json,
)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
sem_archive_id = formsemestre_id
archive_id = PVArchive.create_obj_archive(sem_archive_id, description)
date = PVArchive.get_archive_date(archive_id).strftime("%d/%m/%Y à %H:%M")
@ -319,37 +327,38 @@ def do_formsemestre_archive(
etudids = [m["etudid"] for m in groups_infos.members]
# Tableau recap notes en XLS (pour tous les etudiants, n'utilise pas les groupes)
data, _, _ = make_formsemestre_recapcomplet(formsemestre_id, format="xls")
data, _ = gen_formsemestre_recapcomplet_excel(
formsemestre, res, include_evaluations=True, format="xls"
)
if data:
PVArchive.store(archive_id, "Tableau_moyennes" + scu.XLSX_SUFFIX, data)
# Tableau recap notes en HTML (pour tous les etudiants, n'utilise pas les groupes)
data, _, _ = make_formsemestre_recapcomplet(
formsemestre_id, format="html", disable_etudlink=True
table_html = gen_formsemestre_recapcomplet_html(
formsemestre, res, include_evaluations=True
)
if data:
if table_html:
data = "\n".join(
[
html_sco_header.sco_header(
page_title="Moyennes archivées le %s" % date,
head_message="Moyennes archivées le %s" % date,
page_title=f"Moyennes archivées le {date}",
head_message=f"Moyennes archivées le {date}",
no_side_bar=True,
),
'<h2 class="fontorange">Valeurs archivées le %s</h2>' % date,
f'<h2 class="fontorange">Valeurs archivées le {date}</h2>',
'<style type="text/css">table.notes_recapcomplet tr { color: rgb(185,70,0); }</style>',
data,
table_html,
html_sco_header.sco_footer(),
]
)
data = data.encode(scu.SCO_ENCODING)
PVArchive.store(archive_id, "Tableau_moyennes.html", data)
# Bulletins en XML (pour tous les etudiants, n'utilise pas les groupes)
data, _, _ = make_formsemestre_recapcomplet(
formsemestre_id, format="xml", xml_with_decisions=True
)
# Bulletins en JSON
data = gen_formsemestre_recapcomplet_json(formsemestre_id, xml_with_decisions=True)
data_js = json.dumps(data, indent=1, cls=scu.ScoDocJSONEncoder)
data_js = data_js.encode(scu.SCO_ENCODING)
if data:
data = data.encode(scu.SCO_ENCODING)
PVArchive.store(archive_id, "Bulletins.xml", data)
PVArchive.store(archive_id, "Bulletins.json", data_js)
# Decisions de jury, en XLS
data = sco_pvjury.formsemestre_pvjury(formsemestre_id, format="xls", publish=False)
if data:

View File

@ -49,7 +49,6 @@
# sco_cache.EvaluationCache.get(evaluation_id), set(evaluation_id, value), delete(evaluation_id),
#
import time
import traceback
from flask import g
@ -198,6 +197,26 @@ class SemInscriptionsCache(ScoDocCache):
duration = 12 * 60 * 60 # ttl 12h
class TableRecapCache(ScoDocCache):
"""Cache table recap (pour get_table_recap)
Clé: formsemestre_id
Valeur: le html (<div class="table_recap">...</div>)
"""
prefix = "RECAP"
duration = 12 * 60 * 60 # ttl 12h
class TableRecapWithEvalsCache(ScoDocCache):
"""Cache table recap (pour get_table_recap)
Clé: formsemestre_id
Valeur: le html (<div class="table_recap">...</div>)
"""
prefix = "RECAPWITHEVALS"
duration = 12 * 60 * 60 # ttl 12h
def invalidate_formsemestre( # was inval_cache(formsemestre_id=None, pdfonly=False)
formsemestre_id=None, pdfonly=False
):
@ -209,7 +228,7 @@ def invalidate_formsemestre( # was inval_cache(formsemestre_id=None, pdfonly=Fa
if getattr(g, "defer_cache_invalidation", False):
g.sem_to_invalidate.add(formsemestre_id)
return
log("inval_cache, formsemestre_id=%s pdfonly=%s" % (formsemestre_id, pdfonly))
log("inval_cache, formsemestre_id={formsemestre_id} pdfonly={pdfonly}")
if formsemestre_id is None:
# clear all caches
log("----- invalidate_formsemestre: clearing all caches -----")
@ -247,6 +266,9 @@ def invalidate_formsemestre( # was inval_cache(formsemestre_id=None, pdfonly=Fa
SemInscriptionsCache.delete_many(formsemestre_ids)
ResultatsSemestreCache.delete_many(formsemestre_ids)
ValidationsSemestreCache.delete_many(formsemestre_ids)
TableRecapCache.delete_many(formsemestre_ids)
TableRecapWithEvalsCache.delete_many(formsemestre_ids)
SemBulletinsPDFCache.invalidate_sems(formsemestre_ids)

View File

@ -25,7 +25,7 @@
#
##############################################################################
"""Vérification des abasneces à une évaluation
"""Vérification des absences à une évaluation
"""
from flask import url_for, g

View File

@ -0,0 +1,144 @@
##############################################################################
# ScoDoc
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
# See LICENSE
##############################################################################
"""Tableau recap. de toutes les évaluations d'un semestre
avec leur état.
Sur une idée de Pascal Bouron, de Lyon.
"""
import time
from flask import g, url_for
from app.models import Evaluation, FormSemestre
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.comp.moy_mod import ModuleImplResults
from app.scodoc import html_sco_header
import app.scodoc.sco_utils as scu
def evaluations_recap(formsemestre_id: int) -> str:
"""Page récap. de toutes les évaluations d'un semestre"""
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
rows, titles = evaluations_recap_table(formsemestre)
column_ids = titles.keys()
filename = scu.sanitize_filename(
f"""evaluations-{formsemestre.titre_num()}-{time.strftime("%Y-%m-%d")}"""
)
if not rows:
return '<div class="evaluations_recap"><div class="message">aucune évaluation</div></div>'
H = [
html_sco_header.sco_header(
page_title="Évaluations du semestre",
javascripts=["js/evaluations_recap.js"],
),
f"""<div class="evaluations_recap"><table class="evaluations_recap compact {
'apc' if formsemestre.formation.is_apc() else 'classic'
}"
data-filename="{filename}">""",
]
# header
H.append(
f"""
<thead>
{scu.gen_row(column_ids, titles, "th", with_col_classes=True)}
</thead>
"""
)
# body
H.append("<tbody>")
for row in rows:
H.append(f"{scu.gen_row(column_ids, row, with_col_classes=True)}\n")
H.append("""</tbody></table></div>""")
H.append(
html_sco_header.sco_footer(),
)
return "".join(H)
def evaluations_recap_table(formsemestre: FormSemestre) -> list[dict]:
"""Tableau recap. de toutes les évaluations d'un semestre
Colonnes:
- code (UE ou module),
- titre
- complete
- publiée
- inscrits (non dem. ni def.)
- nb notes manquantes
- nb ATT
- nb ABS
- nb EXC
"""
rows = []
titles = {
"type": "",
"code": "Code",
"titre": "",
"date": "Date",
"complete": "Comptée",
"inscrits": "Inscrits",
"manquantes": "Manquantes", # notes eval non entrées
"nb_abs": "ABS",
"nb_att": "ATT",
"nb_exc": "EXC",
}
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
line_idx = 0
for modimpl in nt.formsemestre.modimpls_sorted:
modimpl_results: ModuleImplResults = nt.modimpls_results[modimpl.id]
row = {
"type": modimpl.module.type_abbrv().upper(),
"_type_order": f"{line_idx:04d}",
"code": modimpl.module.code,
"_code_target": url_for(
"notes.moduleimpl_status",
scodoc_dept=g.scodoc_dept,
moduleimpl_id=modimpl.id,
),
"titre": modimpl.module.titre,
"_titre_class": "titre",
"inscrits": modimpl_results.nb_inscrits_module,
"date": "-",
"_date_order": "",
"_tr_class": f"module {modimpl.module.type_abbrv()}",
}
rows.append(row)
line_idx += 1
for evaluation_id in modimpl_results.evals_notes:
e = Evaluation.query.get(evaluation_id)
eval_etat = modimpl_results.evaluations_etat[evaluation_id]
row = {
"type": "",
"_type_order": f"{line_idx:04d}",
"titre": e.description or "sans titre",
"_titre_target": url_for(
"notes.evaluation_listenotes",
scodoc_dept=g.scodoc_dept,
evaluation_id=evaluation_id,
),
"_titre_target_attrs": 'class="discretelink"',
"date": e.jour.strftime("%d/%m/%Y") if e.jour else "",
"_date_order": e.jour.isoformat() if e.jour else "",
"complete": "oui" if eval_etat.is_complete else "non",
"_complete_target": "#",
"_complete_target_attrs": 'class="bull_link" title="prise en compte dans les moyennes"'
if eval_etat.is_complete
else 'class="bull_link incomplete" title="il manque des notes"',
"manquantes": len(modimpl_results.evals_etudids_sans_note[e.id]),
"inscrits": modimpl_results.nb_inscrits_module,
"nb_abs": sum(modimpl_results.evals_notes[e.id] == scu.NOTES_ABSENCE),
"nb_att": eval_etat.nb_attente,
"nb_exc": sum(
modimpl_results.evals_notes[e.id] == scu.NOTES_NEUTRALISE
),
"_tr_class": "evaluation"
+ (" incomplete" if not eval_etat.is_complete else ""),
}
rows.append(row)
line_idx += 1
return rows, titles

View File

@ -185,13 +185,13 @@ def excel_make_style(
class ScoExcelSheet:
"""Représente une feuille qui peut être indépendante ou intégrée dans un SCoExcelBook.
"""Représente une feuille qui peut être indépendante ou intégrée dans un ScoExcelBook.
En application des directives de la bibliothèque sur l'écriture optimisée, l'ordre des opérations
est imposé:
* instructions globales (largeur/maquage des colonnes et ligne, ...)
* construction et ajout des cellules et ligne selon le sens de lecture (occidental)
ligne de haut en bas et cellules de gauche à droite (i.e. A1, A2, .. B1, B2, ..)
* pour finit appel de la méthode de génération
* pour finir appel de la méthode de génération
"""
def __init__(self, sheet_name="feuille", default_style=None, wb=None):
@ -260,7 +260,7 @@ class ScoExcelSheet:
for i, val in enumerate(value):
self.ws.column_dimensions[self.i2col(i)].width = val
# No keys: value is a list of widths
elif type(cle) == str: # accepts set_column_with("D", ...)
elif isinstance(cle, str): # accepts set_column_with("D", ...)
self.ws.column_dimensions[cle].width = value
else:
self.ws.column_dimensions[self.i2col(cle)].width = value
@ -337,7 +337,8 @@ class ScoExcelSheet:
return cell
def make_row(self, values: list, style=None, comments=None):
def make_row(self, values: list, style=None, comments=None) -> list:
"build a row"
# TODO make possible differents styles in a row
if comments is None:
comments = [None] * len(values)

View File

@ -53,12 +53,10 @@ def form_search_etud(
):
"form recherche par nom"
H = []
if title:
H.append("<h2>%s</h2>" % title)
H.append(
f"""<form action="{ url_for("scolar.search_etud_in_dept", scodoc_dept=g.scodoc_dept) }" method="POST">
<b>{title}</b>
<input type="text" name="expnom" width="12" spellcheck="false" value="">
<input type="text" name="expnom" class="in-expnom" width="12" spellcheck="false" value="">
<input type="submit" value="Chercher">
<br/>(entrer une partie du nom)
"""

View File

@ -1314,7 +1314,7 @@ def _reassociate_moduleimpls(cnx, formsemestre_id, ues_old2new, modules_old2new)
def formsemestre_delete(formsemestre_id):
"""Delete a formsemestre (affiche avertissements)"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id, raise_soft_exc=True)
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
H = [
html_sco_header.html_sem_header("Suppression du semestre"),

View File

@ -357,6 +357,11 @@ def formsemestre_status_menubar(sem):
"endpoint": "notes.formsemestre_recapcomplet",
"args": {"formsemestre_id": formsemestre_id},
},
{
"title": "État des évaluations",
"endpoint": "notes.evaluations_recap",
"args": {"formsemestre_id": formsemestre_id},
},
{
"title": "Saisie des notes",
"endpoint": "notes.formsemestre_status",
@ -404,9 +409,6 @@ def formsemestre_status_menubar(sem):
"args": {
"formsemestre_id": formsemestre_id,
"modejury": 1,
"hidemodules": 1,
"hidebac": 1,
"pref_override": 0,
},
"enabled": sco_permissions_check.can_validate_sem(formsemestre_id),
},
@ -764,22 +766,29 @@ def _make_listes_sem(sem, with_absences=True):
if with_absences:
first_monday = sco_abs.ddmmyyyy(sem["date_debut"]).prev_monday()
form_abs_tmpl = f"""
<td><form action="{url_for(
<td>
<a href="%(url_etat)s">absences</a>
</td>
<td>
<form action="{url_for(
"absences.SignaleAbsenceGrSemestre", scodoc_dept=g.scodoc_dept
)}" method="get">
<input type="hidden" name="datefin" value="{sem['date_fin']}"/>
<input type="hidden" name="group_ids" value="%(group_id)s"/>
<input type="hidden" name="destination" value="{destination}"/>
<input type="submit" value="Saisir absences du" />
<input type="submit" value="Saisir abs des" />
<select name="datedebut" class="noprint">
"""
date = first_monday
for jour in sco_abs.day_names():
form_abs_tmpl += '<option value="%s">%s</option>' % (date, jour)
form_abs_tmpl += f'<option value="{date}">{jour}s</option>'
date = date.next_day()
form_abs_tmpl += """
form_abs_tmpl += f"""
</select>
<a href="%(url_etat)s">état</a>
<a href="{
url_for("absences.choix_semaine", scodoc_dept=g.scodoc_dept)
}?group_id=%(group_id)s">saisie par semaine</a>
</form></td>
"""
else:
@ -791,7 +800,7 @@ def _make_listes_sem(sem, with_absences=True):
# Genere liste pour chaque partition (categorie de groupes)
for partition in sco_groups.get_partitions_list(sem["formsemestre_id"]):
if not partition["partition_name"]:
H.append("<h4>Tous les étudiants</h4>" % partition)
H.append("<h4>Tous les étudiants</h4>")
else:
H.append("<h4>Groupes de %(partition_name)s</h4>" % partition)
groups = sco_groups.get_partition_groups(partition)
@ -821,20 +830,6 @@ def _make_listes_sem(sem, with_absences=True):
)
}">{group["label"]}</a>
</td><td>
(<a href="{
url_for("scolar.groups_view",
group_ids=group["group_id"],
format="xls",
scodoc_dept=g.scodoc_dept,
)
}">tableur</a>)
<a href="{
url_for("scolar.groups_view",
curtab="tab-photos",
group_ids=group["group_id"],
scodoc_dept=g.scodoc_dept,
)
}">Photos</a>
</td>
<td>({n_members} étudiants)</td>
"""
@ -1191,6 +1186,7 @@ def formsemestre_tableau_modules(
H.append("<td>")
if mod.module_type in (ModuleType.RESSOURCE, ModuleType.SAE):
coefs = mod.ue_coefs_list()
H.append(f'<a class="invisible_link" href="#" title="{mod_descr}">')
for coef in coefs:
if coef[1] > 0:
H.append(
@ -1202,6 +1198,7 @@ def formsemestre_tableau_modules(
)
else:
H.append(f"""<span class="mod_coef_indicator_zero"></span>""")
H.append("</a>")
H.append("</td>")
if mod.module_type in (
None, # ne devrait pas être nécessaire car la migration a remplacé les NULLs

View File

@ -31,6 +31,7 @@ import time
import flask
from flask import url_for, g, request
from app.models.etudiants import Identite
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
@ -107,29 +108,57 @@ def formsemestre_validation_etud_form(
if not Se.sem["etat"]:
raise ScoValueError("validation: semestre verrouille")
url_tableau = url_for(
"notes.formsemestre_recapcomplet",
scodoc_dept=g.scodoc_dept,
modejury=1,
formsemestre_id=formsemestre_id,
selected_etudid=etudid, # va a la bonne ligne
)
H = [
html_sco_header.sco_header(
page_title="Parcours %(nomprenom)s" % etud,
page_title=f"Parcours {etud['nomprenom']}",
javascripts=["js/recap_parcours.js"],
)
]
Footer = ["<p>"]
# Navigation suivant/precedent
if etud_index_prev != None:
etud_p = sco_etud.get_etud_info(etudid=T[etud_index_prev][-1], filled=True)[0]
Footer.append(
'<span><a href="formsemestre_validation_etud_form?formsemestre_id=%s&etud_index=%s">Etud. précédent (%s)</a></span>'
% (formsemestre_id, etud_index_prev, etud_p["nomprenom"])
if etud_index_prev is not None:
etud_prev = Identite.query.get(T[etud_index_prev][-1])
url_prev = url_for(
"notes.formsemestre_validation_etud_form",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
etud_index=etud_index_prev,
)
if etud_index_next != None:
etud_n = sco_etud.get_etud_info(etudid=T[etud_index_next][-1], filled=True)[0]
Footer.append(
'<span style="padding-left: 50px;"><a href="formsemestre_validation_etud_form?formsemestre_id=%s&etud_index=%s">Etud. suivant (%s)</a></span>'
% (formsemestre_id, etud_index_next, etud_n["nomprenom"])
else:
url_prev = None
if etud_index_next is not None:
etud_next = Identite.query.get(T[etud_index_next][-1])
url_next = url_for(
"notes.formsemestre_validation_etud_form",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
etud_index=etud_index_next,
)
Footer.append("</p>")
Footer.append(html_sco_header.sco_footer())
else:
url_next = None
footer = ["""<div class="jury_footer"><span>"""]
if url_prev:
footer.append(
f'< <a class="stdlink" href="{url_prev}">{etud_prev.nomprenom}</a>'
)
footer.append(
f"""</span><span><a class="stdlink" href="{url_tableau}">retour à la liste</a></span><span>"""
)
if url_next:
footer.append(
f'<a class="stdlink" href="{url_next}">{etud_next.nomprenom}</a> >'
)
footer.append("</span></div>")
footer.append(html_sco_header.sco_footer())
H.append('<table style="width: 100%"><tr><td>')
if not check:
@ -171,7 +200,7 @@ def formsemestre_validation_etud_form(
"""
)
)
return "\n".join(H + Footer)
return "\n".join(H + footer)
H.append(
formsemestre_recap_parcours_table(
@ -180,21 +209,10 @@ def formsemestre_validation_etud_form(
)
if check:
if not desturl:
desturl = url_for(
"notes.formsemestre_recapcomplet",
scodoc_dept=g.scodoc_dept,
modejury=1,
hidemodules=1,
hidebac=1,
pref_override=0,
formsemestre_id=formsemestre_id,
sortcol=sortcol
or None, # pour refaire tri sorttable du tableau de notes
_anchor="etudid%s" % etudid, # va a la bonne ligne
)
desturl = url_tableau
H.append(f'<ul><li><a href="{desturl}">Continuer</a></li></ul>')
return "\n".join(H + Footer)
return "\n".join(H + footer)
decision_jury = Se.nt.get_etud_decision_sem(etudid)
@ -210,7 +228,7 @@ def formsemestre_validation_etud_form(
"""
)
)
return "\n".join(H + Footer)
return "\n".join(H + footer)
# Infos si pas de semestre précédent
if not Se.prev:
@ -348,7 +366,7 @@ def formsemestre_validation_etud_form(
else:
H.append("sans semestres décalés</p>")
return "".join(H + Footer)
return "".join(H + footer)
def formsemestre_validation_etud(
@ -437,14 +455,6 @@ def _redirect_valid_choice(formsemestre_id, etudid, Se, choice, desturl, sortcol
# sinon renvoie au listing general,
# if choice.new_code_prev:
# flask.redirect( 'formsemestre_validation_etud_form?formsemestre_id=%s&etudid=%s&check=1&desturl=%s' % (formsemestre_id, etudid, desturl) )
# else:
# if not desturl:
# desturl = 'formsemestre_recapcomplet?modejury=1&hidemodules=1&formsemestre_id=' + str(formsemestre_id)
# flask.redirect(desturl)
def _dispcode(c):
if not c:
return ""
@ -948,19 +958,23 @@ def do_formsemestre_validation_auto(formsemestre_id):
)
if conflicts:
H.append(
"""<p><b>Attention:</b> %d étudiants non modifiés car décisions différentes
déja saisies :<ul>"""
% len(conflicts)
f"""<p><b>Attention:</b> {len(conflicts)} étudiants non modifiés
car décisions différentes déja saisies :
<ul>"""
)
for etud in conflicts:
H.append(
'<li><a href="formsemestre_validation_etud_form?formsemestre_id=%s&etudid=%s&check=1">%s</li>'
% (formsemestre_id, etud["etudid"], etud["nomprenom"])
f"""<li><a href="{
url_for('notes.formsemestre_validation_etud_form',
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id,
etudid=etud["etudid"], check=1)
}">{etud["nomprenom"]}</li>"""
)
H.append("</ul>")
H.append(
'<a href="formsemestre_recapcomplet?formsemestre_id=%s&modejury=1&hidemodules=1&hidebac=1&pref_override=0">continuer</a>'
% formsemestre_id
f"""<a href="{url_for('notes.formsemestre_recapcomplet',
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id, modejury=1)
}">continuer</a>"""
)
H.append(html_sco_header.sco_footer())
return "\n".join(H)

View File

@ -575,9 +575,7 @@ def _make_table_notes(
html_sortable=True,
base_url=base_url,
filename=filename,
origin="Généré par %s le " % sco_version.SCONAME
+ scu.timedate_human_repr()
+ "",
origin=f"Généré par {sco_version.SCONAME} le {scu.timedate_human_repr()}",
caption=caption,
html_next_section=html_next_section,
page_title="Notes de " + sem["titremois"],
@ -674,6 +672,21 @@ def _add_eval_columns(
e_o = Evaluation.query.get(evaluation_id) # XXX en attendant ré-écriture
inscrits = e_o.moduleimpl.formsemestre.etudids_actifs # set d'etudids
notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id)
if len(e["jour"]) > 0:
titles[evaluation_id] = "%(description)s (%(jour)s)" % e
else:
titles[evaluation_id] = "%(description)s " % e
if e["eval_state"]["evalcomplete"]:
klass = "eval_complete"
elif e["eval_state"]["evalattente"]:
klass = "eval_attente"
else:
klass = "eval_incomplete"
titles[evaluation_id] += " (non prise en compte)"
titles[f"_{evaluation_id}_td_attrs"] = f'class="{klass}"'
for row in rows:
etudid = row["etudid"]
if etudid in notes_db:
@ -685,7 +698,7 @@ def _add_eval_columns(
# calcul moyenne SANS LES ABSENTS ni les DEMISSIONNAIRES
if (
(etudid in inscrits)
and val != None
and val is not None
and val != scu.NOTES_NEUTRALISE
and val != scu.NOTES_ATTENTE
):
@ -707,15 +720,27 @@ def _add_eval_columns(
sco_users.user_info(notes_db[etudid]["uid"])["nomcomplet"],
comment,
)
else:
if (etudid in inscrits) and e["publish_incomplete"]:
# Note manquante mais prise en compte immédiate: affiche ATT
val = scu.NOTES_ATTENTE
val_fmt = "ATT"
explanation = "non saisie mais prise en compte immédiate"
else:
explanation = ""
val_fmt = ""
val = None
cell_class = klass + {"ATT": " att", "ABS": " abs", "EXC": " exc"}.get(
val_fmt, ""
)
if val is None:
row["_" + str(evaluation_id) + "_td_attrs"] = 'class="etudabs" '
row[f"_{evaluation_id}_td_attrs"] = f'class="etudabs {cell_class}" '
if not row.get("_css_row_class", ""):
row["_css_row_class"] = "etudabs"
else:
row[f"_{evaluation_id}_td_attrs"] = f'class="{cell_class}" '
# regroupe les commentaires
if explanation:
if explanation in K:
@ -768,18 +793,6 @@ def _add_eval_columns(
else:
row_moys[evaluation_id] = ""
if len(e["jour"]) > 0:
titles[evaluation_id] = "%(description)s (%(jour)s)" % e
else:
titles[evaluation_id] = "%(description)s " % e
if e["eval_state"]["evalcomplete"]:
titles["_" + str(evaluation_id) + "_td_attrs"] = 'class="eval_complete"'
elif e["eval_state"]["evalattente"]:
titles["_" + str(evaluation_id) + "_td_attrs"] = 'class="eval_attente"'
else:
titles["_" + str(evaluation_id) + "_td_attrs"] = 'class="eval_incomplete"'
return notes, nb_abs, nb_att # pour histogramme

View File

@ -112,7 +112,6 @@ def scolar_news_summary(n=5):
"""Return last n news.
News are "compressed", ie redondant events are joined.
"""
from app.scodoc import sco_etud
from app.scodoc import sco_users
cnx = ndb.GetDBConnexion()
@ -152,12 +151,12 @@ def scolar_news_summary(n=5):
# date resumee
j, m = n["date"].split("/")[:2]
mois = scu.MONTH_NAMES_ABBREV[int(m) - 1]
n["formatted_date"] = "%s %s %s" % (j, mois, n["hm"])
n["formatted_date"] = f'{j} {mois} {n["hm"]}'
# indication semestre si ajout notes:
infos = _get_formsemestre_infos_from_news(n)
if infos:
n["text"] += (
' (<a href="Notes/formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(descr_sem)s</a>)'
' (<a class="stdlink" href="Notes/formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(descr_sem)s</a>)'
% infos
)
n["text"] += (
@ -179,7 +178,6 @@ def _get_formsemestre_infos_from_news(n):
mods = sco_moduleimpl.moduleimpl_list(moduleimpl_id=moduleimpl_id)
if not mods:
return {} # module does not exists anymore
return {} # pas d'indication du module
mod = mods[0]
formsemestre_id = mod["formsemestre_id"]
@ -188,12 +186,12 @@ def _get_formsemestre_infos_from_news(n):
try:
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
except:
except ValueError:
# semestre n'existe plus
return {}
if sem["semestre_id"] > 0:
descr_sem = "S%d" % sem["semestre_id"]
descr_sem = f'S{sem["semestre_id"]}'
else:
descr_sem = ""
if sem["modalite"]:

View File

@ -382,18 +382,6 @@ class BasePreferences(object):
"only_global": False,
},
),
(
"recap_hidebac",
{
"initvalue": 0,
"title": "Cacher la colonne Bac",
"explanation": "sur la table récapitulative",
"input_type": "boolcheckbox",
"category": "misc",
"labels": ["non", "oui"],
"only_global": False,
},
),
# ------------------ Absences
(
"email_chefdpt",

File diff suppressed because it is too large Load Diff

View File

@ -55,19 +55,18 @@ from app.scodoc.sco_pdf import SU
from app.scodoc import html_sco_header
from app.scodoc import htmlutils
from app.scodoc import sco_import_etuds
from app.scodoc import sco_etud
from app.scodoc import sco_excel
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_groups_view
from app.scodoc import sco_pdf
from app.scodoc import sco_photos
from app.scodoc import sco_portal_apogee
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
from app.scodoc import sco_trombino_doc
def trombino(
group_ids=[], # liste des groupes à afficher
group_ids=(), # liste des groupes à afficher
formsemestre_id=None, # utilisé si pas de groupes selectionné
etat=None,
format="html",
@ -93,6 +92,8 @@ def trombino(
return _trombino_pdf(groups_infos)
elif format == "pdflist":
return _listeappel_photos_pdf(groups_infos)
elif format == "doc":
return sco_trombino_doc.trombino_doc(groups_infos)
else:
raise Exception("invalid format")
# return _trombino_html_header() + trombino_html( group, members) + html_sco_header.sco_footer()
@ -176,8 +177,13 @@ def trombino_html(groups_infos):
H.append("</div>")
H.append(
'<div style="margin-bottom:15px;"><a class="stdlink" href="trombino?format=pdf&%s">Version PDF</a></div>'
% groups_infos.groups_query_args
f"""<div style="margin-bottom:15px;">
<a class="stdlink" href="{url_for('scolar.trombino', scodoc_dept=g.scodoc_dept,
format='pdf', group_ids=groups_infos.group_ids)}">Version PDF</a>
&nbsp;&nbsp;
<a class="stdlink" href="{url_for('scolar.trombino', scodoc_dept=g.scodoc_dept,
format='doc', group_ids=groups_infos.group_ids)}">Version doc</a>
</div>"""
)
return "\n".join(H)
@ -234,7 +240,7 @@ def _trombino_zip(groups_infos):
Z.writestr(filename, img)
Z.close()
size = data.tell()
log("trombino_zip: %d bytes" % size)
log(f"trombino_zip: {size} bytes")
data.seek(0)
return send_file(
data,
@ -470,7 +476,7 @@ def _listeappel_photos_pdf(groups_infos):
# --------------------- Upload des photos de tout un groupe
def photos_generate_excel_sample(group_ids=[]):
def photos_generate_excel_sample(group_ids=()):
"""Feuille excel pour import fichiers photos"""
fmt = sco_import_etuds.sco_import_format()
data = sco_import_etuds.sco_import_generate_excel_sample(
@ -492,18 +498,21 @@ def photos_generate_excel_sample(group_ids=[]):
# return sco_excel.send_excel_file(data, "ImportPhotos" + scu.XLSX_SUFFIX)
def photos_import_files_form(group_ids=[]):
def photos_import_files_form(group_ids=()):
"""Formulaire pour importation photos"""
if not group_ids:
raise ScoValueError("paramètre manquant !")
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids)
back_url = "groups_view?%s&curtab=tab-photos" % groups_infos.groups_query_args
back_url = f"groups_view?{groups_infos.groups_query_args}&curtab=tab-photos"
H = [
html_sco_header.sco_header(page_title="Import des photos des étudiants"),
"""<h2 class="formsemestre">Téléchargement des photos des étudiants</h2>
<p><b>Vous pouvez aussi charger les photos individuellement via la fiche de chaque étudiant (menu "Etudiant" / "Changer la photo").</b></p>
<p class="help">Cette page permet de charger en une seule fois les photos de plusieurs étudiants.<br/>
f"""<h2 class="formsemestre">Téléchargement des photos des étudiants</h2>
<p><b>Vous pouvez aussi charger les photos individuellement via la fiche
de chaque étudiant (menu "Etudiant" / "Changer la photo").</b>
</p>
<p class="help">Cette page permet de charger en une seule fois les photos
de plusieurs étudiants.<br/>
Il faut d'abord remplir une feuille excel donnant les noms
des fichiers images (une image par étudiant).
</p>
@ -511,12 +520,11 @@ def photos_import_files_form(group_ids=[]):
simultanément le fichier excel et le fichier zip.
</p>
<ol>
<li><a class="stdlink" href="photos_generate_excel_sample?%s">
<li><a class="stdlink" href="photos_generate_excel_sample?{groups_infos.groups_query_args}">
Obtenir la feuille excel à remplir</a>
</li>
<li style="padding-top: 2em;">
"""
% groups_infos.groups_query_args,
""",
]
F = html_sco_header.sco_footer()
vals = scu.get_request_args()

View File

@ -0,0 +1,76 @@
##############################################################################
# ScoDoc
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
# See LICENSE
##############################################################################
"""Génération d'un trombinoscope en doc
"""
import docx
from docx.shared import Mm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_ALIGN_VERTICAL
from app.scodoc import sco_etud
from app.scodoc import sco_photos
import app.scodoc.sco_utils as scu
import sco_version
def trombino_doc(groups_infos):
"Send photos as docx document"
filename = f"trombino_{groups_infos.groups_filename}.docx"
sem = groups_infos.formsemestre # suppose 1 seul semestre
PHOTO_WIDTH = Mm(25)
N_PER_ROW = 5 # XXX should be in ScoDoc preferences
document = docx.Document()
document.add_heading(
f"Trombinoscope {sem['titreannee']} {groups_infos.groups_titles}", 1
)
section = document.sections[0]
footer = section.footer
footer.paragraphs[
0
].text = f"Généré par {sco_version.SCONAME} le {scu.timedate_human_repr()}"
nb_images = len(groups_infos.members)
table = document.add_table(rows=2 * (nb_images // N_PER_ROW + 1), cols=N_PER_ROW)
table.allow_autofit = False
for i, t in enumerate(groups_infos.members):
li = i // N_PER_ROW
co = i % N_PER_ROW
img_path = (
sco_photos.photo_pathname(t["photo_filename"], size="small")
or sco_photos.UNKNOWN_IMAGE_PATH
)
cell = table.rows[2 * li].cells[co]
cell.vertical_alignment = WD_ALIGN_VERTICAL.TOP
cell_p, cell_f, cell_r = _paragraph_format_run(cell)
cell_r.add_picture(img_path, width=PHOTO_WIDTH)
# le nom de l'étudiant: cellules de lignes impaires
cell = table.rows[2 * li + 1].cells[co]
cell.vertical_alignment = WD_ALIGN_VERTICAL.TOP
cell_p, cell_f, cell_r = _paragraph_format_run(cell)
cell_r.add_text(sco_etud.format_nomprenom(t))
cell_f.space_after = Mm(8)
return scu.send_docx(document, filename)
def _paragraph_format_run(cell):
"parag. dans cellule tableau"
# inspired by https://stackoverflow.com/questions/64218305/problem-with-python-docx-putting-pictures-in-a-table
paragraph = cell.paragraphs[0]
fmt = paragraph.paragraph_format
run = paragraph.add_run()
fmt.space_before = Mm(0)
fmt.space_after = Mm(0)
fmt.line_spacing = 1.0
fmt.alignment = WD_ALIGN_PARAGRAPH.CENTER
return paragraph, fmt, run

View File

@ -227,7 +227,7 @@ def _user_list(user_name):
@cache.memoize(timeout=50) # seconds
def user_info(user_name_or_id=None, user=None):
def user_info(user_name_or_id=None, user: User = None):
"""Dict avec infos sur l'utilisateur (qui peut ne pas etre dans notre base).
Si user_name est specifie (string ou id), interroge la BD. Sinon, user doit etre une instance
de User.

View File

@ -33,6 +33,7 @@ import bisect
import copy
import datetime
from enum import IntEnum
import io
import json
from hashlib import md5
import numbers
@ -49,6 +50,7 @@ from PIL import Image as PILImage
import pydot
import requests
import flask
from flask import g, request
from flask import flash, url_for, make_response, jsonify
@ -176,6 +178,7 @@ MONTH_NAMES = (
"novembre",
"décembre",
)
DAY_NAMES = ("lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche")
def fmt_note(val, note_max=None, keep_numeric=False):
@ -191,7 +194,7 @@ def fmt_note(val, note_max=None, keep_numeric=False):
if isinstance(val, float) or isinstance(val, int):
if np.isnan(val):
return "~"
if note_max != None and note_max > 0:
if (note_max is not None) and note_max > 0:
val = val * 20.0 / note_max
if keep_numeric:
return val
@ -379,6 +382,10 @@ CSV_FIELDSEP = ";"
CSV_LINESEP = "\n"
CSV_MIMETYPE = "text/comma-separated-values"
CSV_SUFFIX = ".csv"
DOCX_MIMETYPE = (
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
)
DOCX_SUFFIX = ".docx"
JSON_MIMETYPE = "application/json"
JSON_SUFFIX = ".json"
PDF_MIMETYPE = "application/pdf"
@ -398,6 +405,7 @@ def get_mime_suffix(format_code: str) -> tuple[str, str]:
"""
d = {
"csv": (CSV_MIMETYPE, CSV_SUFFIX),
"docx": (DOCX_MIMETYPE, DOCX_SUFFIX),
"xls": (XLSX_MIMETYPE, XLSX_SUFFIX),
"xlsx": (XLSX_MIMETYPE, XLSX_SUFFIX),
"pdf": (PDF_MIMETYPE, PDF_SUFFIX),
@ -740,6 +748,18 @@ def send_file(data, filename="", suffix="", mime=None, attached=None):
return response
def send_docx(document, filename):
"Send a python-docx document"
buffer = io.BytesIO() # in-memory document, no disk file
document.save(buffer)
buffer.seek(0)
return flask.send_file(
buffer,
attachment_filename=sanitize_filename(filename),
mimetype=DOCX_MIMETYPE,
)
def get_request_args():
"""returns a dict with request (POST or GET) arguments
converted to suit legacy Zope style (scodoc7) functions.
@ -1057,6 +1077,36 @@ def objects_renumber(db, obj_list) -> None:
db.session.commit()
def gen_cell(key: str, row: dict, elt="td", with_col_class=False):
"html table cell"
klass = row.get(f"_{key}_class", "")
if with_col_class:
klass = key + " " + klass
attrs = f'class="{klass}"' if klass else ""
order = row.get(f"_{key}_order")
if order:
attrs += f' data-order="{order}"'
content = row.get(key, "")
target = row.get(f"_{key}_target")
target_attrs = row.get(f"_{key}_target_attrs", "")
if target or target_attrs: # avec lien
href = f'href="{target}"' if target else ""
content = f"<a {href} {target_attrs}>{content}</a>"
return f"<{elt} {attrs}>{content}</{elt}>"
def gen_row(
keys: list[str], row, elt="td", selected_etudid=None, with_col_classes=False
):
"html table row"
klass = row.get("_tr_class")
tr_class = f'class="{klass}"' if klass else ""
tr_id = (
f"""id="row_selected" """ if (row.get("etudid", "") == selected_etudid) else ""
)
return f"""<tr {tr_id} {tr_class}>{"".join([gen_cell(key, row, elt, with_col_class=with_col_classes) for key in keys if not key.startswith('_')])}</tr>"""
# Pour accès depuis les templates jinja
def is_entreprises_enabled():
from app.models import ScoDocSiteConfig

View File

@ -1076,7 +1076,7 @@ tr.etuddem td {
td.etudabs,
td.etudabs a.discretelink,
tr.etudabs td.moyenne a.discretelink {
color: rgb(180, 0, 0);
color: rgb(195, 0, 0);
}
tr.moyenne td {
@ -1089,13 +1089,31 @@ table.notes_evaluation th.eval_complete {
table.notes_evaluation th.eval_incomplete {
color: red;
width: 80px;
font-size: 80%;
}
table.notes_evaluation td.eval_incomplete>a {
font-size: 80%;
color: rgb(166, 50, 159);
}
table.notes_evaluation th.eval_attente {
color: rgb(215, 90, 0);
;
width: 80px;
}
table.notes_evaluation td.att a {
color: rgb(255, 0, 217);
font-weight: bold;
}
table.notes_evaluation td.exc a {
font-style: italic;
color: rgb(0, 131, 0);
}
table.notes_evaluation tr td a.discretelink:hover {
text-decoration: none;
}
@ -1139,6 +1157,18 @@ span.jurylink a {
text-decoration: underline;
}
div.jury_footer {
display: flex;
justify-content: space-evenly;
}
div.jury_footer>span {
border: 2px solid rgb(90, 90, 90);
border-radius: 4px;
padding: 4px;
background-color: rgb(230, 242, 230);
}
.eval_description p {
margin-left: 15px;
margin-bottom: 2px;
@ -2402,6 +2432,12 @@ span.bul_minmax:before {
content: " ";
}
a.invisible_link,
a.invisible_link:hover {
text-decoration: none;
color: rgb(20, 30, 30);
}
a.bull_link {
text-decoration: none;
color: rgb(20, 30, 30);
@ -3535,7 +3571,7 @@ table.dataTable td.group {
text-align: left;
}
/* Nouveau tableau recap */
/* ------------- Nouveau tableau recap ------------ */
div.table_recap {
margin-top: 6px;
}
@ -3704,3 +3740,111 @@ table.table_recap tr.def td {
color: rgb(121, 74, 74);
font-style: italic;
}
table.table_recap td.evaluation,
table.table_recap tr.descr_evaluation {
font-size: 90%;
color: rgb(4, 16, 159);
}
table.table_recap tr.descr_evaluation a {
color: rgb(4, 16, 159);
text-decoration: none;
}
table.table_recap tr.descr_evaluation a:hover {
color: red;
}
table.table_recap tr.descr_evaluation {
vertical-align: top;
}
table.table_recap tr.apo {
font-size: 75%;
font-family: monospace;
}
table.table_recap tr.apo td {
border: 1px solid gray;
background-color: #d8f5fe;
}
table.table_recap td.evaluation.first,
table.table_recap th.evaluation.first {
border-left: 2px solid rgb(4, 16, 159);
}
table.table_recap td.evaluation.first_of_mod,
table.table_recap th.evaluation.first_of_mod {
border-left: 1px dashed rgb(4, 16, 159);
}
table.table_recap td.evaluation.att {
color: rgb(255, 0, 217);
font-weight: bold;
}
table.table_recap td.evaluation.abs {
color: rgb(231, 0, 0);
font-weight: bold;
}
table.table_recap td.evaluation.exc {
font-style: italic;
color: rgb(0, 131, 0);
}
table.table_recap td.evaluation.non_inscrit {
font-style: italic;
color: rgb(101, 101, 101);
}
/* ------------- Tableau etat evals ------------ */
div.evaluations_recap table.evaluations_recap {
width: auto !important;
border: 1px solid black;
}
table.evaluations_recap tr.odd td {
background-color: #fff4e4;
}
table.evaluations_recap tr.res td {
background-color: #f7d372;
}
table.evaluations_recap tr.sae td {
background-color: #d8fcc8;
}
table.evaluations_recap tr.module td {
font-weight: bold;
}
table.evaluations_recap tr.evaluation td.titre {
font-style: italic;
padding-left: 2em;
}
table.evaluations_recap td.titre,
table.evaluations_recap th.titre {
max-width: 350px;
}
table.evaluations_recap td.complete,
table.evaluations_recap th.complete {
text-align: center;
}
table.evaluations_recap tr.evaluation.incomplete td,
table.evaluations_recap tr.evaluation.incomplete td a {
color: red;
}
table.evaluations_recap tr.evaluation.incomplete td a.incomplete {
font-weight: bold;
}

View File

@ -0,0 +1,38 @@
// Tableau recap evaluations du semestre
$(function () {
$('table.evaluations_recap').DataTable(
{
paging: false,
searching: true,
info: false,
autoWidth: false,
fixedHeader: {
header: true,
footer: false
},
orderCellsTop: true, // cellules ligne 1 pour tri
aaSorting: [], // Prevent initial sorting
colReorder: true,
"columnDefs": [
{
// colonne date, triable (XXX ne fonctionne pas)
targets: ["date"],
"type": "string",
},
],
dom: 'Bfrtip',
buttons: [
{
extend: 'copyHtml5',
text: 'Copier',
exportOptions: { orthogonal: 'export' }
},
{
extend: 'excelHtml5',
exportOptions: { orthogonal: 'export' },
title: document.querySelector('table.evaluations_recap').dataset.filename
},
],
})
});

View File

@ -3,14 +3,14 @@
$(function () {
// Autocomplete recherche etudiants par nom
$("#in-expnom").autocomplete(
$(".in-expnom").autocomplete(
{
delay: 300, // wait 300ms before suggestions
minLength: 2, // min nb of chars before suggest
position: { collision: 'flip' }, // automatic menu position up/down
source: "search_etud_by_name",
source: SCO_URL + "/search_etud_by_name",
select: function (event, ui) {
$("#in-expnom").val(ui.item.value);
$(".in-expnom").val(ui.item.value);
$("#form-chercheetud").submit();
}
});

View File

@ -21,7 +21,9 @@ $(function () {
dt.columns(".partition_aux").visible(!visible);
dt.buttons('toggle_partitions:name').text(visible ? "Toutes les partitions" : "Cacher les partitions");
}
},
}];
if (!$('table.table_recap').hasClass("jury")) {
buttons.push(
$('table.table_recap').hasClass("apc") ?
{
name: "toggle_res",
@ -30,6 +32,7 @@ $(function () {
let visible = dt.columns(".col_res").visible()[0];
dt.columns(".col_res").visible(!visible);
dt.columns(".col_ue_bonus").visible(!visible);
dt.columns(".col_malus").visible(!visible);
dt.buttons('toggle_res:name').text(visible ? "Montrer les ressources" : "Cacher les ressources");
}
} : {
@ -39,12 +42,13 @@ $(function () {
let visible = dt.columns(".col_mod:not(.col_empty)").visible()[0];
dt.columns(".col_mod:not(.col_empty)").visible(!visible);
dt.columns(".col_ue_bonus").visible(!visible);
dt.columns(".col_malus").visible(!visible);
dt.buttons('toggle_mod:name').text(visible ? "Montrer les modules" : "Cacher les modules");
visible = dt.columns(".col_empty").visible()[0];
dt.buttons('toggle_col_empty:name').text(visible ? "Cacher mod. vides" : "Montrer mod. vides");
}
}
];
);
if ($('table.table_recap').hasClass("apc")) {
buttons.push({
name: "toggle_sae",
@ -55,7 +59,16 @@ $(function () {
dt.buttons('toggle_sae:name').text(visible ? "Montrer les SAÉs" : "Cacher les SAÉs");
}
})
}
buttons.push({
name: "toggle_col_empty",
text: "Montrer mod. vides",
action: function (e, dt, node, config) {
let visible = dt.columns(".col_empty").visible()[0];
dt.columns(".col_empty").visible(!visible);
dt.buttons('toggle_col_empty:name').text(visible ? "Montrer mod. vides" : "Cacher mod. vides");
}
})
}
buttons.push({
name: "toggle_admission",
@ -66,15 +79,6 @@ $(function () {
dt.buttons('toggle_admission:name').text(visible ? "Montrer infos admission" : "Cacher infos admission");
}
})
buttons.push({
name: "toggle_col_empty",
text: "Montrer mod. vides",
action: function (e, dt, node, config) {
let visible = dt.columns(".col_empty").visible()[0];
dt.columns(".col_empty").visible(!visible);
dt.buttons('toggle_col_empty:name').text(visible ? "Montrer mod. vides" : "Cacher mod. vides");
}
})
$('table.table_recap').DataTable(
{
paging: false,
@ -90,13 +94,37 @@ $(function () {
colReorder: true,
"columnDefs": [
{
// cache le détail de l'identité, les groupes, les colonnes admission et les vides
"targets": ["identite_detail", "partition_aux", "admission", "col_empty"],
"visible": false,
// cache les codes, le détail de l'identité, les groupes, les colonnes admission et les vides
targets: ["codes", "identite_detail", "partition_aux", "admission", "col_empty"],
visible: false,
},
{
// Elimine les 0 à gauche pour les exports excel et les "copy"
targets: ["col_mod", "col_moy_gen", "col_ue", "col_res", "col_sae"],
render: function (data, type, row) {
return type === 'export' ? data.replace(/0(\d\..*)/, '$1') : data;
}
},
{
// Elimine les décorations (fleches bonus/malus) pour les exports
targets: ["col_ue_bonus", "col_malus"],
render: function (data, type, row) {
return type === 'export' ? data.replace(/.*(\d\d\.\d\d)/, '$1').replace(/0(\d\..*)/, '$1') : data;
}
},
],
dom: 'Bfrtip',
buttons: ['copy', 'excel', 'pdf',
buttons: [
{
extend: 'copyHtml5',
text: 'Copier',
exportOptions: { orthogonal: 'export' }
},
{
extend: 'excelHtml5',
exportOptions: { orthogonal: 'export' },
title: document.querySelector('table.table_recap').dataset.filename
},
{
extend: 'collection',
text: 'Colonnes affichées',
@ -117,4 +145,10 @@ $(function () {
$(this).addClass('selected');
}
});
// Pour montrer et highlihter l'étudiant sélectionné:
$(function () {
document.querySelector("#row_selected").scrollIntoView();
window.scrollBy(0, -50);
document.querySelector("#row_selected").classList.add("selected");
});
});

View File

@ -32,7 +32,7 @@
{% if can_edit_appreciations %}
<p><a class="stdlink" href="{{url_for(
'notes.appreciation_add_form', scodoc_dept=g.scodoc_dept,
etudid=etud.id, formsemestre_id=formsemestre_id)
etudid=etud.id, formsemestre_id=formsemestre.id)
}}">Ajouter une appréciation</a>
</p>
{% endif %}

View File

@ -41,7 +41,7 @@
<form method="get" id="form-chercheetud"
action="{{ url_for('scolar.search_etud_in_dept', scodoc_dept=g.scodoc_dept) }}">
<div>
<input type="text" size="12" id="in-expnom" name="expnom" spellcheck="false" />
<input type="text" size="12" class="in-expnom" name="expnom" spellcheck="false" />
</div>
</form>
</div>
@ -49,7 +49,7 @@
<div class="etud-insidebar">
{% if sco.etud %}
<h2 id="insidebar-etud"><a href="{{url_for(
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=sco.etud.id )}}" class="sidebar">
'scolar.ficheEtud', scodoc_dept=g.scodoc_dept, etudid=sco.etud.id )}}" class="sidebar">
<span class="fontred">{{sco.etud.nomprenom}}</span></a>
</h2>
<b>Absences</b>

View File

@ -69,7 +69,7 @@ from app.decorators import (
permission_required,
permission_required_compat_scodoc7,
)
from app.models import FormSemestre
from app.models import FormSemestre, GroupDescr
from app.models.absences import BilletAbsence
from app.views import absences_bp as bp
@ -119,60 +119,68 @@ def sco_publish(route, function, permission, methods=["GET"]):
@scodoc7func
def index_html():
"""Gestionnaire absences, page principale"""
# crude portage from 1999 DTML
sems = sco_formsemestre.do_formsemestre_list()
authuser = current_user
H = [
html_sco_header.sco_header(
page_title="Gestion des absences",
page_title="Saisie des absences",
cssstyles=["css/calabs.css"],
javascripts=["js/calabs.js"],
),
"""<h2>Gestion des Absences</h2>""",
"""<h2>Traitement des absences</h2>
<p class="help">
Pour saisir des absences ou consulter les états, il est recommandé par passer par
le semestre concerné (saisie par jours nommés ou par semaines).
</p>
""",
]
if not sems:
H.append(
"""<p class="warning">Aucun semestre défini (ou aucun groupe d'étudiant)</p>"""
)
else:
H.append(
"""<ul><li><a href="EtatAbsences">Afficher l'état des absences (pour tout un groupe)</a></li>"""
)
if sco_preferences.get_preference("handle_billets_abs"):
H.append(
"""<li><a href="listeBillets">Traitement des billets d'absence en attente</a></li>"""
)
H.append(
"""<p>Pour signaler, annuler ou justifier une absence, choisissez d'abord l'étudiant concerné:</p>"""
"""<p class="help">Pour signaler, annuler ou justifier une absence pour un seul étudiant,
choisissez d'abord concerné:</p>"""
)
H.append(sco_find_etud.form_search_etud())
if authuser.has_permission(Permission.ScoAbsChange):
H.extend(
(
"""<hr/>
<form action="SignaleAbsenceGrHebdo" id="formw">
<input type="hidden" name="destination" value="%s"/>
<p>
<span style="font-weight: bold; font-size:120%%;">
Saisie par semaine </span> - Choix du groupe:
<input name="datelundi" type="hidden" value="x"/>
if current_user.has_permission(
Permission.ScoAbsChange
) and sco_preferences.get_preference("handle_billets_abs"):
H.append(
"""
% request.base_url,
sco_abs_views.formChoixSemestreGroupe(),
"</p>",
<h2 style="margin-top: 30px;">Billets d'absence</h2>
<ul><li><a href="listeBillets">Traitement des billets d'absence en attente</a></li></ul>
"""
)
H.append(html_sco_header.sco_footer())
return "\n".join(H)
@bp.route("/choix_semaine")
@scodoc
@permission_required(Permission.ScoAbsChange)
@scodoc7func
def choix_semaine(group_id):
"""Page choix semaine sur calendrier pour saisie absences d'un groupe"""
group = GroupDescr.query.get_or_404(group_id)
H = [
html_sco_header.sco_header(
page_title="Saisie des absences",
cssstyles=["css/calabs.css"],
javascripts=["js/calabs.js"],
),
f"""
<h2>Saisie des Absences</h2>
<form action="SignaleAbsenceGrHebdo" id="formw">
<p>
<span style="font-weight: bold; font-size:120%;">
Saisie par semaine </span> - Groupe: {group.get_nom_with_part()}
<input name="datelundi" type="hidden" value="x"/>
<input name="group_ids" type="hidden" value="{group_id}"/>
</p>
""",
cal_select_week(),
"""<p class="help">Sélectionner le groupe d'étudiants, puis cliquez sur une semaine pour
saisir les absences de toute cette semaine.</p>
</form>""",
)
)
else:
H.append(
"""<p class="scoinfo">Vous n'avez pas l'autorisation d'ajouter, justifier ou supprimer des absences.</p>"""
)
H.append(html_sco_header.sco_footer())
</form>
""",
html_sco_header.sco_footer(),
]
return "\n".join(H)
@ -479,7 +487,7 @@ def SignaleAbsenceGrSemestre(
datedebut,
datefin,
destination="",
group_ids=[], # list of groups to display
group_ids=(), # list of groups to display
nbweeks=4, # ne montre que les nbweeks dernieres semaines
moduleimpl_id=None,
):
@ -566,7 +574,7 @@ def SignaleAbsenceGrSemestre(
url_link_semaines += "&moduleimpl_id=" + str(moduleimpl_id)
#
dates = [x.ISO() for x in dates]
dayname = sco_abs.day_names()[jourdebut.weekday]
day_name = sco_abs.day_names()[jourdebut.weekday]
if groups_infos.tous_les_etuds_du_sem:
gr_tit = "en"
@ -579,19 +587,18 @@ def SignaleAbsenceGrSemestre(
H = [
html_sco_header.sco_header(
page_title="Saisie des absences",
page_title=f"Saisie des absences du {day_name}",
init_qtip=True,
javascripts=["js/etud_info.js", "js/abs_ajax.js"],
no_side_bar=1,
),
"""<table border="0" cellspacing="16"><tr><td>
<h2>Saisie des absences %s %s,
les <span class="fontred">%s</span></h2>
f"""<table border="0" cellspacing="16"><tr><td>
<h2>Saisie des absences {gr_tit} {sem["titre_num"]},
les <span class="fontred">{day_name}s</span></h2>
<p>
<a href="%s">%s</a>
<a href="{url_link_semaines}">{msg}</a>
<form id="abs_form" action="doSignaleAbsenceGrSemestre" method="post">
"""
% (gr_tit, sem["titre_num"], dayname, url_link_semaines, msg),
""",
]
#
if etuds:
@ -820,7 +827,6 @@ def _gen_form_saisie_groupe(
# version pour formulaire avec AJAX (Yann LB)
H.append(
"""
<p><input type="button" value="Retour" onClick="window.location='%s'"/>
</p>
</form>
</p>
@ -832,7 +838,6 @@ def _gen_form_saisie_groupe(
Attention, les modifications sont automatiquement entregistrées au fur et à mesure.
</p>
"""
% destination
)
return H

View File

@ -100,6 +100,7 @@ from app.scodoc import sco_evaluations
from app.scodoc import sco_evaluation_check_abs
from app.scodoc import sco_evaluation_db
from app.scodoc import sco_evaluation_edit
from app.scodoc import sco_evaluation_recap
from app.scodoc import sco_export_results
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
@ -109,22 +110,18 @@ from app.scodoc import sco_formsemestre_exterieurs
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_formsemestre_status
from app.scodoc import sco_formsemestre_validation
from app.scodoc import sco_groups
from app.scodoc import sco_inscr_passage
from app.scodoc import sco_liste_notes
from app.scodoc import sco_lycee
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_moduleimpl_inscriptions
from app.scodoc import sco_moduleimpl_status
from app.scodoc import sco_news
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_permissions_check
from app.scodoc import sco_placement
from app.scodoc import sco_poursuite_dut
from app.scodoc import sco_preferences
from app.scodoc import sco_prepajury
from app.scodoc import sco_pvjury
from app.scodoc import sco_pvpdf
from app.scodoc import sco_recapcomplet
from app.scodoc import sco_report
from app.scodoc import sco_saisie_notes
@ -136,7 +133,6 @@ from app.scodoc import sco_undo_notes
from app.scodoc import sco_users
from app.scodoc import sco_xml
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_pdf import PDFLOCK
from app.scodoc.sco_permissions import Permission
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.views import ScoData
@ -235,6 +231,11 @@ sco_publish(
sco_recapcomplet.formsemestre_recapcomplet,
Permission.ScoView,
)
sco_publish(
"/evaluations_recap",
sco_evaluation_recap.evaluations_recap,
Permission.ScoView,
)
sco_publish(
"/formsemestres_bulletins",
sco_recapcomplet.formsemestres_bulletins,
@ -1737,12 +1738,13 @@ def evaluation_listenotes():
evaluation_id = None
moduleimpl_id = None
vals = scu.get_request_args()
try:
if "evaluation_id" in vals:
evaluation_id = int(vals["evaluation_id"])
mode = "eval"
if "moduleimpl_id" in vals and vals["moduleimpl_id"]:
moduleimpl_id = int(vals["moduleimpl_id"])
mode = "module"
except ValueError as exc:
raise ScoValueError("adresse invalide !") from exc
format = vals.get("format", "html")
html_content, page_title = sco_liste_notes.do_evaluation_listenotes(

View File

@ -144,11 +144,12 @@ def config_codes_decisions():
if form.validate_on_submit():
for code in models.config.CODES_SCODOC_TO_APO:
ScoDocSiteConfig.set_code_apo(code, getattr(form, code).data)
flash(f"Codes décisions enregistrés.")
flash("Codes décisions enregistrés.")
return redirect(url_for("scodoc.index"))
elif request.method == "GET":
for code in models.config.CODES_SCODOC_TO_APO:
getattr(form, code).data = ScoDocSiteConfig.get_code_apo(code)
return render_template(
"config_codes_decisions.html",
form=form,

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.1.90api"
SCOVERSION = "9.2.0api"
SCONAME = "ScoDoc"

View File

@ -35,7 +35,7 @@ cnx = psycopg2.connect(DBCNXSTRING)
cursor = cnx.cursor()
cursor.execute(
"select count(*) from notes_formsemestre where formsemestre_id=%(formsemestre_id)s",
"select count(*) from notes_formsemestre where id=%(formsemestre_id)s",
{"formsemestre_id": formsemestre_id},
)
nsem = cursor.fetchone()[0]
@ -44,9 +44,9 @@ if nsem != 1:
sys.exit(2)
cursor.execute(
"""select i.etudid
"""select i.id
from identite i, notes_formsemestre_inscription ins
where i.etudid=ins.etudid and ins.formsemestre_id=%(formsemestre_id)s
where i.id=ins.etudid and ins.formsemestre_id=%(formsemestre_id)s
""",
{"formsemestre_id": formsemestre_id},
)
@ -64,7 +64,7 @@ for (etudid,) in cursor:
"etudid": etudid,
"code_nip": random.randrange(10000000, 99999999),
}
req = "update identite set nom=%(nom)s, prenom=%(prenom)s, civilite=%(civilite)s where etudid=%(etudid)s"
req = "update identite set nom=%(nom)s, prenom=%(prenom)s, civilite=%(civilite)s where id=%(etudid)s"
# print( req % args)
wcursor.execute(req, args)
n += 1