From c6659db08adae45ea700b0482a7eb3d92e1b526b Mon Sep 17 00:00:00 2001 From: Iziram Date: Fri, 15 Sep 2023 10:51:40 +0200 Subject: [PATCH] Assiduites : page ListeSemestre #733 --- app/scodoc/sco_formsemestre_status.py | 15 ++- app/templates/assiduites/pages/bilan_dept.j2 | 11 +-- .../assiduites/pages/liste_semestre.j2 | 94 +++++++++++++++++++ .../widgets/moduleimpl_dynamic_selector.j2 | 10 +- .../assiduites/widgets/tableau_assi.j2 | 23 ++++- .../assiduites/widgets/tableau_base.j2 | 35 +++++-- .../assiduites/widgets/tableau_justi.j2 | 42 ++++----- app/views/assiduites.py | 43 +++++++++ 8 files changed, 222 insertions(+), 51 deletions(-) create mode 100644 app/templates/assiduites/pages/liste_semestre.j2 diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index c21e8774d..ab185b284 100755 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -171,6 +171,13 @@ def formsemestre_status_menubar(formsemestre: FormSemestre) -> str: "enabled": True, "helpmsg": "Tableau de bord du semestre", }, + { + "title": "Assiduités du semestre", + "endpoint": "assiduites.liste_assiduites_formsemestre", + "args": {"formsemestre_id": formsemestre_id}, + "enabled": True, + "helpmsg": "Tableau des assiduités et des justificatifs du semestre", + }, { "title": f"Voir la formation {formation.acronyme} (v{formation.version})", "endpoint": "notes.ue_table", @@ -218,14 +225,6 @@ def formsemestre_status_menubar(formsemestre: FormSemestre) -> str: "enabled": True, "helpmsg": "", }, - # TODO: Mettre à jour avec module Assiduités - # { - # "title": "Vérifier absences aux évaluations", - # "endpoint": "notes.formsemestre_check_absences_html", - # "args": {"formsemestre_id": formsemestre_id}, - # "enabled": True, - # "helpmsg": "", - # }, { "title": "Lister tous les enseignants", "endpoint": "notes.formsemestre_enseignants_list", diff --git a/app/templates/assiduites/pages/bilan_dept.j2 b/app/templates/assiduites/pages/bilan_dept.j2 index 0d758b49f..2db0dce9e 100644 --- a/app/templates/assiduites/pages/bilan_dept.j2 +++ b/app/templates/assiduites/pages/bilan_dept.j2 @@ -33,11 +33,6 @@ +{% endblock pageContent %} \ No newline at end of file diff --git a/app/templates/assiduites/widgets/moduleimpl_dynamic_selector.j2 b/app/templates/assiduites/widgets/moduleimpl_dynamic_selector.j2 index bb3806ab2..f5df64101 100644 --- a/app/templates/assiduites/widgets/moduleimpl_dynamic_selector.j2 +++ b/app/templates/assiduites/widgets/moduleimpl_dynamic_selector.j2 @@ -117,10 +117,12 @@ } }) - const conflicts = getAssiduitesConflict(etudid); - if (conflicts.length > 0) { - updateSelectedSelect(conflicts[0].moduleimpl_id); - } + try { + const conflicts = getAssiduitesConflict(etudid); + if (conflicts.length > 0) { + updateSelectedSelect(conflicts[0].moduleimpl_id); + } + } catch { } }, { once: true }); diff --git a/app/templates/assiduites/widgets/tableau_assi.j2 b/app/templates/assiduites/widgets/tableau_assi.j2 index cb7bb0f16..1eb634bef 100644 --- a/app/templates/assiduites/widgets/tableau_assi.j2 +++ b/app/templates/assiduites/widgets/tableau_assi.j2 @@ -88,6 +88,10 @@ td.textContent = getModuleImpl(assiduite); } else if (k.indexOf('est_just') != -1) { td.textContent = assiduite[k] ? "Oui" : "Non" + } else if (k.indexOf('etudid') != -1) { + const e = getEtudiant(assiduite.etudid); + + td.innerHTML = `${e.prenom.capitalize()} ${e.nom.toUpperCase()}`; } else { td.textContent = assiduite[k].capitalize() } @@ -341,6 +345,10 @@ + + Rechercher dans les étudiants + + `; const span = document.createElement('span'); @@ -349,7 +357,7 @@ const filterHead = html.querySelector('.filter-head'); filterHead.innerHTML = "" - let cols = ["entry_date", "date_debut", "date_fin", "etat", "moduleimpl_id", "est_just"]; + let cols = ["etudid", "entry_date", "date_debut", "date_fin", "etat", "moduleimpl_id", "est_just"]; cols.forEach((k) => { const label = document.createElement('label') @@ -401,6 +409,8 @@ l.querySelector('#moduleimpl_id').value = filterAssiduites.filters[key]; } else if (key.indexOf("est_just") != -1) { l.querySelector('#est_just').value = filterAssiduites.filters[key]; + } else if (key == "etud") { + l.querySelector('#etud').value = filterAssiduites.filters["etud"]; } }) @@ -434,18 +444,23 @@ filterAssiduites.filters[key] = l.querySelector('#moduleimpl_id').value; } else if (key.indexOf("est_just") != -1) { filterAssiduites.filters[key] = l.querySelector('#est_just').value; + } else if (key == "etud") { + filterAssiduites.filters["etud"] = l.querySelector('#etud').value; } }) - - getAllAssiduitesFromEtud(etudid, assiduiteCallBack) + getAssi(assiduiteCallBack) }, () => { }, "#7059FF"); } function downloadAssi() { - try { getAllAssiduitesFromEtud(etudid, (d) => { toCSV(d, filterAssiduites) }, true, true, assi_limit_annee) } catch (_) { } + getAssi((d) => { toCSV(d, filterAssiduites) }) + } + + function getAssi(action) { + try { getAllAssiduitesFromEtud(etudid, action, true, true, assi_limit_annee) } catch (_) { } } \ No newline at end of file diff --git a/app/templates/assiduites/widgets/tableau_base.j2 b/app/templates/assiduites/widgets/tableau_base.j2 index e28fef780..c623ccced 100644 --- a/app/templates/assiduites/widgets/tableau_base.j2 +++ b/app/templates/assiduites/widgets/tableau_base.j2 @@ -60,8 +60,6 @@ deleteJustificatif(obj_id); } loadAll(); - - } }); @@ -105,6 +103,13 @@ if (k == "formsemestre") { return f.formsemestre === "" || (el.hasOwnProperty("formsemestre") && el.formsemestre.title.replaceAll('-', ' ').indexOf(f.formsemestre) != -1); } + if (k == "etud") { + + const e = getEtudiant(el.etudid); + const str = `${e.prenom.capitalize()} ${e.nom.toUpperCase()}` + + return f.etud === "" || str.indexOf(f.etud) != -1; + } return true; }) @@ -246,8 +251,8 @@ } function loadAll() { - try { getAllAssiduitesFromEtud(etudid, assiduiteCallBack, true, true, assi_limit_annee) } catch (_) { } - try { getAllJustificatifsFromEtud(etudid, justificatifCallBack, true, assi_limit_annee) } catch (_) { } + try { getAssi(assiduiteCallBack) } catch { } + try { getJusti(justificatifCallBack) } catch { } } function order(keyword, callback = () => { }, el, assi = true) { @@ -265,6 +270,13 @@ keyValueA = getModuleImpl(a); keyValueB = getModuleImpl(b); } + if (keyword.indexOf("etudid") != -1) { + keyValueA = getEtudiant(a.etudid); + keyValueB = getEtudiant(b.etudid); + + keyValueA = `${keyValueA.prenom.capitalize()} ${keyValueA.nom.toUpperCase()}` + keyValueB = `${keyValueB.prenom.capitalize()} ${keyValueB.nom.toUpperCase()}` + } let orderDertermined = keyValueA > keyValueB; @@ -282,10 +294,10 @@ if (assi) { orderAssiduites = !orderAssiduites; - getAllAssiduitesFromEtud(etudid, (a) => { call(a, orderAssiduites) }) + getAssi((a) => { call(a, orderAssiduites) }); } else { orderJustificatifs = !orderJustificatifs; - getAllJustificatifsFromEtud(etudid, (a) => { call(a, orderJustificatifs) }) + getJusti((a) => { call(a, orderJustificatifs) }); } } @@ -333,7 +345,6 @@ li.addEventListener('click', () => { let obj_id = selectedRow.getAttribute('obj_id'); assiduite = Object.values(assiduites).flat().filter((a) => { return a.assiduite_id == obj_id }) - console.log(assiduite[0]) if (assiduite && !assiduite[0].est_just && assiduite[0].etat != "PRESENT") { fastJustify(assiduite[0]) } else { @@ -412,6 +423,16 @@ askDownload(csv); } + function getEtudiant(id) { + if (id in etuds) { + return etuds[id]; + } + getSingleEtud(id); + + return etuds[id]; + + } +