2020-09-26 16:19:37 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2023-01-02 13:16:27 +01:00
|
|
|
# Copyright (c) 1999 - 2023 Emmanuel Viennet. All rights reserved.
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2022-02-06 16:09:17 +01:00
|
|
|
"""Tableau récapitulatif des notes d'un semestre
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2023-06-20 12:14:16 +02:00
|
|
|
import collections
|
2021-02-04 20:02:44 +01:00
|
|
|
import datetime
|
2021-09-16 00:15:10 +02:00
|
|
|
import time
|
2021-07-10 17:40:40 +02:00
|
|
|
from xml.etree import ElementTree
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-03-23 22:30:22 +01:00
|
|
|
from flask import g, request
|
2022-05-10 18:18:44 +02:00
|
|
|
from flask import abort, url_for
|
2021-09-18 10:10:02 +02:00
|
|
|
|
2021-08-29 19:57:32 +02:00
|
|
|
from app import log
|
2021-12-11 20:27:58 +01:00
|
|
|
from app.but import bulletin_but
|
2022-01-08 18:06:00 +01:00
|
|
|
from app.comp import res_sem
|
2023-01-18 18:25:40 +01:00
|
|
|
from app.comp.res_common import ResultatsSemestre
|
2022-03-27 22:25:00 +02:00
|
|
|
from app.comp.res_compat import NotesTableCompat
|
2021-12-17 21:59:28 +01:00
|
|
|
from app.models import FormSemestre
|
|
|
|
from app.models.etudiants import Identite
|
2021-12-11 20:27:58 +01:00
|
|
|
|
|
|
|
import app.scodoc.sco_utils as scu
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import html_sco_header
|
|
|
|
from app.scodoc import sco_bulletins_json
|
|
|
|
from app.scodoc import sco_bulletins_xml
|
2022-04-05 22:23:55 +02:00
|
|
|
from app.scodoc import sco_cache
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_evaluations
|
2022-04-06 18:51:01 +02:00
|
|
|
from app.scodoc.sco_exceptions import ScoValueError
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_formsemestre
|
|
|
|
from app.scodoc import sco_formsemestre_status
|
|
|
|
from app.scodoc import sco_preferences
|
2023-02-03 22:39:45 +01:00
|
|
|
from app.tables.recap import TableRecap
|
2023-02-06 13:05:39 +01:00
|
|
|
from app.tables.jury_recap import TableJury
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
def formsemestre_recapcomplet(
|
|
|
|
formsemestre_id=None,
|
2022-06-29 16:30:01 +02:00
|
|
|
mode_jury=False,
|
2020-09-26 16:19:37 +02:00
|
|
|
tabformat="html",
|
2022-04-07 23:31:08 +02:00
|
|
|
xml_with_decisions=False,
|
|
|
|
force_publishing=True,
|
|
|
|
selected_etudid=None,
|
2020-09-26 16:19:37 +02:00
|
|
|
):
|
|
|
|
"""Page récapitulant les notes d'un semestre.
|
|
|
|
Grand tableau récapitulatif avec toutes les notes de modules
|
|
|
|
pour tous les étudiants, les moyennes par UE et générale,
|
|
|
|
trié par moyenne générale décroissante.
|
2022-04-06 18:51:01 +02:00
|
|
|
|
|
|
|
tabformat:
|
|
|
|
html : page web
|
|
|
|
evals : page web, avec toutes les évaluations dans le tableau
|
|
|
|
xls, xlsx: export excel simple
|
|
|
|
xlsall : export excel simple, avec toutes les évaluations dans le tableau
|
|
|
|
csv : export CSV, avec toutes les évaluations
|
|
|
|
xml, json : concaténation de tous les bulletins, au format demandé
|
|
|
|
pdf : NON SUPPORTE (car tableau trop grand pour générer un pdf utilisable)
|
|
|
|
|
2022-06-29 16:30:01 +02:00
|
|
|
mode_jury: cache modules, affiche lien saisie decision jury
|
2022-04-07 23:31:08 +02:00
|
|
|
xml_with_decisions: publie décisions de jury dans xml et json
|
|
|
|
force_publishing: publie les xml et json même si bulletins non publiés
|
|
|
|
selected_etudid: etudid sélectionné (pour scroller au bon endroit)
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2022-05-10 18:18:44 +02:00
|
|
|
if not isinstance(formsemestre_id, int):
|
|
|
|
abort(404)
|
2023-03-20 11:17:38 +01:00
|
|
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
2022-05-09 18:32:54 +02:00
|
|
|
file_formats = {"csv", "json", "xls", "xlsx", "xlsall", "xml"}
|
2022-05-10 10:06:51 +02:00
|
|
|
supported_formats = file_formats | {"html", "evals"}
|
2022-05-09 18:32:54 +02:00
|
|
|
if tabformat not in supported_formats:
|
|
|
|
raise ScoValueError(f"Format non supporté: {tabformat}")
|
|
|
|
is_file = tabformat in file_formats
|
2022-06-29 16:30:01 +02:00
|
|
|
mode_jury = int(mode_jury)
|
2020-09-26 16:19:37 +02:00
|
|
|
xml_with_decisions = int(xml_with_decisions)
|
2020-12-12 17:22:54 +01:00
|
|
|
force_publishing = int(force_publishing)
|
2023-02-12 01:13:43 +01:00
|
|
|
filename = scu.sanitize_filename(
|
2023-03-12 12:30:57 +01:00
|
|
|
f"""{'jury' if mode_jury else 'recap'
|
|
|
|
}{'-evals' if tabformat == 'xlsall' else ''
|
|
|
|
}-{formsemestre.titre_num()}-{time.strftime("%Y-%m-%d")}"""
|
2023-02-12 01:13:43 +01:00
|
|
|
)
|
|
|
|
if is_file:
|
|
|
|
return _formsemestre_recapcomplet_to_file(
|
|
|
|
formsemestre,
|
2023-03-12 12:30:57 +01:00
|
|
|
mode_jury=mode_jury,
|
2023-02-12 01:13:43 +01:00
|
|
|
tabformat=tabformat,
|
|
|
|
filename=filename,
|
|
|
|
xml_with_decisions=xml_with_decisions,
|
|
|
|
force_publishing=force_publishing,
|
|
|
|
)
|
2022-05-09 18:32:54 +02:00
|
|
|
|
2023-06-20 12:14:16 +02:00
|
|
|
table_html, table, freq_codes_annuels = _formsemestre_recapcomplet_to_html(
|
2023-02-12 01:13:43 +01:00
|
|
|
formsemestre,
|
|
|
|
filename=filename,
|
2022-06-29 16:30:01 +02:00
|
|
|
mode_jury=mode_jury,
|
2023-02-12 01:13:43 +01:00
|
|
|
tabformat=tabformat,
|
2022-04-07 23:31:08 +02:00
|
|
|
selected_etudid=selected_etudid,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2023-02-12 01:13:43 +01:00
|
|
|
|
2022-04-07 23:31:08 +02:00
|
|
|
H = [
|
|
|
|
html_sco_header.sco_header(
|
2023-02-09 16:01:56 +01:00
|
|
|
page_title=f"{formsemestre.sem_modalite()}: "
|
|
|
|
+ ("jury" if mode_jury else "moyennes"),
|
2022-04-07 23:31:08 +02:00
|
|
|
no_side_bar=True,
|
|
|
|
init_qtip=True,
|
|
|
|
javascripts=["js/etud_info.js", "js/table_recap.js"],
|
|
|
|
),
|
|
|
|
sco_formsemestre_status.formsemestre_status_head(
|
|
|
|
formsemestre_id=formsemestre_id
|
|
|
|
),
|
|
|
|
]
|
|
|
|
if len(formsemestre.inscriptions) > 0:
|
|
|
|
H.append(
|
|
|
|
f"""<form name="f" method="get" action="{request.base_url}">
|
|
|
|
<input type="hidden" name="formsemestre_id" value="{formsemestre_id}"></input>
|
|
|
|
"""
|
|
|
|
)
|
2022-06-29 16:30:01 +02:00
|
|
|
if mode_jury:
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append(
|
2022-06-29 16:30:01 +02:00
|
|
|
f'<input type="hidden" name="mode_jury" value="{mode_jury}"></input>'
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2022-04-07 23:31:08 +02:00
|
|
|
H.append(
|
|
|
|
'<select name="tabformat" onchange="document.f.submit()" class="noprint">'
|
|
|
|
)
|
2023-06-18 09:37:13 +02:00
|
|
|
for fmt, label in (
|
2022-04-07 23:31:08 +02:00
|
|
|
("html", "Tableau"),
|
|
|
|
("evals", "Avec toutes les évaluations"),
|
2022-05-10 20:32:25 +02:00
|
|
|
("xlsx", "Excel (non formaté)"),
|
2022-05-10 10:06:51 +02:00
|
|
|
("xlsall", "Excel avec évaluations"),
|
2022-04-07 23:31:08 +02:00
|
|
|
("json", "Bulletins JSON"),
|
|
|
|
):
|
2023-02-12 01:13:43 +01:00
|
|
|
if fmt == tabformat:
|
2022-04-07 23:31:08 +02:00
|
|
|
selected = " selected"
|
|
|
|
else:
|
|
|
|
selected = ""
|
2023-02-12 01:13:43 +01:00
|
|
|
H.append(f'<option value="{fmt}"{selected}>{label}</option>')
|
2022-04-07 23:31:08 +02:00
|
|
|
H.append(
|
2023-02-12 01:13:43 +01:00
|
|
|
f"""
|
|
|
|
</select> (cliquer sur un nom pour afficher son bulletin ou
|
|
|
|
<a class="stdlink"
|
2022-04-07 23:31:08 +02:00
|
|
|
href="{url_for('notes.formsemestre_bulletins_pdf',
|
2023-02-12 01:13:43 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id)
|
2022-04-07 23:31:08 +02:00
|
|
|
}">ici avoir le classeur papier</a>)
|
2023-02-12 01:13:43 +01:00
|
|
|
</form>
|
2022-04-07 23:31:08 +02:00
|
|
|
"""
|
|
|
|
)
|
2023-02-12 01:13:43 +01:00
|
|
|
|
|
|
|
H.append(table_html) # La table
|
2022-04-07 23:31:08 +02:00
|
|
|
|
|
|
|
if len(formsemestre.inscriptions) > 0:
|
2023-02-12 01:13:43 +01:00
|
|
|
H.append("""<div class="links_under_recap"><ul>""")
|
2023-02-18 18:49:52 +01:00
|
|
|
if not mode_jury:
|
|
|
|
H.append(
|
|
|
|
f"""<li><a class="stdlink" href="{url_for('notes.formsemestre_recapcomplet',
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id, mode_jury=1)
|
|
|
|
}">Décisions du jury</a>
|
|
|
|
</li>
|
|
|
|
"""
|
|
|
|
)
|
2023-02-12 01:13:43 +01:00
|
|
|
if formsemestre.can_edit_jury():
|
2022-06-29 16:30:01 +02:00
|
|
|
if mode_jury:
|
2022-03-27 23:19:17 +02:00
|
|
|
H.append(
|
2023-02-12 01:13:43 +01:00
|
|
|
f"""<li><a class="stdlink" href="{url_for('notes.formsemestre_validation_auto',
|
2022-04-07 23:31:08 +02:00
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id)
|
2023-01-30 19:30:25 +01:00
|
|
|
}">Calcul automatique des décisions du jury</a>
|
2023-02-12 01:13:43 +01:00
|
|
|
</li>
|
|
|
|
<li><a class="stdlink" href="{url_for('notes.formsemestre_jury_but_erase',
|
2023-01-30 19:30:25 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id, only_one_sem=1)
|
2023-06-18 09:37:13 +02:00
|
|
|
}">Effacer <em>toutes</em> les décisions de jury BUT issues de ce semestre</a>
|
2023-02-12 01:13:43 +01:00
|
|
|
</li>
|
2023-01-30 19:30:25 +01:00
|
|
|
"""
|
2022-04-07 23:31:08 +02:00
|
|
|
)
|
2023-02-18 18:49:52 +01:00
|
|
|
if mode_jury:
|
|
|
|
H.append(
|
|
|
|
f"""<li><a class="stdlink" href="{
|
|
|
|
url_for('notes.formsemestre_lettres_individuelles',
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id, mode_jury=1)
|
|
|
|
}">Courriers individuels (classeur pdf)</a>
|
|
|
|
</li>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
f"""<li><a class="stdlink" href="{url_for('notes.formsemestre_pvjury_pdf',
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id, mode_jury=1)
|
|
|
|
}">PV officiel (pdf)</a>
|
|
|
|
</li>
|
|
|
|
"""
|
|
|
|
)
|
2023-02-12 01:13:43 +01:00
|
|
|
H.append("</ul></div>")
|
|
|
|
|
2022-04-07 23:31:08 +02:00
|
|
|
if sco_preferences.get_preference("use_ue_coefs", formsemestre_id):
|
|
|
|
H.append(
|
|
|
|
"""
|
|
|
|
<p class="infop">utilise les coefficients d'UE pour calculer la moyenne générale.</p>
|
|
|
|
"""
|
|
|
|
)
|
2023-02-12 01:13:43 +01:00
|
|
|
|
2023-06-20 12:14:16 +02:00
|
|
|
if mode_jury and freq_codes_annuels and sum(freq_codes_annuels.values()) > 0:
|
|
|
|
nb_etud_avec_decision_annuelle = (
|
|
|
|
sum(freq_codes_annuels.values()) - freq_codes_annuels["total"]
|
|
|
|
)
|
2023-02-12 01:13:43 +01:00
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<div class="jury_stats">
|
2023-06-20 12:14:16 +02:00
|
|
|
<div><b>Nb d'étudiants avec décision annuelle:</b>
|
|
|
|
{nb_etud_avec_decision_annuelle} / {freq_codes_annuels["total"]}
|
2023-02-12 01:13:43 +01:00
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
)
|
2023-06-20 12:14:16 +02:00
|
|
|
if nb_etud_avec_decision_annuelle > 0:
|
2023-02-12 01:13:43 +01:00
|
|
|
H.append(
|
2023-06-20 12:14:16 +02:00
|
|
|
"""<div><b>Codes annuels octroyés:</b></div>
|
|
|
|
<table class="jury_stats_codes">
|
|
|
|
"""
|
2023-02-12 01:13:43 +01:00
|
|
|
)
|
2023-06-20 12:14:16 +02:00
|
|
|
for code in sorted(freq_codes_annuels.keys()):
|
|
|
|
if code != "total":
|
|
|
|
H.append(
|
|
|
|
f"""<tr>
|
|
|
|
<td>{code}</td>
|
|
|
|
<td style="text-align:right">{freq_codes_annuels[code]}</td>
|
|
|
|
<td style="text-align:right">{
|
|
|
|
(100*freq_codes_annuels[code] / freq_codes_annuels["total"]):2.1f}%
|
|
|
|
</td>
|
|
|
|
</tr>"""
|
|
|
|
)
|
|
|
|
H.append("""</table>""")
|
|
|
|
H.append("""</div>""")
|
2023-03-27 23:57:10 +02:00
|
|
|
# Légende
|
|
|
|
H.append(
|
|
|
|
"""
|
|
|
|
<div class="table_recap_caption">
|
|
|
|
<div class="title">Codes utilisés dans cette table:</div>
|
|
|
|
<div class="captions">
|
|
|
|
<div><tt>~</tt></div><div>valeur manquante</div>
|
|
|
|
<div><tt>=</tt></div><div>UE dispensée</div>
|
|
|
|
<div><tt>nan</tt></div><div>valeur non disponible</div>
|
2023-06-18 21:20:02 +02:00
|
|
|
<div>📍</div><div>code jury non enregistré</div>
|
2023-03-27 23:57:10 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
)
|
2022-04-07 23:31:08 +02:00
|
|
|
H.append(html_sco_header.sco_footer())
|
2021-08-21 16:51:08 +02:00
|
|
|
# HTML or binary data ?
|
|
|
|
if len(H) > 1:
|
|
|
|
return "".join(H)
|
|
|
|
elif len(H) == 1:
|
|
|
|
return H[0]
|
|
|
|
else:
|
|
|
|
return H
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2023-02-12 01:13:43 +01:00
|
|
|
def _formsemestre_recapcomplet_to_html(
|
|
|
|
formsemestre: FormSemestre,
|
|
|
|
tabformat="html", # "html" or "evals"
|
|
|
|
filename: str = "",
|
2022-06-29 16:30:01 +02:00
|
|
|
mode_jury=False, # saisie décisions jury
|
2023-02-12 01:13:43 +01:00
|
|
|
selected_etudid=None,
|
2023-06-20 12:14:16 +02:00
|
|
|
) -> tuple[str, TableRecap, collections.Counter]:
|
2023-02-12 01:13:43 +01:00
|
|
|
"""Le tableau recap en html"""
|
|
|
|
if tabformat not in ("html", "evals"):
|
|
|
|
raise ScoValueError("invalid table format")
|
|
|
|
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
2023-06-20 12:14:16 +02:00
|
|
|
table_html, table, freq_codes_annuels = gen_formsemestre_recapcomplet_html_table(
|
2023-02-12 01:13:43 +01:00
|
|
|
formsemestre,
|
|
|
|
res,
|
|
|
|
include_evaluations=(tabformat == "evals"),
|
|
|
|
mode_jury=mode_jury,
|
|
|
|
filename=filename,
|
|
|
|
selected_etudid=selected_etudid,
|
|
|
|
)
|
2023-06-20 12:14:16 +02:00
|
|
|
return table_html, table, freq_codes_annuels
|
2023-02-12 01:13:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
def _formsemestre_recapcomplet_to_file(
|
|
|
|
formsemestre: FormSemestre,
|
|
|
|
tabformat: str = "json", # xml, xls, xlsall, json
|
2023-03-12 12:30:57 +01:00
|
|
|
mode_jury: bool = False,
|
2023-02-12 01:13:43 +01:00
|
|
|
filename: str = "",
|
|
|
|
xml_nodate=False, # format XML sans dates (sert pour debug cache: comparaison de XML)
|
2020-09-26 16:19:37 +02:00
|
|
|
xml_with_decisions=False,
|
2020-12-12 17:22:54 +01:00
|
|
|
force_publishing=True,
|
2020-09-26 16:19:37 +02:00
|
|
|
):
|
2020-12-02 01:00:23 +01:00
|
|
|
"""Calcule et renvoie le tableau récapitulatif."""
|
2023-02-12 01:13:43 +01:00
|
|
|
if tabformat.startswith("xls"):
|
2023-03-12 12:30:57 +01:00
|
|
|
include_evaluations = tabformat == "xlsall"
|
2022-03-27 22:25:00 +02:00
|
|
|
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
2022-04-06 18:51:01 +02:00
|
|
|
data, filename = gen_formsemestre_recapcomplet_excel(
|
|
|
|
res,
|
2023-03-12 12:30:57 +01:00
|
|
|
mode_jury=mode_jury,
|
2022-04-06 18:51:01 +02:00
|
|
|
include_evaluations=include_evaluations,
|
|
|
|
filename=filename,
|
2021-09-16 00:15:10 +02:00
|
|
|
)
|
2023-03-12 12:30:57 +01:00
|
|
|
mime, suffix = scu.get_mime_suffix("xlsx")
|
2023-02-21 21:34:38 +01:00
|
|
|
return scu.send_file(data, filename=filename, mime=mime, suffix=suffix)
|
2023-02-12 01:13:43 +01:00
|
|
|
elif tabformat == "xml":
|
2022-04-06 18:51:01 +02:00
|
|
|
data = gen_formsemestre_recapcomplet_xml(
|
2023-02-12 01:13:43 +01:00
|
|
|
formsemestre.id,
|
2020-12-12 17:22:54 +01:00
|
|
|
xml_nodate,
|
|
|
|
xml_with_decisions=xml_with_decisions,
|
|
|
|
force_publishing=force_publishing,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2022-04-06 18:51:01 +02:00
|
|
|
return scu.send_file(data, filename=filename, suffix=scu.XML_SUFFIX)
|
2023-02-12 01:13:43 +01:00
|
|
|
elif tabformat == "json":
|
2022-04-06 18:51:01 +02:00
|
|
|
data = gen_formsemestre_recapcomplet_json(
|
2023-02-12 01:13:43 +01:00
|
|
|
formsemestre.id,
|
2020-12-12 17:22:54 +01:00
|
|
|
xml_nodate=xml_nodate,
|
|
|
|
xml_with_decisions=xml_with_decisions,
|
|
|
|
force_publishing=force_publishing,
|
2020-12-02 01:00:23 +01:00
|
|
|
)
|
2022-04-06 18:51:01 +02:00
|
|
|
return scu.sendJSON(data, filename=filename)
|
2022-03-23 22:30:22 +01:00
|
|
|
|
2023-02-12 01:13:43 +01:00
|
|
|
raise ScoValueError(f"Format demandé invalide: {tabformat}")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2022-04-06 18:51:01 +02:00
|
|
|
def gen_formsemestre_recapcomplet_xml(
|
2020-12-12 17:22:54 +01:00
|
|
|
formsemestre_id,
|
|
|
|
xml_nodate,
|
|
|
|
xml_with_decisions=False,
|
|
|
|
force_publishing=True,
|
2022-04-06 18:51:01 +02:00
|
|
|
) -> str:
|
2020-12-02 01:00:23 +01:00
|
|
|
"XML export: liste tous les bulletins XML."
|
2023-03-20 11:17:38 +01:00
|
|
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
2022-02-12 22:57:46 +01:00
|
|
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
2020-09-26 16:19:37 +02:00
|
|
|
T = nt.get_table_moyennes_triees()
|
|
|
|
if not T:
|
|
|
|
return "", "", "xml"
|
|
|
|
|
|
|
|
if xml_nodate:
|
|
|
|
docdate = ""
|
|
|
|
else:
|
|
|
|
docdate = datetime.datetime.now().isoformat()
|
2021-07-10 17:40:40 +02:00
|
|
|
doc = ElementTree.Element(
|
2021-08-22 17:18:15 +02:00
|
|
|
"recapsemestre", formsemestre_id=str(formsemestre_id), date=docdate
|
2021-07-10 17:40:40 +02:00
|
|
|
)
|
2021-07-29 10:19:00 +02:00
|
|
|
evals = sco_evaluations.do_evaluation_etat_in_sem(formsemestre_id)
|
2021-07-10 17:40:40 +02:00
|
|
|
doc.append(
|
|
|
|
ElementTree.Element(
|
|
|
|
"evals_info",
|
|
|
|
nb_evals_completes=str(evals["nb_evals_completes"]),
|
|
|
|
nb_evals_en_cours=str(evals["nb_evals_en_cours"]),
|
|
|
|
nb_evals_vides=str(evals["nb_evals_vides"]),
|
|
|
|
date_derniere_note=str(evals["last_modif"]),
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
for t in T:
|
|
|
|
etudid = t[-1]
|
|
|
|
sco_bulletins_xml.make_xml_formsemestre_bulletinetud(
|
|
|
|
formsemestre_id,
|
|
|
|
etudid,
|
|
|
|
doc=doc,
|
2020-12-12 17:22:54 +01:00
|
|
|
force_publishing=force_publishing,
|
2020-09-26 16:19:37 +02:00
|
|
|
xml_nodate=xml_nodate,
|
|
|
|
xml_with_decisions=xml_with_decisions,
|
|
|
|
)
|
2022-04-06 18:51:01 +02:00
|
|
|
return ElementTree.tostring(doc).decode(scu.SCO_ENCODING)
|
2020-12-02 01:00:23 +01:00
|
|
|
|
|
|
|
|
2022-04-06 18:51:01 +02:00
|
|
|
def gen_formsemestre_recapcomplet_json(
|
2020-12-12 17:22:54 +01:00
|
|
|
formsemestre_id,
|
|
|
|
xml_nodate=False,
|
|
|
|
xml_with_decisions=False,
|
|
|
|
force_publishing=True,
|
2022-04-06 18:51:01 +02:00
|
|
|
) -> dict:
|
2020-12-12 17:22:54 +01:00
|
|
|
"""JSON export: liste tous les bulletins JSON
|
|
|
|
:param xml_nodate(bool): indique la date courante (attribut docdate)
|
|
|
|
:param force_publishing: donne les bulletins même si non "publiés sur portail"
|
2022-04-06 18:51:01 +02:00
|
|
|
:returns: dict
|
2020-12-12 17:22:54 +01:00
|
|
|
"""
|
2023-03-20 11:17:38 +01:00
|
|
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
2021-12-17 21:59:28 +01:00
|
|
|
is_apc = formsemestre.formation.is_apc()
|
|
|
|
|
2020-12-02 01:00:23 +01:00
|
|
|
if xml_nodate:
|
|
|
|
docdate = ""
|
|
|
|
else:
|
|
|
|
docdate = datetime.datetime.now().isoformat()
|
2021-07-29 10:19:00 +02:00
|
|
|
evals = sco_evaluations.do_evaluation_etat_in_sem(formsemestre_id)
|
2022-04-06 18:51:01 +02:00
|
|
|
js_data = {
|
2020-12-02 01:00:23 +01:00
|
|
|
"docdate": docdate,
|
|
|
|
"formsemestre_id": formsemestre_id,
|
|
|
|
"evals_info": {
|
|
|
|
"nb_evals_completes": evals["nb_evals_completes"],
|
|
|
|
"nb_evals_en_cours": evals["nb_evals_en_cours"],
|
|
|
|
"nb_evals_vides": evals["nb_evals_vides"],
|
|
|
|
"date_derniere_note": evals["last_modif"],
|
|
|
|
},
|
|
|
|
"bulletins": [],
|
|
|
|
}
|
2022-04-06 18:51:01 +02:00
|
|
|
bulletins = js_data["bulletins"]
|
2023-03-20 11:17:38 +01:00
|
|
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
2022-02-12 22:57:46 +01:00
|
|
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
2020-12-02 01:00:23 +01:00
|
|
|
T = nt.get_table_moyennes_triees()
|
|
|
|
for t in T:
|
|
|
|
etudid = t[-1]
|
2021-12-17 21:59:28 +01:00
|
|
|
if is_apc:
|
2023-03-20 11:17:38 +01:00
|
|
|
etud = Identite.get_etud(etudid)
|
2023-03-18 21:56:08 +01:00
|
|
|
bulletins_sem = bulletin_but.BulletinBUT(formsemestre)
|
2023-09-01 14:38:41 +02:00
|
|
|
bul = bulletins_sem.bulletin_etud(etud)
|
2021-12-17 21:59:28 +01:00
|
|
|
else:
|
|
|
|
bul = sco_bulletins_json.formsemestre_bulletinetud_published_dict(
|
2020-12-02 01:00:23 +01:00
|
|
|
formsemestre_id,
|
|
|
|
etudid,
|
2020-12-12 17:22:54 +01:00
|
|
|
force_publishing=force_publishing,
|
2020-12-02 01:00:23 +01:00
|
|
|
xml_with_decisions=xml_with_decisions,
|
|
|
|
)
|
2021-12-17 21:59:28 +01:00
|
|
|
bulletins.append(bul)
|
2022-04-06 18:51:01 +02:00
|
|
|
return js_data
|
2020-12-12 17:22:54 +01:00
|
|
|
|
|
|
|
|
2021-09-27 10:20:10 +02:00
|
|
|
def formsemestres_bulletins(annee_scolaire):
|
2020-12-12 17:22:54 +01:00
|
|
|
"""Tous les bulletins des semestres publiés des semestres de l'année indiquée.
|
2022-02-09 23:22:00 +01:00
|
|
|
:param annee_scolaire(int): année de début de l'année scolaire
|
2020-12-12 17:22:54 +01:00
|
|
|
:returns: JSON
|
|
|
|
"""
|
2022-04-06 18:51:01 +02:00
|
|
|
js_list = []
|
2021-08-19 10:28:35 +02:00
|
|
|
sems = sco_formsemestre.list_formsemestre_by_etape(annee_scolaire=annee_scolaire)
|
2020-12-12 17:22:54 +01:00
|
|
|
log("formsemestres_bulletins(%s): %d sems" % (annee_scolaire, len(sems)))
|
|
|
|
for sem in sems:
|
2022-04-06 18:51:01 +02:00
|
|
|
js_data = gen_formsemestre_recapcomplet_json(
|
2021-08-21 00:24:51 +02:00
|
|
|
sem["formsemestre_id"], force_publishing=False
|
2020-12-12 17:22:54 +01:00
|
|
|
)
|
2022-04-06 18:51:01 +02:00
|
|
|
js_list.append(js_data)
|
2020-12-12 17:22:54 +01:00
|
|
|
|
2022-04-06 18:51:01 +02:00
|
|
|
return scu.sendJSON(js_list)
|
2022-03-26 23:33:57 +01:00
|
|
|
|
|
|
|
|
2023-02-12 01:13:43 +01:00
|
|
|
def gen_formsemestre_recapcomplet_html_table(
|
2022-04-06 18:51:01 +02:00
|
|
|
formsemestre: FormSemestre,
|
|
|
|
res: NotesTableCompat,
|
|
|
|
include_evaluations=False,
|
2022-06-29 16:30:01 +02:00
|
|
|
mode_jury=False,
|
2022-04-06 18:51:01 +02:00
|
|
|
filename="",
|
2022-04-07 23:31:08 +02:00
|
|
|
selected_etudid=None,
|
2023-06-20 12:14:16 +02:00
|
|
|
) -> tuple[str, TableRecap, collections.Counter]:
|
2022-03-26 23:33:57 +01:00
|
|
|
"""Construit table recap pour le BUT
|
2023-06-20 12:14:16 +02:00
|
|
|
Cache le résultat pour le semestre.
|
2023-02-12 01:13:43 +01:00
|
|
|
Note: on cache le HTML et non l'objet Table.
|
|
|
|
|
|
|
|
Si mode_jury, occultera colonnes modules (en js)
|
|
|
|
et affiche un lien vers la saisie de la décision de jury
|
2022-04-07 23:31:08 +02:00
|
|
|
|
2023-02-12 01:13:43 +01:00
|
|
|
Return: html (str), table (None sauf en mode jury ou si pas cachée)
|
2022-04-07 23:31:08 +02:00
|
|
|
|
2023-02-12 01:13:43 +01:00
|
|
|
html est une chaine, le <div>...</div> incluant le tableau.
|
2022-03-26 23:33:57 +01:00
|
|
|
"""
|
2023-02-12 01:13:43 +01:00
|
|
|
table = None
|
2022-04-07 23:31:08 +02:00
|
|
|
table_html = None
|
2023-06-20 12:14:16 +02:00
|
|
|
table_html_cached = None
|
2023-02-21 01:07:21 +01:00
|
|
|
cache_class = {
|
|
|
|
(True, True): sco_cache.TableJuryWithEvalsCache,
|
|
|
|
(True, False): sco_cache.TableJuryCache,
|
|
|
|
(False, True): sco_cache.TableRecapWithEvalsCache,
|
|
|
|
(False, False): sco_cache.TableRecapCache,
|
|
|
|
}[(bool(mode_jury), bool(include_evaluations))]
|
2023-02-21 00:45:27 +01:00
|
|
|
if not selected_etudid:
|
2023-06-20 12:14:16 +02:00
|
|
|
table_html_cached = cache_class.get(formsemestre.id)
|
|
|
|
if table_html_cached is None:
|
2023-02-12 01:13:43 +01:00
|
|
|
table = _gen_formsemestre_recapcomplet_table(
|
2022-04-07 23:31:08 +02:00
|
|
|
res,
|
|
|
|
include_evaluations,
|
2022-06-29 16:30:01 +02:00
|
|
|
mode_jury,
|
2022-04-07 23:31:08 +02:00
|
|
|
filename,
|
|
|
|
selected_etudid=selected_etudid,
|
|
|
|
)
|
2023-02-12 01:13:43 +01:00
|
|
|
table_html = table.html()
|
2023-06-20 12:14:16 +02:00
|
|
|
freq_codes_annuels = (
|
|
|
|
table.freq_codes_annuels if hasattr(table, "freq_codes_annuels") else None
|
|
|
|
)
|
|
|
|
cache_class.set(formsemestre.id, (table_html, freq_codes_annuels))
|
|
|
|
else:
|
|
|
|
table_html, freq_codes_annuels = table_html_cached
|
2022-04-05 22:23:55 +02:00
|
|
|
|
2023-06-20 12:14:16 +02:00
|
|
|
return table_html, table, freq_codes_annuels
|
2022-04-05 22:23:55 +02:00
|
|
|
|
|
|
|
|
2023-02-12 01:13:43 +01:00
|
|
|
def _gen_formsemestre_recapcomplet_table(
|
2023-01-18 18:25:40 +01:00
|
|
|
res: ResultatsSemestre,
|
2022-04-05 22:23:55 +02:00
|
|
|
include_evaluations=False,
|
2022-06-29 16:30:01 +02:00
|
|
|
mode_jury=False,
|
2023-03-12 12:30:57 +01:00
|
|
|
convert_values: bool = True,
|
2022-04-05 22:23:55 +02:00
|
|
|
filename: str = "",
|
2022-04-07 23:31:08 +02:00
|
|
|
selected_etudid=None,
|
2023-02-12 01:13:43 +01:00
|
|
|
) -> TableRecap:
|
|
|
|
"""Construit la table récap."""
|
2023-02-05 23:15:50 +01:00
|
|
|
table_class = TableJury if mode_jury else TableRecap
|
|
|
|
table = table_class(
|
2023-02-03 22:39:45 +01:00
|
|
|
res,
|
2023-03-12 12:30:57 +01:00
|
|
|
convert_values=convert_values,
|
2022-06-29 16:30:01 +02:00
|
|
|
include_evaluations=include_evaluations,
|
|
|
|
mode_jury=mode_jury,
|
2023-03-12 12:30:57 +01:00
|
|
|
read_only=not res.formsemestre.can_edit_jury(),
|
2022-04-04 09:35:52 +02:00
|
|
|
)
|
2023-02-03 22:39:45 +01:00
|
|
|
|
2023-01-29 21:52:39 +01:00
|
|
|
table.data["filename"] = filename
|
|
|
|
table.select_row(selected_etudid)
|
2023-02-12 01:13:43 +01:00
|
|
|
return table
|
2022-04-06 18:51:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
def gen_formsemestre_recapcomplet_excel(
|
|
|
|
res: NotesTableCompat,
|
2023-03-12 12:30:57 +01:00
|
|
|
mode_jury: bool = False,
|
2022-04-06 18:51:01 +02:00
|
|
|
include_evaluations=False,
|
|
|
|
filename: str = "",
|
|
|
|
) -> tuple:
|
2023-03-12 12:30:57 +01:00
|
|
|
"""Génère le tableau recap ou jury en excel (xlsx).
|
|
|
|
Utilisé pour menu (export excel), archives et autres besoins particuliers (API).
|
2022-04-06 18:51:01 +02:00
|
|
|
Attention: le tableau exporté depuis la page html est celui généré en js par DataTables,
|
|
|
|
et non celui-ci.
|
|
|
|
"""
|
2023-03-12 12:30:57 +01:00
|
|
|
table = _gen_formsemestre_recapcomplet_table(
|
2023-02-03 22:39:45 +01:00
|
|
|
res,
|
|
|
|
include_evaluations=include_evaluations,
|
2023-03-12 12:30:57 +01:00
|
|
|
mode_jury=mode_jury,
|
|
|
|
convert_values=False,
|
|
|
|
filename=filename,
|
2022-04-06 18:51:01 +02:00
|
|
|
)
|
|
|
|
|
2023-02-06 10:58:36 +01:00
|
|
|
return table.excel(), filename
|