2020-09-26 16:19:37 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2023-12-31 23:04:06 +01:00
|
|
|
# Copyright (c) 1999 - 2024 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
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Opérations d'inscriptions aux modules (interface pour gérer options ou parcours)
|
|
|
|
"""
|
2023-03-08 22:23:55 +01:00
|
|
|
import collections
|
2023-06-07 18:43:44 +02:00
|
|
|
from operator import attrgetter
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-08-01 10:16:16 +02:00
|
|
|
import flask
|
2021-09-18 10:10:02 +02:00
|
|
|
from flask import url_for, g, request
|
2021-09-18 13:42:19 +02:00
|
|
|
from flask_login import current_user
|
2021-07-11 17:37:12 +02:00
|
|
|
|
2023-07-11 06:57:38 +02:00
|
|
|
from app import db, log
|
2022-02-13 15:50:16 +01:00
|
|
|
from app.comp import res_sem
|
2022-03-27 22:25:00 +02:00
|
|
|
from app.comp.res_compat import NotesTableCompat
|
2023-03-27 18:30:36 +02:00
|
|
|
from app.models import (
|
|
|
|
FormSemestre,
|
|
|
|
Identite,
|
2024-01-16 11:11:00 +01:00
|
|
|
ModuleImpl,
|
2023-03-27 18:30:36 +02:00
|
|
|
Partition,
|
|
|
|
ScolarFormSemestreValidation,
|
|
|
|
UniteEns,
|
2024-07-08 23:13:45 +02:00
|
|
|
Scolog,
|
2023-03-27 18:30:36 +02:00
|
|
|
)
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import html_sco_header
|
|
|
|
from app.scodoc import htmlutils
|
2023-01-23 11:05:06 +01:00
|
|
|
from app.scodoc import sco_cache
|
2023-02-12 13:36:47 +01:00
|
|
|
from app.scodoc import codes_cursus
|
2022-09-03 11:41:56 +02:00
|
|
|
from app.scodoc import sco_etud
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_formsemestre_inscriptions
|
|
|
|
from app.scodoc import sco_groups
|
|
|
|
from app.scodoc import sco_moduleimpl
|
2023-01-13 23:23:18 +01:00
|
|
|
import app.scodoc.notesdb as ndb
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc.sco_exceptions import ScoValueError
|
|
|
|
from app.scodoc.sco_permissions import Permission
|
2023-01-13 23:23:18 +01:00
|
|
|
import app.scodoc.sco_utils as scu
|
2023-07-11 06:57:38 +02:00
|
|
|
from app.tables import list_etuds
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2024-01-16 11:11:00 +01:00
|
|
|
def moduleimpl_inscriptions_edit(
|
|
|
|
moduleimpl_id, etudids: list[int] | None = None, submitted=False
|
|
|
|
):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Formulaire inscription des etudiants a ce module
|
|
|
|
* Gestion des inscriptions
|
|
|
|
Nom TD TA TP (triable)
|
|
|
|
[x] M. XXX YYY - - -
|
2021-01-01 17:46:05 +01:00
|
|
|
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
ajouter TD A, TD B, TP 1, TP 2 ...
|
|
|
|
supprimer TD A, TD B, TP 1, TP 2 ...
|
2021-01-01 17:46:05 +01:00
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
* Si pas les droits: idem en readonly
|
|
|
|
"""
|
2024-01-16 11:11:00 +01:00
|
|
|
etudids = etudids or []
|
|
|
|
modimpl = ModuleImpl.get_modimpl(moduleimpl_id)
|
|
|
|
module = modimpl.module
|
|
|
|
formsemestre = modimpl.formsemestre
|
2024-06-13 22:03:17 +02:00
|
|
|
# -- check permission (and lock)
|
|
|
|
if not modimpl.can_change_inscriptions():
|
|
|
|
return # can_change_inscriptions raises exception
|
2021-06-13 23:37:14 +02:00
|
|
|
header = html_sco_header.sco_header(
|
2020-09-26 16:19:37 +02:00
|
|
|
page_title="Inscription au module",
|
|
|
|
javascripts=["js/etud_info.js"],
|
|
|
|
)
|
2021-07-29 10:19:00 +02:00
|
|
|
footer = html_sco_header.sco_footer()
|
2020-09-26 16:19:37 +02:00
|
|
|
H = [
|
|
|
|
header,
|
2024-01-16 11:11:00 +01:00
|
|
|
f"""<h2>Inscriptions au module <a class="stdlink" href="{
|
|
|
|
url_for("notes.moduleimpl_status", scodoc_dept=g.scodoc_dept,
|
|
|
|
moduleimpl_id=moduleimpl_id)
|
|
|
|
}">{module.titre or "(module sans titre)"}</a> ({module.code})</a></h2>
|
2020-09-26 16:19:37 +02:00
|
|
|
<p class="help">Cette page permet d'éditer les étudiants inscrits à ce module
|
|
|
|
(ils doivent évidemment être inscrits au semestre).
|
2024-01-16 11:11:00 +01:00
|
|
|
Les étudiants cochés sont (ou seront) inscrits. Vous pouvez inscrire ou
|
2020-09-26 16:19:37 +02:00
|
|
|
désinscrire tous les étudiants d'un groupe à l'aide des menus "Ajouter" et "Enlever".
|
|
|
|
</p>
|
2024-01-16 11:11:00 +01:00
|
|
|
<p class="help">Aucune modification n'est prise en compte tant que l'on n'appuie pas
|
|
|
|
sur le bouton "Appliquer les modifications".
|
2020-09-26 16:19:37 +02:00
|
|
|
</p>
|
2024-01-16 11:11:00 +01:00
|
|
|
""",
|
2020-09-26 16:19:37 +02:00
|
|
|
]
|
|
|
|
# Liste des inscrits à ce semestre
|
2021-06-21 10:17:16 +02:00
|
|
|
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
|
2024-01-16 11:11:00 +01:00
|
|
|
formsemestre.id
|
2021-06-21 10:17:16 +02:00
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
for ins in inscrits:
|
2021-06-19 23:21:37 +02:00
|
|
|
etuds_info = sco_etud.get_etud_info(etudid=ins["etudid"], filled=1)
|
2020-09-26 16:19:37 +02:00
|
|
|
if not etuds_info:
|
|
|
|
log(
|
2022-09-03 11:41:56 +02:00
|
|
|
f"""moduleimpl_inscriptions_edit: inconsistency for etudid={ins['etudid']} !"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
raise ScoValueError(
|
2022-09-03 11:41:56 +02:00
|
|
|
f"""Étudiant {ins['etudid']} inscrit mais inconnu dans la base !"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
ins["etud"] = etuds_info[0]
|
2022-09-03 11:41:56 +02:00
|
|
|
inscrits.sort(key=lambda inscr: sco_etud.etud_sort_key(inscr["etud"]))
|
2024-01-16 11:11:00 +01:00
|
|
|
in_m = sco_moduleimpl.do_moduleimpl_inscription_list(moduleimpl_id=modimpl.id)
|
|
|
|
in_module = {x["etudid"] for x in in_m}
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
2024-01-16 11:11:00 +01:00
|
|
|
partitions = sco_groups.get_partitions_list(formsemestre.id)
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
if not submitted:
|
|
|
|
H.append(
|
|
|
|
"""<script type="text/javascript">
|
|
|
|
function group_select(groupName, partitionIdx, check) {
|
|
|
|
var nb_inputs_to_skip = 2; // nb d'input avant les checkbox !!!
|
|
|
|
var elems = document.getElementById("mi_form").getElementsByTagName("input");
|
|
|
|
|
|
|
|
if (partitionIdx==-1) {
|
|
|
|
for (var i =nb_inputs_to_skip; i < elems.length; i++) {
|
2024-08-06 22:30:30 +02:00
|
|
|
elems[i].checked=check;
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (var i =nb_inputs_to_skip; i < elems.length; i++) {
|
2024-08-06 22:30:30 +02:00
|
|
|
let tds = elems[i].parentNode.parentNode.getElementsByTagName("td");
|
|
|
|
var cells = tds[partitionIdx].childNodes;
|
|
|
|
if (cells.length && cells[0].nodeValue == groupName) {
|
|
|
|
elems[i].checked=check;
|
|
|
|
}
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-16 11:11:00 +01:00
|
|
|
</script>
|
|
|
|
<style>
|
|
|
|
table.mi_table td, table.mi_table th {
|
|
|
|
text-align: left;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
H.append(
|
2022-09-03 11:41:56 +02:00
|
|
|
f"""<form method="post" id="mi_form" action="{request.base_url}">
|
2024-01-16 11:11:00 +01:00
|
|
|
<input type="hidden" name="moduleimpl_id" value="{modimpl.id}"/>
|
2022-09-03 11:41:56 +02:00
|
|
|
<input type="submit" name="submitted" value="Appliquer les modifications"/>
|
2024-01-16 11:11:00 +01:00
|
|
|
<div>
|
|
|
|
{ _make_menu(partitions, "Ajouter", "true") }
|
|
|
|
{ _make_menu(partitions, "Enlever", "false")}
|
|
|
|
</div>
|
|
|
|
<table class="gt_table mi_table">
|
|
|
|
<thead>
|
2022-09-03 11:41:56 +02:00
|
|
|
<tr>
|
2024-01-16 11:11:00 +01:00
|
|
|
<th class="etud">Nom</th>
|
2022-09-03 11:41:56 +02:00
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
for partition in partitions:
|
|
|
|
if partition["partition_name"]:
|
2024-01-16 11:11:00 +01:00
|
|
|
H.append(f"<th>{partition['partition_name']}</th>")
|
|
|
|
H.append("</tr></thead><tbody>")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
for ins in inscrits:
|
|
|
|
etud = ins["etud"]
|
|
|
|
if etud["etudid"] in in_module:
|
|
|
|
checked = 'checked="checked"'
|
|
|
|
else:
|
|
|
|
checked = ""
|
|
|
|
H.append(
|
2024-08-06 22:30:30 +02:00
|
|
|
f"""<tr><td class="etud">
|
|
|
|
<input type="checkbox" name="etudids:list" value="{etud['etudid']}" {checked}>
|
|
|
|
<a class="discretelink etudinfo" href="{
|
|
|
|
url_for(
|
|
|
|
"scolar.fiche_etud",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
etudid=etud["etudid"],
|
|
|
|
)
|
|
|
|
}" id="{etud['etudid']}">{etud['nomprenom']}</a>
|
|
|
|
</input>
|
|
|
|
</td>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2024-01-16 11:11:00 +01:00
|
|
|
groups = sco_groups.get_etud_groups(etud["etudid"], formsemestre.id)
|
2020-09-26 16:19:37 +02:00
|
|
|
for partition in partitions:
|
|
|
|
if partition["partition_name"]:
|
|
|
|
gr_name = ""
|
|
|
|
for group in groups:
|
|
|
|
if group["partition_id"] == partition["partition_id"]:
|
|
|
|
gr_name = group["group_name"]
|
|
|
|
break
|
|
|
|
# gr_name == '' si etud non inscrit dans un groupe de cette partition
|
2022-09-03 11:41:56 +02:00
|
|
|
H.append(f"<td>{gr_name}</td>")
|
2024-01-16 11:11:00 +01:00
|
|
|
H.append("""</tbody></table></form>""")
|
2020-09-26 16:19:37 +02:00
|
|
|
else: # SUBMISSION
|
|
|
|
# inscrit a ce module tous les etuds selectionnes
|
2021-01-17 22:31:28 +01:00
|
|
|
sco_moduleimpl.do_moduleimpl_inscrit_etuds(
|
2024-01-16 11:11:00 +01:00
|
|
|
moduleimpl_id, formsemestre.id, etudids, reset=True
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2022-09-03 11:41:56 +02:00
|
|
|
return flask.redirect(
|
|
|
|
url_for(
|
|
|
|
"notes.moduleimpl_status",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
moduleimpl_id=moduleimpl_id,
|
|
|
|
)
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
H.append(footer)
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2022-08-31 19:14:21 +02:00
|
|
|
def _make_menu(partitions: list[dict], title="", check="true") -> str:
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Menu with list of all groups"""
|
2024-01-16 11:11:00 +01:00
|
|
|
items = [{"title": "Tous", "attr": f"onclick=\"group_select('', -1, {check})\""}]
|
2020-09-26 16:19:37 +02:00
|
|
|
p_idx = 0
|
|
|
|
for partition in partitions:
|
2024-01-16 11:11:00 +01:00
|
|
|
if partition["partition_name"] is not None:
|
2020-09-26 16:19:37 +02:00
|
|
|
p_idx += 1
|
2021-08-19 10:28:35 +02:00
|
|
|
for group in sco_groups.get_partition_groups(partition):
|
2020-09-26 16:19:37 +02:00
|
|
|
items.append(
|
|
|
|
{
|
2021-01-01 17:46:05 +01:00
|
|
|
"title": "%s %s"
|
|
|
|
% (partition["partition_name"], group["group_name"]),
|
|
|
|
"attr": "onclick=\"group_select('%s', %s, %s)\""
|
|
|
|
% (group["group_name"], p_idx, check),
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
)
|
2021-01-01 17:46:05 +01:00
|
|
|
return (
|
2024-01-16 11:11:00 +01:00
|
|
|
'<div class="inscr_addremove_menu">'
|
2021-06-14 18:08:52 +02:00
|
|
|
+ htmlutils.make_menu(title, items, alone=True)
|
2024-01-16 11:11:00 +01:00
|
|
|
+ "</div>"
|
2021-01-01 17:46:05 +01:00
|
|
|
)
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-09-27 10:20:10 +02:00
|
|
|
def moduleimpl_inscriptions_stats(formsemestre_id):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Affiche quelques informations sur les inscriptions
|
|
|
|
aux modules de ce semestre.
|
|
|
|
|
|
|
|
Inscrits au semestre: <nb>
|
|
|
|
|
|
|
|
Modules communs (tous inscrits): <liste des modules (codes)
|
|
|
|
|
|
|
|
Autres modules: (regroupés par UE)
|
|
|
|
UE 1
|
|
|
|
<code du module>: <nb inscrits> (<description en termes de groupes>)
|
|
|
|
...
|
|
|
|
|
2022-11-08 00:19:50 +01:00
|
|
|
En APC, n'affiche pas la colonne UE, car le rattachement n'a pas
|
|
|
|
d'importance pédagogique.
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
descriptions:
|
|
|
|
groupes de TD A, B et C
|
|
|
|
tous sauf groupe de TP Z (?)
|
|
|
|
tous sauf <liste d'au plus 7 noms>
|
2021-01-01 17:46:05 +01:00
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2021-09-18 13:42:19 +02:00
|
|
|
authuser = current_user
|
2023-03-20 11:17:38 +01:00
|
|
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
2022-12-01 13:00:14 +01:00
|
|
|
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
2022-08-31 19:14:21 +02:00
|
|
|
is_apc = formsemestre.formation.is_apc()
|
2021-06-19 23:21:37 +02:00
|
|
|
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
|
2021-08-19 10:28:35 +02:00
|
|
|
args={"formsemestre_id": formsemestre_id}
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
set_all = set([x["etudid"] for x in inscrits])
|
2022-08-31 19:20:40 +02:00
|
|
|
partitions, _ = sco_groups.get_formsemestre_groups(formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2023-09-29 21:17:31 +02:00
|
|
|
can_change = authuser.has_permission(Permission.EtudInscrit) and formsemestre.etat
|
2022-08-31 19:14:21 +02:00
|
|
|
|
|
|
|
# Décrit les inscriptions aux modules:
|
2020-09-26 16:19:37 +02:00
|
|
|
commons = [] # modules communs a tous les etuds du semestre
|
|
|
|
options = [] # modules ou seuls quelques etudiants sont inscrits
|
2022-08-31 19:14:21 +02:00
|
|
|
mod_description = {} # modimplid : str
|
|
|
|
mod_nb_inscrits = {} # modimplid : int
|
2022-08-31 19:20:40 +02:00
|
|
|
if is_apc:
|
|
|
|
modimpls = sorted(formsemestre.modimpls, key=lambda m: m.module.sort_key_apc())
|
|
|
|
else:
|
|
|
|
modimpls = formsemestre.modimpls_sorted
|
|
|
|
for modimpl in modimpls:
|
2021-01-01 17:46:05 +01:00
|
|
|
tous_inscrits, nb_inscrits, descr = descr_inscrs_module(
|
2022-08-31 19:14:21 +02:00
|
|
|
modimpl.id,
|
2020-09-26 16:19:37 +02:00
|
|
|
set_all,
|
|
|
|
partitions,
|
|
|
|
)
|
2021-01-01 17:46:05 +01:00
|
|
|
if tous_inscrits:
|
2022-08-31 19:14:21 +02:00
|
|
|
commons.append(modimpl)
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2022-08-31 19:14:21 +02:00
|
|
|
mod_description[modimpl.id] = descr
|
|
|
|
mod_nb_inscrits[modimpl.id] = nb_inscrits
|
|
|
|
options.append(modimpl)
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
# Page HTML:
|
2023-01-12 17:08:39 +01:00
|
|
|
H = [
|
|
|
|
html_sco_header.html_sem_header(
|
|
|
|
"Inscriptions aux modules et UE du semestre",
|
|
|
|
javascripts=["js/etud_info.js", "js/moduleimpl_inscriptions_stats.js"],
|
|
|
|
)
|
|
|
|
]
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-08-31 19:14:21 +02:00
|
|
|
H.append(f"<h3>Inscrits au semestre: {len(inscrits)} étudiants</h3>")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if options:
|
|
|
|
H.append("<h3>Modules auxquels tous les étudiants ne sont pas inscrits:</h3>")
|
|
|
|
H.append(
|
2022-11-08 00:19:50 +01:00
|
|
|
f"""<table class="formsemestre_status formsemestre_inscr">
|
|
|
|
<tr>
|
|
|
|
{'<th>UE</th>' if not is_apc else ""}
|
|
|
|
<th>Code</th>
|
2024-02-09 15:36:37 +01:00
|
|
|
<th>Module</th>
|
2022-11-08 00:19:50 +01:00
|
|
|
<th>Inscrits</th>
|
|
|
|
<th></th>
|
|
|
|
</tr>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2022-08-31 19:14:21 +02:00
|
|
|
for modimpl in options:
|
2020-09-26 16:19:37 +02:00
|
|
|
if can_change:
|
2022-08-31 19:14:21 +02:00
|
|
|
c_link = f"""<a class="discretelink" href="{url_for(
|
|
|
|
'notes.moduleimpl_inscriptions_edit',
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
moduleimpl_id=modimpl.id)
|
|
|
|
}">{mod_description[modimpl.id] or "<i>(inscrire des étudiants)</i>"}</a>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2022-08-31 19:14:21 +02:00
|
|
|
c_link = mod_description[modimpl.id]
|
2022-11-08 00:19:50 +01:00
|
|
|
H.append("""<tr class="formsemestre_status">""")
|
|
|
|
if not is_apc:
|
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<td>{
|
|
|
|
modimpl.module.ue.acronyme or ""
|
|
|
|
}</td>
|
|
|
|
"""
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append(
|
2022-11-08 00:19:50 +01:00
|
|
|
f"""
|
|
|
|
<td class="formsemestre_status_code">{
|
2022-08-31 19:14:21 +02:00
|
|
|
modimpl.module.code or "(module sans code)"
|
2022-11-08 00:19:50 +01:00
|
|
|
}</td>
|
2024-02-09 15:36:37 +01:00
|
|
|
<td class="formsemestre_status_module">{modimpl.module.titre or ""}</td>
|
2022-11-08 00:19:50 +01:00
|
|
|
<td class="formsemestre_status_inscrits">{
|
|
|
|
mod_nb_inscrits[modimpl.id]}</td><td>{c_link}</td>
|
|
|
|
</tr>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
H.append("</table>")
|
|
|
|
else:
|
|
|
|
H.append(
|
2022-08-31 19:14:21 +02:00
|
|
|
"""<span style="font-size:110%; font-style:italic; color: red;"
|
|
|
|
>Tous les étudiants sont inscrits à tous les modules.</span>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if commons:
|
|
|
|
H.append(
|
2022-11-08 00:19:50 +01:00
|
|
|
f"""<h3>Modules communs (auxquels tous les étudiants sont inscrits):</h3>
|
2022-08-31 19:14:21 +02:00
|
|
|
|
|
|
|
<table class="formsemestre_status formsemestre_inscr">
|
2022-11-08 00:19:50 +01:00
|
|
|
<tr>
|
|
|
|
{'<th>UE</th>' if not is_apc else ""}
|
|
|
|
<th>Code</th>
|
|
|
|
<th>Module</th>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2022-08-31 19:14:21 +02:00
|
|
|
if is_apc:
|
|
|
|
H.append("<th>Parcours</th>")
|
|
|
|
H.append("""</tr>""")
|
|
|
|
for modimpl in commons:
|
2020-09-26 16:19:37 +02:00
|
|
|
if can_change:
|
2022-08-31 19:14:21 +02:00
|
|
|
c_link = f"""<a class="discretelink" href="{
|
|
|
|
url_for("notes.moduleimpl_inscriptions_edit",
|
|
|
|
scodoc_dept=g.scodoc_dept, moduleimpl_id=modimpl.id)
|
|
|
|
}">{modimpl.module.titre}</a>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
else:
|
2022-08-31 19:14:21 +02:00
|
|
|
c_link = modimpl.module.titre
|
2022-11-08 00:19:50 +01:00
|
|
|
H.append("""<tr class="formsemestre_status_green">""")
|
|
|
|
if not is_apc:
|
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<td>{modimpl.module.ue.acronyme or ""}</td>
|
|
|
|
"""
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append(
|
2022-11-08 00:19:50 +01:00
|
|
|
f"""
|
|
|
|
<td class="formsemestre_status_code">{
|
2022-08-31 19:14:21 +02:00
|
|
|
modimpl.module.code or "(module sans code)"
|
|
|
|
}</td><td>{c_link}</td>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2022-08-31 19:14:21 +02:00
|
|
|
if is_apc:
|
|
|
|
H.append(
|
|
|
|
f"""<td><em>{', '.join(p.code for p in modimpl.module.parcours)}</em></td>"""
|
|
|
|
)
|
|
|
|
H.append("</tr>")
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("</table>")
|
|
|
|
|
|
|
|
# Etudiants "dispensés" d'une UE (capitalisée)
|
2022-12-01 13:00:14 +01:00
|
|
|
ues_cap_info = get_etuds_with_capitalized_ue(formsemestre_id)
|
|
|
|
if ues_cap_info:
|
2023-01-12 17:08:39 +01:00
|
|
|
H.append(
|
|
|
|
'<h3>Étudiants avec UEs capitalisées (ADM):</h3><ul class="ue_inscr_list">'
|
|
|
|
)
|
2024-02-14 21:45:58 +01:00
|
|
|
ues = [UniteEns.query.get_or_404(ue_id) for ue_id in ues_cap_info.keys()]
|
|
|
|
ues.sort(key=lambda u: u.numero)
|
2020-09-26 16:19:37 +02:00
|
|
|
for ue in ues:
|
|
|
|
H.append(
|
2024-02-14 21:45:58 +01:00
|
|
|
f"""<li class="tit"><span class="tit">{ue.acronyme}: {ue.titre or ''}</span>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
H.append("<ul>")
|
2024-02-14 21:45:58 +01:00
|
|
|
for info in ues_cap_info[ue.id]:
|
|
|
|
etud = Identite.get_etud(info["etudid"])
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append(
|
2024-01-23 20:09:13 +01:00
|
|
|
f"""<li class="etud"><a class="discretelink etudinfo"
|
2024-02-14 21:45:58 +01:00
|
|
|
id="{etud.id}"
|
2024-01-23 20:09:13 +01:00
|
|
|
href="{
|
2021-07-11 17:37:12 +02:00
|
|
|
url_for(
|
2024-01-20 14:49:36 +01:00
|
|
|
"scolar.fiche_etud",
|
2021-07-11 17:37:12 +02:00
|
|
|
scodoc_dept=g.scodoc_dept,
|
2024-02-14 21:45:58 +01:00
|
|
|
etudid=etud.id,
|
2022-12-01 13:00:14 +01:00
|
|
|
)
|
2024-02-14 21:45:58 +01:00
|
|
|
}">{etud.nomprenom}</a>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
if info["ue_status"]["event_date"]:
|
|
|
|
H.append(
|
2024-04-02 23:37:23 +02:00
|
|
|
f"""(cap. le {info["ue_status"]["event_date"].strftime(scu.DATE_FMT)})"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2022-12-01 13:00:14 +01:00
|
|
|
if is_apc:
|
2024-02-14 21:45:58 +01:00
|
|
|
is_inscrit_ue = (etud.id, ue.id) not in res.dispense_ues
|
2022-12-01 13:00:14 +01:00
|
|
|
else:
|
|
|
|
# CLASSIQUE
|
|
|
|
is_inscrit_ue = info["is_ins"]
|
|
|
|
if is_inscrit_ue:
|
|
|
|
dm = ", ".join(
|
|
|
|
[
|
|
|
|
m["code"] or m["abbrev"] or "pas_de_code"
|
|
|
|
for m in info["is_ins"]
|
|
|
|
]
|
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
f"""actuellement inscrit dans <a title="{dm}" class="discretelink"
|
|
|
|
>{len(info["is_ins"])} modules</a>"""
|
|
|
|
)
|
|
|
|
if is_inscrit_ue:
|
2020-09-26 16:19:37 +02:00
|
|
|
if info["ue_status"]["is_capitalized"]:
|
|
|
|
H.append(
|
2022-12-01 13:00:14 +01:00
|
|
|
"""<div><em style="font-size: 70%">UE actuelle moins bonne que
|
|
|
|
l'UE capitalisée</em>
|
|
|
|
</div>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append(
|
2022-12-01 13:00:14 +01:00
|
|
|
"""<div><em style="font-size: 70%">UE actuelle meilleure que
|
|
|
|
l'UE capitalisée</em>
|
|
|
|
</div>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
if can_change:
|
|
|
|
H.append(
|
2022-12-01 13:00:14 +01:00
|
|
|
f"""<div><a class="stdlink" href="{
|
|
|
|
url_for("notes.etud_desinscrit_ue",
|
2024-02-14 21:45:58 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, etudid=etud.id,
|
|
|
|
formsemestre_id=formsemestre_id, ue_id=ue.id)
|
2022-12-01 13:00:14 +01:00
|
|
|
}">désinscrire {"des modules" if not is_apc else ""} de cette UE</a></div>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append("(non réinscrit dans cette UE)")
|
|
|
|
if can_change:
|
|
|
|
H.append(
|
2022-12-01 13:00:14 +01:00
|
|
|
f"""<div><a class="stdlink" href="{
|
2023-12-31 23:04:06 +01:00
|
|
|
url_for("notes.etud_inscrit_ue",
|
2024-02-14 21:45:58 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, etudid=etud.id,
|
|
|
|
formsemestre_id=formsemestre_id, ue_id=ue.id)
|
2022-12-01 13:00:14 +01:00
|
|
|
}">inscrire à {"" if is_apc else "tous les modules de"} cette UE</a></div>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
H.append("</li>")
|
|
|
|
H.append("</ul></li>")
|
|
|
|
H.append("</ul>")
|
2023-01-12 17:08:39 +01:00
|
|
|
# BUT: propose dispense de toutes UEs
|
|
|
|
if is_apc:
|
|
|
|
H.append(_list_but_ue_inscriptions(res, read_only=not can_change))
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-02-13 14:11:15 +01:00
|
|
|
H.append(
|
2023-01-12 17:08:39 +01:00
|
|
|
"""<hr/><p class="help">Cette page décrit les inscriptions actuelles.
|
|
|
|
Vous pouvez changer (si vous en avez le droit) les inscrits dans chaque module en
|
2022-02-13 14:11:15 +01:00
|
|
|
cliquant sur la ligne du module.</p>
|
2023-01-12 17:08:39 +01:00
|
|
|
<p class="help">Note: la déinscription d'un module ne perd pas les notes. Ainsi, si
|
2022-02-13 14:11:15 +01:00
|
|
|
l'étudiant est ensuite réinscrit au même module, il retrouvera ses notes.</p>
|
|
|
|
"""
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2021-07-29 10:19:00 +02:00
|
|
|
H.append(html_sco_header.sco_footer())
|
2020-09-26 16:19:37 +02:00
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2023-01-12 17:08:39 +01:00
|
|
|
def _list_but_ue_inscriptions(res: NotesTableCompat, read_only: bool = True) -> str:
|
|
|
|
"""HTML pour dispenser/reinscrire chaque étudiant à chaque UE du BUT"""
|
|
|
|
H = [
|
|
|
|
"""
|
|
|
|
<div class="list_but_ue_inscriptions">
|
|
|
|
<h3>Inscriptions/déinscription aux UEs du BUT</h3>
|
|
|
|
<form class="list_but_ue_inscriptions">
|
|
|
|
"""
|
|
|
|
]
|
|
|
|
table_inscr = _table_but_ue_inscriptions(res)
|
2023-01-16 19:53:31 +01:00
|
|
|
ue_ids = (
|
|
|
|
set.union(*(set(x.keys()) for x in table_inscr.values()))
|
|
|
|
if table_inscr
|
|
|
|
else set()
|
|
|
|
)
|
2023-01-12 17:08:39 +01:00
|
|
|
ues = sorted(
|
2023-07-11 06:57:38 +02:00
|
|
|
(db.session.get(UniteEns, ue_id) for ue_id in ue_ids),
|
2023-01-12 17:08:39 +01:00
|
|
|
key=lambda u: (u.numero or 0, u.acronyme),
|
|
|
|
)
|
2023-03-27 18:30:36 +02:00
|
|
|
H.append(
|
|
|
|
"""<table id="but_ue_inscriptions" class="stripe compact">
|
|
|
|
<thead>
|
|
|
|
<tr><th>Nom</th><th>Parcours</th>
|
|
|
|
"""
|
|
|
|
)
|
2023-01-12 17:08:39 +01:00
|
|
|
for ue in ues:
|
|
|
|
H.append(f"""<th title="{ue.titre or ''}">{ue.acronyme}</th>""")
|
2023-03-27 18:30:36 +02:00
|
|
|
H.append(
|
|
|
|
"""</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
partition_parcours: Partition = Partition.query.filter_by(
|
|
|
|
formsemestre=res.formsemestre, partition_name=scu.PARTITION_PARCOURS
|
|
|
|
).first()
|
2023-02-10 22:04:09 +01:00
|
|
|
etuds = list_etuds.etuds_sorted_from_ids(table_inscr.keys())
|
|
|
|
for etud in etuds:
|
|
|
|
ues_etud = table_inscr[etud.id]
|
2023-01-12 17:08:39 +01:00
|
|
|
H.append(
|
2023-02-10 22:04:09 +01:00
|
|
|
f"""<tr><td><a class="discretelink etudinfo" id={etud.id}
|
2023-01-12 17:08:39 +01:00
|
|
|
href="{url_for(
|
2024-01-20 14:49:36 +01:00
|
|
|
"scolar.fiche_etud",
|
2023-01-12 17:08:39 +01:00
|
|
|
scodoc_dept=g.scodoc_dept,
|
2023-02-10 22:04:09 +01:00
|
|
|
etudid=etud.id,
|
2023-01-12 17:08:39 +01:00
|
|
|
)}"
|
|
|
|
>{etud.nomprenom}</a></td>"""
|
|
|
|
)
|
2023-03-27 18:30:36 +02:00
|
|
|
# Parcours:
|
2023-05-30 01:15:48 +02:00
|
|
|
if partition_parcours:
|
|
|
|
group = partition_parcours.get_etud_group(etud.id)
|
|
|
|
parcours_name = group.group_name if group else ""
|
|
|
|
else:
|
|
|
|
parcours_name = ""
|
2023-03-27 18:30:36 +02:00
|
|
|
H.append(f"""<td class="parcours">{parcours_name}</td>""")
|
|
|
|
# UEs:
|
2023-01-12 17:08:39 +01:00
|
|
|
for ue in ues:
|
2023-01-13 23:23:18 +01:00
|
|
|
td_class = ""
|
2023-01-12 17:08:39 +01:00
|
|
|
est_inscr = ues_etud.get(ue.id) # None si pas concerné
|
|
|
|
if est_inscr is None:
|
|
|
|
content = ""
|
|
|
|
else:
|
2023-01-13 23:23:18 +01:00
|
|
|
# Validations d'UE déjà enregistrées dans d'autres semestres
|
|
|
|
validations_ue = (
|
2023-02-10 22:04:09 +01:00
|
|
|
ScolarFormSemestreValidation.query.filter_by(etudid=etud.id)
|
2023-01-13 23:23:18 +01:00
|
|
|
.filter(
|
|
|
|
ScolarFormSemestreValidation.formsemestre_id
|
|
|
|
!= res.formsemestre.id,
|
|
|
|
ScolarFormSemestreValidation.code.in_(
|
2023-02-12 13:36:47 +01:00
|
|
|
codes_cursus.CODES_UE_VALIDES
|
2023-01-13 23:23:18 +01:00
|
|
|
),
|
|
|
|
)
|
|
|
|
.join(UniteEns)
|
|
|
|
.filter_by(ue_code=ue.ue_code)
|
|
|
|
.all()
|
|
|
|
)
|
|
|
|
validations_ue.sort(
|
2023-06-22 08:22:37 +02:00
|
|
|
key=lambda v: codes_cursus.BUT_CODES_ORDER.get(v.code, 0)
|
2023-01-13 23:23:18 +01:00
|
|
|
)
|
|
|
|
validation = validations_ue[-1] if validations_ue else None
|
|
|
|
expl_validation = (
|
2023-02-10 22:04:09 +01:00
|
|
|
f"""Validée ({validation.code}) le {
|
2024-04-02 23:37:23 +02:00
|
|
|
validation.event_date.strftime(scu.DATE_FMT)}"""
|
2023-01-13 23:23:18 +01:00
|
|
|
if validation
|
|
|
|
else ""
|
|
|
|
)
|
|
|
|
td_class = ' class="ue_validee"' if validation else ""
|
2023-01-12 17:08:39 +01:00
|
|
|
content = f"""<input type="checkbox"
|
|
|
|
{'checked' if est_inscr else ''}
|
|
|
|
{'disabled' if read_only else ''}
|
2023-03-27 18:30:36 +02:00
|
|
|
title="{etud.nomprenom} {'inscrit' if est_inscr else 'non inscrit'} à l'UE {ue.acronyme}. {expl_validation}"
|
2023-01-12 17:08:39 +01:00
|
|
|
onchange="change_ue_inscr(this);"
|
2023-03-27 18:30:36 +02:00
|
|
|
data-url_inscr="{
|
2023-02-10 22:04:09 +01:00
|
|
|
url_for("notes.etud_inscrit_ue",
|
|
|
|
scodoc_dept=g.scodoc_dept, etudid=etud.id,
|
2023-01-12 17:08:39 +01:00
|
|
|
formsemestre_id=res.formsemestre.id, ue_id=ue.id)
|
2023-03-27 18:30:36 +02:00
|
|
|
}"
|
|
|
|
data-url_desinscr="{
|
2023-02-10 22:04:09 +01:00
|
|
|
url_for("notes.etud_desinscrit_ue",
|
|
|
|
scodoc_dept=g.scodoc_dept, etudid=etud.id,
|
2023-01-12 17:08:39 +01:00
|
|
|
formsemestre_id=res.formsemestre.id, ue_id=ue.id)
|
2023-03-27 18:30:36 +02:00
|
|
|
}"
|
2023-01-12 17:08:39 +01:00
|
|
|
/>
|
|
|
|
"""
|
|
|
|
|
2023-01-13 23:23:18 +01:00
|
|
|
H.append(f"""<td{td_class}>{content}</td>""")
|
2023-01-12 17:08:39 +01:00
|
|
|
H.append(
|
2023-03-27 18:30:36 +02:00
|
|
|
"""
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2023-01-12 17:08:39 +01:00
|
|
|
</form>
|
|
|
|
<div class="help">
|
2023-03-27 23:57:10 +02:00
|
|
|
<p>L'inscription ou désinscription aux UEs du BUT n'affecte pas les inscriptions aux modules
|
2023-01-13 12:17:59 +01:00
|
|
|
mais permet de "dispenser" un étudiant de suivre certaines UEs de son parcours.
|
2023-03-27 23:57:10 +02:00
|
|
|
</p>
|
2024-02-19 14:10:55 +01:00
|
|
|
<p>Il peut s'agir d'étudiants redoublants ayant déjà acquis l'UE, ou d'une UE
|
2023-03-27 23:57:10 +02:00
|
|
|
présente dans le semestre mais pas dans le parcours de l'étudiant, ou bien d'autres
|
|
|
|
cas particuliers.
|
|
|
|
</p>
|
|
|
|
<p>La dispense d'UE est réversible à tout moment (avant le jury de fin de semestre)
|
2023-01-12 17:08:39 +01:00
|
|
|
et n'affecte pas les notes saisies.
|
2023-03-27 23:57:10 +02:00
|
|
|
</p>
|
2023-01-12 17:08:39 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
|
|
|
def _table_but_ue_inscriptions(res: NotesTableCompat) -> dict[int, dict]:
|
|
|
|
""" "table" avec les inscriptions aux UEs de chaque étudiant
|
|
|
|
{
|
|
|
|
etudid : { ue_id : True | False }
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
return {
|
|
|
|
etudid: {
|
|
|
|
ue_id: (etudid, ue_id) not in res.dispense_ues
|
|
|
|
for ue_id in res.etud_ues_ids(etudid)
|
|
|
|
}
|
|
|
|
for etudid, inscr in res.formsemestre.etuds_inscriptions.items()
|
|
|
|
if inscr.etat == scu.INSCRIT
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-31 19:14:21 +02:00
|
|
|
def descr_inscrs_module(moduleimpl_id, set_all, partitions):
|
2021-01-01 17:46:05 +01:00
|
|
|
"""returns tous_inscrits, nb_inscrits, descr"""
|
2021-08-20 01:09:55 +02:00
|
|
|
ins = sco_moduleimpl.do_moduleimpl_inscription_list(moduleimpl_id=moduleimpl_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
set_m = set([x["etudid"] for x in ins]) # ens. des inscrits au module
|
|
|
|
non_inscrits = set_all - set_m
|
|
|
|
if len(non_inscrits) == 0:
|
|
|
|
return True, len(ins), "" # tous inscrits
|
|
|
|
if len(non_inscrits) <= 7: # seuil arbitraire
|
2021-08-21 00:24:51 +02:00
|
|
|
return False, len(ins), "tous sauf " + _fmt_etud_set(non_inscrits)
|
2020-09-26 16:19:37 +02:00
|
|
|
# Cherche les groupes:
|
|
|
|
gr = [] # [ ( partition_name , [ group_names ] ) ]
|
|
|
|
for partition in partitions:
|
|
|
|
grp = [] # groupe de cette partition
|
2021-08-19 10:28:35 +02:00
|
|
|
for group in sco_groups.get_partition_groups(partition):
|
|
|
|
members = sco_groups.get_group_members(group["group_id"])
|
2020-09-26 16:19:37 +02:00
|
|
|
set_g = set([m["etudid"] for m in members])
|
|
|
|
if set_g.issubset(set_m):
|
|
|
|
grp.append(group["group_name"])
|
|
|
|
set_m = set_m - set_g
|
|
|
|
gr.append((partition["partition_name"], grp))
|
|
|
|
#
|
|
|
|
d = []
|
2023-06-07 18:43:44 +02:00
|
|
|
for partition_name, grp in gr:
|
2020-09-26 16:19:37 +02:00
|
|
|
if grp:
|
|
|
|
d.append("groupes de %s: %s" % (partition_name, ", ".join(grp)))
|
|
|
|
r = []
|
|
|
|
if d:
|
|
|
|
r.append(", ".join(d))
|
|
|
|
if set_m:
|
2021-08-21 00:24:51 +02:00
|
|
|
r.append(_fmt_etud_set(set_m))
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
return False, len(ins), " et ".join(r)
|
|
|
|
|
|
|
|
|
2023-06-07 18:43:44 +02:00
|
|
|
def _fmt_etud_set(etudids, max_list_size=7) -> str:
|
2020-09-26 16:19:37 +02:00
|
|
|
# max_list_size est le nombre max de noms d'etudiants listés
|
|
|
|
# au delà, on indique juste le nombre, sans les noms.
|
2023-06-07 18:43:44 +02:00
|
|
|
if len(etudids) > max_list_size:
|
|
|
|
return f"{len(etudids)} étudiants"
|
2020-09-26 16:19:37 +02:00
|
|
|
etuds = []
|
2023-06-07 18:43:44 +02:00
|
|
|
for etudid in etudids:
|
2023-07-11 06:57:38 +02:00
|
|
|
etud = db.session.get(Identite, etudid)
|
2023-06-07 18:43:44 +02:00
|
|
|
if etud:
|
|
|
|
etuds.append(etud)
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
return ", ".join(
|
|
|
|
[
|
2023-06-07 18:43:44 +02:00
|
|
|
f"""<a class="discretelink" href="{
|
2021-07-11 17:37:12 +02:00
|
|
|
url_for(
|
2024-01-20 14:49:36 +01:00
|
|
|
"scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etud.id
|
2023-06-07 18:43:44 +02:00
|
|
|
)
|
|
|
|
}">{etud.nomprenom}</a>"""
|
|
|
|
for etud in sorted(etuds, key=attrgetter("sort_key"))
|
2020-09-26 16:19:37 +02:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-12-01 13:00:14 +01:00
|
|
|
def get_etuds_with_capitalized_ue(formsemestre_id: int) -> list[dict]:
|
2020-09-26 16:19:37 +02:00
|
|
|
"""For each UE, computes list of students capitalizing the UE.
|
|
|
|
returns { ue_id : [ { infos } ] }
|
|
|
|
"""
|
2023-03-08 22:23:55 +01:00
|
|
|
ues_cap_info = collections.defaultdict(list)
|
2023-03-20 11:17:38 +01:00
|
|
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
2022-02-13 15:50:16 +01:00
|
|
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
|
|
|
|
2021-06-19 23:21:37 +02:00
|
|
|
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
|
2021-08-19 10:28:35 +02:00
|
|
|
args={"formsemestre_id": formsemestre_id}
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2021-12-24 00:08:25 +01:00
|
|
|
ues = nt.get_ues_stat_dict()
|
2020-09-26 16:19:37 +02:00
|
|
|
for ue in ues:
|
|
|
|
for etud in inscrits:
|
2022-02-12 22:57:46 +01:00
|
|
|
ue_status = nt.get_etud_ue_status(etud["etudid"], ue["ue_id"])
|
|
|
|
if ue_status and ue_status["was_capitalized"]:
|
2022-12-01 13:00:14 +01:00
|
|
|
ues_cap_info[ue["ue_id"]].append(
|
2020-09-26 16:19:37 +02:00
|
|
|
{
|
|
|
|
"etudid": etud["etudid"],
|
2022-02-12 22:57:46 +01:00
|
|
|
"ue_status": ue_status,
|
2022-12-01 13:00:14 +01:00
|
|
|
"is_ins": etud_modules_ue_inscr(
|
2021-08-21 00:24:51 +02:00
|
|
|
etud["etudid"], formsemestre_id, ue["ue_id"]
|
2020-09-26 16:19:37 +02:00
|
|
|
),
|
|
|
|
}
|
|
|
|
)
|
2022-12-01 13:00:14 +01:00
|
|
|
return ues_cap_info
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2022-12-01 13:00:14 +01:00
|
|
|
def etud_modules_ue_inscr(etudid, formsemestre_id, ue_id) -> list[int]:
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Modules de cette UE dans ce semestre
|
|
|
|
auxquels l'étudiant est inscrit.
|
2022-12-01 13:00:14 +01:00
|
|
|
Utile pour formations classiques seulement.
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2021-02-03 22:00:41 +01:00
|
|
|
r = ndb.SimpleDictFetch(
|
2021-08-08 17:38:46 +02:00
|
|
|
"""SELECT mod.id AS module_id, mod.*
|
2020-09-26 16:19:37 +02:00
|
|
|
FROM notes_moduleimpl mi, notes_modules mod,
|
|
|
|
notes_formsemestre sem, notes_moduleimpl_inscription i
|
2021-08-21 23:01:20 +02:00
|
|
|
WHERE sem.id = %(formsemestre_id)s
|
2021-08-08 17:38:46 +02:00
|
|
|
AND mi.formsemestre_id = sem.id
|
|
|
|
AND mod.id = mi.module_id
|
2020-09-26 16:19:37 +02:00
|
|
|
AND mod.ue_id = %(ue_id)s
|
2021-08-08 17:38:46 +02:00
|
|
|
AND i.moduleimpl_id = mi.id
|
2020-09-26 16:19:37 +02:00
|
|
|
AND i.etudid = %(etudid)s
|
|
|
|
ORDER BY mod.numero
|
|
|
|
""",
|
|
|
|
{"etudid": etudid, "formsemestre_id": formsemestre_id, "ue_id": ue_id},
|
|
|
|
)
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
2022-12-01 13:00:14 +01:00
|
|
|
def do_etud_desinscrit_ue_classic(etudid, formsemestre_id, ue_id):
|
|
|
|
"""Désinscrit l'etudiant de tous les modules de cette UE dans ce semestre.
|
|
|
|
N'utiliser que pour les formations classiques, pas APC.
|
|
|
|
"""
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-02-03 22:00:41 +01:00
|
|
|
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
2020-09-26 16:19:37 +02:00
|
|
|
cursor.execute(
|
2021-09-13 22:10:01 +02:00
|
|
|
"""DELETE FROM notes_moduleimpl_inscription
|
2021-10-04 15:16:50 +02:00
|
|
|
WHERE id IN (
|
|
|
|
SELECT i.id FROM
|
2021-09-13 22:10:01 +02:00
|
|
|
notes_moduleimpl mi, notes_modules mod,
|
2020-09-26 16:19:37 +02:00
|
|
|
notes_formsemestre sem, notes_moduleimpl_inscription i
|
2021-10-04 15:16:50 +02:00
|
|
|
WHERE sem.id = %(formsemestre_id)s
|
|
|
|
AND mi.formsemestre_id = sem.id
|
|
|
|
AND mod.id = mi.module_id
|
2020-09-26 16:19:37 +02:00
|
|
|
AND mod.ue_id = %(ue_id)s
|
2021-10-04 15:16:50 +02:00
|
|
|
AND i.moduleimpl_id = mi.id
|
2020-09-26 16:19:37 +02:00
|
|
|
AND i.etudid = %(etudid)s
|
|
|
|
)
|
|
|
|
""",
|
|
|
|
{"etudid": etudid, "formsemestre_id": formsemestre_id, "ue_id": ue_id},
|
|
|
|
)
|
2024-07-08 23:13:45 +02:00
|
|
|
Scolog.logdb(
|
2021-09-27 10:20:10 +02:00
|
|
|
method="etud_desinscrit_ue",
|
|
|
|
etudid=etudid,
|
2022-12-01 13:00:14 +01:00
|
|
|
msg=f"desinscription UE {ue_id}",
|
2024-07-08 23:13:45 +02:00
|
|
|
commit=True,
|
2021-09-27 10:20:10 +02:00
|
|
|
)
|
2021-07-19 19:53:01 +02:00
|
|
|
sco_cache.invalidate_formsemestre(
|
|
|
|
formsemestre_id=formsemestre_id
|
2020-09-26 16:19:37 +02:00
|
|
|
) # > desinscription etudiant des modules
|
|
|
|
|
|
|
|
|
2021-09-27 10:20:10 +02:00
|
|
|
def do_etud_inscrit_ue(etudid, formsemestre_id, ue_id):
|
2021-01-01 17:46:05 +01:00
|
|
|
"""Incrit l'etudiant de tous les modules de cette UE dans ce semestre."""
|
2020-09-26 16:19:37 +02:00
|
|
|
# Verifie qu'il est bien inscrit au semestre
|
2021-06-19 23:21:37 +02:00
|
|
|
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
|
2021-08-19 10:28:35 +02:00
|
|
|
args={"formsemestre_id": formsemestre_id, "etudid": etudid}
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
if not insem:
|
|
|
|
raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid)
|
|
|
|
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-02-03 22:00:41 +01:00
|
|
|
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
2020-09-26 16:19:37 +02:00
|
|
|
cursor.execute(
|
2023-12-31 23:04:06 +01:00
|
|
|
"""SELECT mi.id
|
2020-09-26 16:19:37 +02:00
|
|
|
FROM notes_moduleimpl mi, notes_modules mod, notes_formsemestre sem
|
2022-01-27 11:53:16 +01:00
|
|
|
WHERE sem.id = %(formsemestre_id)s
|
|
|
|
AND mi.formsemestre_id = sem.id
|
|
|
|
AND mod.id = mi.module_id
|
2020-09-26 16:19:37 +02:00
|
|
|
AND mod.ue_id = %(ue_id)s
|
|
|
|
""",
|
|
|
|
{"formsemestre_id": formsemestre_id, "ue_id": ue_id},
|
|
|
|
)
|
|
|
|
res = cursor.dictfetchall()
|
2022-01-27 11:53:16 +01:00
|
|
|
for moduleimpl_id in [x["id"] for x in res]:
|
2021-01-17 22:31:28 +01:00
|
|
|
sco_moduleimpl.do_moduleimpl_inscription_create(
|
2020-09-26 16:19:37 +02:00
|
|
|
{"moduleimpl_id": moduleimpl_id, "etudid": etudid},
|
|
|
|
formsemestre_id=formsemestre_id,
|
|
|
|
)
|