1
0
forked from ScoDoc/ScoDoc

Assiduites : Lien Evaluation WIP

This commit is contained in:
iziram 2023-05-30 17:16:07 +02:00
parent 825dc6ecb1
commit 36bc67fffc
4 changed files with 120 additions and 9 deletions

View File

@ -668,10 +668,13 @@ def evaluation_describe(evaluation_id="", edit_in_place=True, link_saisie=True):
group_id = sco_groups.get_default_group(formsemestre_id)
H.append(
f"""<span class="noprint"><a href="{url_for(
'absences.EtatAbsencesDate',
'assiduites.get_etat_abs_date',
scodoc_dept=g.scodoc_dept,
group_ids=group_id,
date=E["jour"]
desc=E["description"],
jour=E["jour"],
heure_debut=E["heure_debut"],
heure_fin=E["heure_fin"],
)
}">(absences ce jour)</a></span>"""
)

View File

@ -57,6 +57,7 @@ from app.scodoc import sco_moduleimpl
from app.scodoc import sco_permissions_check
from app.tables import list_etuds
# menu evaluation dans moduleimpl
def moduleimpl_evaluation_menu(evaluation_id, nbnotes=0) -> str:
"Menu avec actions sur une evaluation"
@ -139,8 +140,11 @@ def moduleimpl_evaluation_menu(evaluation_id, nbnotes=0) -> str:
"title": "Absences ce jour",
"endpoint": "absences.EtatAbsencesDate",
"args": {
"date": E["jour"],
"group_ids": group_id,
"desc": E["description"],
"jour": E["jour"],
"heure_debut": E["heure_debut"],
"heure_fin": E["heure_fin"],
},
"enabled": E["jour"],
},

View File

@ -0,0 +1,36 @@
<h2>Présence lors de l'évaluation {{eval.title}} </h2>
<h3>Réalisé le {{eval.jour}} de {{eval.heure_debut}} à {{eval.heure_fin}}</h3>
<table>
<thead>
<tr>
<th>
Nom
</th>
<th>
Assiduité
</th>
</tr>
</thead>
<tbody>
{% for etud in etudiants %}
<tr>
<td>
{{etud.nom | safe}}
</td>
<td style="text-align: center;">
{{etud.etat}}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<style>
tr,
td {
background-color: #FFFFFF;
}
</style>

View File

@ -10,7 +10,7 @@ from app.decorators import (
scodoc,
permission_required,
)
from app.models import FormSemestre, Identite, ScoDocSiteConfig
from app.models import FormSemestre, Identite, ScoDocSiteConfig, Assiduite
from app.views import assiduites_bp as bp
from app.views import ScoData
@ -23,6 +23,8 @@ from app.scodoc import sco_groups_view
from app.scodoc import sco_etud
from app.scodoc import sco_find_etud
from flask_login import current_user
from app.scodoc import sco_utils as scu
from app.scodoc import sco_assiduites as scass
CSSSTYLES = html_sco_header.BOOTSTRAP_MULTISELECT_CSS
@ -284,10 +286,6 @@ def signal_assiduites_group():
Returns:
str: l'html généré
"""
formsemestre_id: int = request.args.get("formsemestre_id", -1)
moduleimpl_id: int = request.args.get("moduleimpl_id")
group_ids: list[int] = request.args.get("group_ids", None)
formsemestre_id: int = request.args.get("formsemestre_id", -1)
moduleimpl_id: int = request.args.get("moduleimpl_id")
date: str = request.args.get("jour", datetime.date.today().isoformat())
@ -314,7 +312,6 @@ def signal_assiduites_group():
group_ids, moduleimpl_id=moduleimpl_id, formsemestre_id=formsemestre_id
)
# Aucun étudiant WIP
if not groups_infos.members:
return (
html_sco_header.sco_header(page_title="Saisie journalière des Assiduités")
@ -415,6 +412,77 @@ def signal_assiduites_group():
).build()
@bp.route("/EtatAbsencesDate")
@scodoc
@permission_required(Permission.ScoAbsChange)
def get_etat_abs_date():
evaluation = {
"jour": request.args.get("jour"),
"heure_debut": request.args.get("heure_debut"),
"heure_fin": request.args.get("heure_fin"),
"title": request.args.get("desc"),
}
date: str = evaluation["jour"]
group_ids: list[int] = request.args.get("group_ids", None)
etudiants: list[dict] = []
if group_ids is None:
group_ids = []
else:
group_ids = group_ids.split(",")
map(str, group_ids)
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids)
etuds = [
sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0]
for m in groups_infos.members
]
date_debut = scu.is_iso_formated(
f"{evaluation['jour']}T{evaluation['heure_debut'].replace('h',':')}", True
)
date_fin = scu.is_iso_formated(
f"{evaluation['jour']}T{evaluation['heure_fin'].replace('h',':')}", True
)
assiduites: Assiduite = Assiduite.query.filter(
Assiduite.etudid.in_([e["etudid"] for e in etuds])
)
assiduites = scass.filter_by_date(
assiduites, Assiduite, date_debut, date_fin, False
)
for etud in etuds:
assi = assiduites.filter_by(etudid=etud["etudid"]).first()
etat = ""
if assi != None and assi.etat != 0:
etat = scu.EtatAssiduite.inverse().get(assi.etat).name
etudiant = {
"nom": f'<a href="{url_for("absences.CalAbs", scodoc_dept=g.scodoc_dept, etudid=etud["etudid"])}"><font color="#A00000">{etud["nomprenom"]}</font></a>',
"etat": etat,
}
etudiants.append(etudiant)
etudiants = list(sorted(etudiants, key=lambda x: x["nom"]))
header: str = html_sco_header.sco_header(
page_title=evaluation["title"],
init_qtip=True,
)
return HTMLBuilder(
header,
render_template(
"assiduites/etat_absence_date.j2", etudiants=etudiants, eval=evaluation
),
html_sco_header.sco_footer(),
).build()
def _module_selector(
formsemestre: FormSemestre, moduleimpl_id: int = None
) -> HTMLElement: