2023-11-22 15:31:35 +01:00
|
|
|
<div>
|
|
|
|
{% if label != false%}
|
|
|
|
<label for="moduleimpl_select">
|
|
|
|
Module
|
|
|
|
</label>
|
|
|
|
{% else %}
|
|
|
|
{% endif %}
|
|
|
|
{% if moduleid %}
|
|
|
|
<select id="{{moduleid}}" class="dynaSelect">
|
|
|
|
{% include "assiduites/widgets/simplemoduleimpl_select.j2" %}
|
|
|
|
</select>
|
|
|
|
{% else %}
|
2023-06-12 17:54:30 +02:00
|
|
|
<select id="moduleimpl_select" class="dynaSelect">
|
2023-10-26 15:52:53 +02:00
|
|
|
{% include "assiduites/widgets/simplemoduleimpl_select.j2" %}
|
2023-04-17 15:44:55 +02:00
|
|
|
</select>
|
2023-11-22 15:31:35 +01:00
|
|
|
{% endif %}
|
2023-10-26 15:52:53 +02:00
|
|
|
|
|
|
|
<div id="saved" style="display: none;">
|
|
|
|
{% include "assiduites/widgets/simplemoduleimpl_select.j2" %}
|
|
|
|
</div>
|
2023-11-22 15:31:35 +01:00
|
|
|
</div>
|
2023-04-17 15:44:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
function getEtudFormSemestres() {
|
|
|
|
let semestre = {};
|
|
|
|
sync_get(getUrl() + `/api/etudiant/etudid/${etudid}/formsemestres`, (data) => {
|
|
|
|
semestre = data;
|
|
|
|
});
|
|
|
|
return semestre;
|
|
|
|
}
|
|
|
|
|
2023-06-12 17:54:30 +02:00
|
|
|
function filterFormSemestres(semestres, dateIso) {
|
2023-11-20 16:55:26 +01:00
|
|
|
const date = new Date(Date.removeUTC(dateIso));
|
2023-04-17 15:44:55 +02:00
|
|
|
semestres = semestres.filter((fm) => {
|
2023-11-20 16:55:26 +01:00
|
|
|
return date.isBetween(new Date(Date.removeUTC(fm.date_debut_iso)), new Date(Date.removeUTC(fm.date_fin_iso)), '[]');
|
2023-04-17 15:44:55 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
return semestres;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFormSemestreProgramme(fm_id) {
|
|
|
|
let semestre = {};
|
|
|
|
sync_get(getUrl() + `/api/formsemestre/${fm_id}/programme`, (data) => {
|
|
|
|
semestre = data;
|
|
|
|
});
|
|
|
|
return semestre;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getModulesImplByFormsemestre(semestres) {
|
|
|
|
const map = new Map();
|
|
|
|
|
|
|
|
semestres.forEach((fm) => {
|
|
|
|
const array = [];
|
|
|
|
|
|
|
|
const fm_p = getFormSemestreProgramme(fm.formsemestre_id);
|
|
|
|
["ressources", "saes", "modules"].forEach((r) => {
|
|
|
|
if (r in fm_p) {
|
|
|
|
fm_p[r].forEach((o) => {
|
|
|
|
array.push(getModuleInfos(o))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
map.set(fm.titre_num, array)
|
|
|
|
})
|
|
|
|
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getModuleInfos(obj) {
|
|
|
|
return {
|
|
|
|
moduleimpl_id: obj.moduleimpl_id,
|
|
|
|
titre: obj.module.titre,
|
|
|
|
code: obj.module.code,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-12 17:54:30 +02:00
|
|
|
function populateSelect(sems, selected, query) {
|
|
|
|
const select = document.querySelector(query);
|
2023-10-26 15:52:53 +02:00
|
|
|
select.innerHTML = document.getElementById('saved').innerHTML
|
2023-04-17 15:44:55 +02:00
|
|
|
sems.forEach((mods, label) => {
|
|
|
|
const optGrp = document.createElement('optgroup');
|
|
|
|
optGrp.label = label
|
|
|
|
|
|
|
|
mods.forEach((obj) => {
|
|
|
|
const opt = document.createElement('option');
|
|
|
|
opt.value = obj.moduleimpl_id;
|
|
|
|
opt.textContent = `${obj.code} ${obj.titre}`
|
|
|
|
if (obj.moduleimpl_id == selected) {
|
|
|
|
opt.setAttribute('selected', 'true');
|
|
|
|
}
|
|
|
|
|
|
|
|
optGrp.appendChild(opt);
|
|
|
|
})
|
|
|
|
select.appendChild(optGrp);
|
|
|
|
})
|
2023-07-04 15:04:58 +02:00
|
|
|
if (selected === "autre") {
|
|
|
|
select.querySelector('option[value="autre"]').setAttribute('selected', 'true');
|
|
|
|
}
|
2023-04-17 15:44:55 +02:00
|
|
|
}
|
|
|
|
|
2023-06-12 17:54:30 +02:00
|
|
|
function updateSelect(moduleimpl_id, query = "#moduleimpl_select", dateIso = null) {
|
2023-04-17 15:44:55 +02:00
|
|
|
let sem = getEtudFormSemestres()
|
2023-11-15 14:11:47 +01:00
|
|
|
if (!dateIso) {
|
|
|
|
dateIso = getDate().format("YYYY-MM-DD")
|
2023-06-12 17:54:30 +02:00
|
|
|
}
|
2023-11-15 14:11:47 +01:00
|
|
|
|
2023-06-12 17:54:30 +02:00
|
|
|
sem = filterFormSemestres(sem, dateIso)
|
2023-04-17 15:44:55 +02:00
|
|
|
const mod = getModulesImplByFormsemestre(sem)
|
2023-06-12 17:54:30 +02:00
|
|
|
populateSelect(mod, moduleimpl_id, query);
|
2023-04-17 15:44:55 +02:00
|
|
|
}
|
|
|
|
|
2023-06-12 17:54:30 +02:00
|
|
|
function updateSelectedSelect(moduleimpl_id, query = "#moduleimpl_select") {
|
2023-04-19 18:17:47 +02:00
|
|
|
const mod_id = moduleimpl_id != null ? moduleimpl_id : ""
|
2023-10-24 09:44:55 +02:00
|
|
|
document.querySelector(query).value = `${mod_id}`.toLowerCase();
|
2023-04-19 18:17:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-24 13:58:03 +01:00
|
|
|
{% if moduleid %}
|
|
|
|
const moduleimpl_dynamic_selector_id = "{{moduleid}}"
|
|
|
|
{% else %}
|
|
|
|
const moduleimpl_dynamic_selector_id = "moduleimpl_select"
|
|
|
|
|
|
|
|
{% endif %}
|
2023-04-19 18:17:47 +02:00
|
|
|
|
2023-10-24 09:44:55 +02:00
|
|
|
|
|
|
|
|
2023-06-12 17:54:30 +02:00
|
|
|
window.addEventListener("load", () => {
|
2023-11-24 13:58:03 +01:00
|
|
|
document.getElementById(moduleimpl_dynamic_selector_id).addEventListener('change', (el) => {
|
2023-04-19 18:17:47 +02:00
|
|
|
const assi = getCurrentAssiduite(etudid);
|
|
|
|
if (assi) {
|
2023-10-24 09:44:55 +02:00
|
|
|
editAssiduite(assi.assiduite_id, assi.etat, [assi]);
|
2023-04-19 18:17:47 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2023-09-15 10:51:40 +02:00
|
|
|
try {
|
|
|
|
const conflicts = getAssiduitesConflict(etudid);
|
|
|
|
if (conflicts.length > 0) {
|
2023-10-24 09:44:55 +02:00
|
|
|
updateSelectedSelect(getCurrentAssiduiteModuleImplId());
|
2023-09-15 10:51:40 +02:00
|
|
|
}
|
|
|
|
} catch { }
|
2023-06-12 17:54:30 +02:00
|
|
|
}, { once: true });
|
2023-04-17 15:44:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
#moduleimpl_select {
|
|
|
|
width: 125px;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
</style>
|