1
0
forked from ScoDoc/ScoDoc

Assiduites : fix partiel bug differee

This commit is contained in:
Iziram 2023-09-21 17:25:57 +02:00
parent 7b62ab8784
commit b8f7037804

View File

@ -96,6 +96,14 @@
display: flex; display: flex;
} }
.td[assiduite_id='insc'] * {
display: none;
}
.td[assiduite_id='insc']::after {
content: "Etudiant non inscrit";
}
.sticky { .sticky {
position: sticky; position: sticky;
left: 0; left: 0;
@ -278,6 +286,8 @@
currentDate = moment(currentDate).tz(TIMEZONE).format("YYYY-MM-DDTHH:mm"); currentDate = moment(currentDate).tz(TIMEZONE).format("YYYY-MM-DDTHH:mm");
} }
const inscriptionsModule = {};
function createColumn(dateStart = "", dateEnd = "", moduleimpl_id = "") { function createColumn(dateStart = "", dateEnd = "", moduleimpl_id = "") {
let table = document.getElementById("studentTable"); let table = document.getElementById("studentTable");
let th = document.createElement("div"); let th = document.createElement("div");
@ -561,6 +571,8 @@
const d_debut = moment(inputDeb).tz(TIMEZONE); const d_debut = moment(inputDeb).tz(TIMEZONE);
const d_fin = moment(inputFin).tz(TIMEZONE); const d_fin = moment(inputFin).tz(TIMEZONE);
const moduleimpl_id = col.querySelector("#moduleimpl_select").value;
const periode = { const periode = {
deb: d_debut, deb: d_debut,
fin: d_fin, fin: d_fin,
@ -573,9 +585,12 @@
}); });
setEtatLine(td, "") setEtatLine(td, "")
const etu = td.parentElement.getAttribute('etudid'); const etu = td.parentElement.getAttribute('etudid');
const inscriptionModule = ["", "autre"].indexOf(moduleimpl_id) !== -1 ? true : checkInscriptionModule(moduleimpl_id, etu);
const conflits = getAssiduitesConflict(etu, periode); const conflits = getAssiduitesConflict(etu, periode);
if (!inscriptionModule) {
if (conflits.length == 0) { td.setAttribute('assiduite_id', "insc");
}
else if (conflits.length == 0) {
td.setAttribute('assiduite_id', "-1"); td.setAttribute('assiduite_id', "-1");
} else if (conflits.length == 1 && isConflictSameAsPeriod(conflits[0], periode)) { } else if (conflits.length == 1 && isConflictSameAsPeriod(conflits[0], periode)) {
const assi = conflits[0]; const assi = conflits[0];
@ -587,7 +602,6 @@
const inputs = [...td.querySelectorAll('input')]; const inputs = [...td.querySelectorAll('input')];
inputs.forEach((i) => { inputs.forEach((i) => {
i.disabled = true; i.disabled = true;
}) })
} }
}) })
@ -871,7 +885,7 @@
const { moduleimpl, deb, fin } = getAssiduitesCol(colid, false); const { moduleimpl, deb, fin } = getAssiduitesCol(colid, false);
const lines = [...document.querySelectorAll(`[assiduite_id][colid='${colid}']`)].filter((el) => { const lines = [...document.querySelectorAll(`[assiduite_id][colid='${colid}']`)].filter((el) => {
return el.getAttribute('assiduite_id') != "conflit"; return ["conflit", "insc"].indexOf(el.getAttribute('assiduite_id')) == -1;
}) })
const toCreate = lines.filter((el) => { return el.getAttribute('assiduite_id') == '-1' }) const toCreate = lines.filter((el) => { return el.getAttribute('assiduite_id') == '-1' })
@ -1019,6 +1033,25 @@
}) })
} }
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', () => { window.addEventListener('load', () => {
document.getElementById("addColumn").addEventListener("click", () => { document.getElementById("addColumn").addEventListener("click", () => {
createColumn(); createColumn();