From 6e447afdaa124e7d3bf2ba27a09ce88c0d6c7eb3 Mon Sep 17 00:00:00 2001 From: Iziram Date: Mon, 23 Oct 2023 14:56:18 +0200 Subject: [PATCH] Assiduite : Etudiant non inscrit module Fix #792 --- app/static/js/assiduites.js | 27 +++++++++++++++++++ .../pages/signal_assiduites_group.j2 | 10 +++++-- app/templates/assiduites/widgets/differee.j2 | 20 +------------- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/app/static/js/assiduites.js b/app/static/js/assiduites.js index b2d73c10..4ad8d380 100644 --- a/app/static/js/assiduites.js +++ b/app/static/js/assiduites.js @@ -1389,6 +1389,11 @@ function generateAllEtudRow() { etuds[a].nom > etuds[b].nom ? 1 : etuds[b].nom > etuds[a].nom ? -1 : 0 ); + let mod = getModuleImplId(); + etuds_ids = etuds_ids.filter((i) => { + return checkInscriptionModule(mod, i); + }); + for (let i = 0; i < etuds_ids.length; i++) { const etud = etuds[etuds_ids[i]]; insertEtudRow(etud, i + 1); @@ -1764,3 +1769,25 @@ function getUser(obj) { return obj.user_nom_complet || obj.user_id; } + +const inscriptionsModule = {}; + +function checkInscriptionModule(moduleimpl_id, etudid) { + if ([null, "", "autre"].indexOf(moduleimpl_id) !== -1) return true; + if (!inscriptionsModule.hasOwnProperty(moduleimpl_id)) { + const path = getUrl() + `/api/moduleimpl/${moduleimpl_id}/inscriptions`; + sync_get( + path, + (data, status) => { + inscriptionsModule[moduleimpl_id] = data; + }, + (data, status) => { + //error + console.error(data, status); + errorAlert(); + } + ); + } + const etudsInscrits = inscriptionsModule[moduleimpl_id].map((i) => i.etudid); + return etudsInscrits.indexOf(Number(etudid)) !== -1; +} diff --git a/app/templates/assiduites/pages/signal_assiduites_group.j2 b/app/templates/assiduites/pages/signal_assiduites_group.j2 index cac99bca..5a7c09fe 100644 --- a/app/templates/assiduites/pages/signal_assiduites_group.j2 +++ b/app/templates/assiduites/pages/signal_assiduites_group.j2 @@ -18,7 +18,8 @@
Groupes : {{grp|safe}}
-
Date : +
Date :
@@ -106,10 +107,15 @@ const etudsDefDem = {{ defdem | safe }} + const select = document.getElementById("moduleimpl_select"); + + select?.addEventListener('change', (e) => { + generateAllEtudRow(); + }); + if (window.forceModule) { const btn = document.getElementById("validate_selectors"); - const select = document.getElementById("moduleimpl_select"); if (!readOnly && select.value == "") { document.getElementById('forcemodule').style.display = "block"; diff --git a/app/templates/assiduites/widgets/differee.j2 b/app/templates/assiduites/widgets/differee.j2 index f6efc6f5..6d0d8ed1 100644 --- a/app/templates/assiduites/widgets/differee.j2 +++ b/app/templates/assiduites/widgets/differee.j2 @@ -287,7 +287,6 @@ currentDate = moment(currentDate).tz(TIMEZONE).format("YYYY-MM-DDTHH:mm"); } - const inscriptionsModule = {}; function createColumn(dateStart = "", dateEnd = "", moduleimpl_id = "") { let table = document.getElementById("studentTable"); @@ -1034,24 +1033,7 @@ }) } - function checkInscriptionModule(moduleimpl_id, etudid) { - if (!inscriptionsModule.hasOwnProperty(moduleimpl_id)) { - const path = getUrl() + `/api/moduleimpl/${moduleimpl_id}/inscriptions`; - sync_get( - path, - (data, status) => { - inscriptionsModule[moduleimpl_id] = data; - }, - (data, status) => { - //error - console.error(data, status); - errorAlert(); - } - ); - } - const etudsInscrits = inscriptionsModule[moduleimpl_id].map((i) => i.etudid); - return etudsInscrits.indexOf(Number(etudid)) !== -1; - } + window.addEventListener('load', () => { document.getElementById("addColumn").addEventListener("click", () => {