1
0
forked from ScoDoc/ScoDoc

Tri partitions et groupes

This commit is contained in:
Sébastien Lehmann 2022-07-27 17:20:43 +02:00
parent ee93cf1e9b
commit 3dfe15ee17

View File

@ -72,26 +72,33 @@
let outputPartitions = "<div>"; let outputPartitions = "<div>";
let outputMasques = ""; let outputMasques = "";
let outputGroupes = ""; let outputGroupes = "";
Object.entries(partitions).forEach(([idPartition, partition]) => { let arrayPartitions = Object.values(partitions).sort((a, b) => {
return a.numero - b.numero;
})
arrayPartitions.forEach((partition) => {
// Filtres // Filtres
outputPartitions += `<div data-idpartition="${idPartition}"><span class="editing move">||</span><span>${partition.partition_name}</span><span class="editing modif">✏️</span><span class="editing suppr"></span></div>`; outputPartitions += `<div data-idpartition="${partition.id}"><span class="editing move">||</span><span>${partition.partition_name}</span><span class="editing modif">✏️</span><span class="editing suppr"></span></div>`;
outputMasques += `<div data-idpartition="${idPartition}"><div data-idpartition="${idPartition}" data-idgroupe=aucun>Non affectés - ${partition.partition_name}</div>`; outputMasques += `<div data-idpartition="${partition.id}"><div data-idpartition="${partition.id}" data-idgroupe=aucun>Non affectés - ${partition.partition_name}</div>`;
// Groupes // Groupes
outputGroupes += ` outputGroupes += `
<div class=partition data-idpartition="${idPartition}"> <div class=partition data-idpartition="${partition.id}">
<h3>${partition.partition_name}</h3> <h3>${partition.partition_name}</h3>
<div class=groupe data-idgroupe=aucun> <div class=groupe data-idgroupe=aucun>
<div>Non affecté(s)</div> <div>Non affecté(s)</div>
<div class=etudiants></div> <div class=etudiants></div>
</div> </div>
${(() => { ${(() => {
let arrayGroups = Object.values(partition.groups).sort((a, b) => {
return a.numero - b.numero;
})
let output = ""; let output = "";
Object.entries(partition.groups).forEach(([idGroupe, titreGroupe]) => { arrayGroups.forEach((groupe) => {
/***************/ /***************/
outputMasques += `<div data-idgroupe="${idGroupe}"><span class="editing move">||</span><span>${titreGroupe.name}</span><span class="editing modif">✏️</span><span class="editing suppr"></span></div>`; outputMasques += `<div data-idgroupe="${groupe.id}"><span class="editing move">||</span><span>${groupe.name}</span><span class="editing modif">✏️</span><span class="editing suppr"></span></div>`;
/***************/ /***************/
output += templateGroupe_zoneGroupes(idGroupe, titreGroupe.name); output += templateGroupe_zoneGroupes(groupe.id, groupe.name);
}) })
return output; return output;
})()} })()}
@ -115,26 +122,29 @@
<div class=nom data-etudid="${etudiant.etudid}" data-nom="${etudiant.nom_disp}" data-prenom="${etudiant.prenom}">${etudiant.nom_disp} ${etudiant.prenom}<br><small>${etudiant.bac}</small></div> <div class=nom data-etudid="${etudiant.etudid}" data-nom="${etudiant.nom_disp}" data-prenom="${etudiant.prenom}">${etudiant.nom_disp} ${etudiant.prenom}<br><small>${etudiant.bac}</small></div>
${(() => { ${(() => {
let output = "<div class=grpPartitions>"; let output = "<div class=grpPartitions>";
Object.entries(partitions).forEach(([idPartition, dataPartition]) => { arrayPartitions.forEach((partition) => {
output += ` output += `
<div class=partition data-idpartition="${idPartition}"> <div class=partition data-idpartition="${partition.id}">
<div>${dataPartition.partition_name}</div> <div>${partition.partition_name}</div>
${(() => { ${(() => {
let output = ""; let output = "";
let affected = false; let affected = false;
Object.entries(dataPartition.groups).forEach(([idGroupe, titreGroupe]) => { let arrayGroups = Object.values(partition.groups).sort((a, b) => {
return a.numero - b.numero;
})
arrayGroups.forEach((groupe) => {
output += ` output += `
<label><input type=radio name="${idPartition}-${etudiant.etudid}" value="${idGroupe}" ${(etudiant.partitions[idPartition] == idGroupe) ? "checked" : ""}><span>${titreGroupe.name}</span></label>`; <label><input type=radio name="${partition.id}-${etudiant.etudid}" value="${groupe.id}" ${(etudiant.partitions[partition.id] == groupe.id) ? "checked" : ""}><span>${groupe.name}</span></label>`;
if (etudiant.partitions[idPartition] == idGroupe) { if (etudiant.partitions[partition.id] == groupe.id) {
affected = true; affected = true;
document.querySelector(`#zoneGroupes [data-idgroupe="${idGroupe}"]>.etudiants`).innerHTML += templateEtudiant_zoneGroupes(etudiant); document.querySelector(`#zoneGroupes [data-idgroupe="${groupe.id}"]>.etudiants`).innerHTML += templateEtudiant_zoneGroupes(etudiant);
} }
}) })
if (!affected) { if (!affected) {
document.querySelector(`#zoneGroupes [data-idpartition="${idPartition}"]>[data-idgroupe="aucun"]>.etudiants`).innerHTML += templateEtudiant_zoneGroupes(etudiant); document.querySelector(`#zoneGroupes [data-idpartition="${partition.id}"]>[data-idgroupe="aucun"]>.etudiants`).innerHTML += templateEtudiant_zoneGroupes(etudiant);
} }
return `<label title="Aucun groupe"><input type=radio name="${idPartition}-${etudiant.etudid}" value="aucun" ${(!affected) ? "checked" : ""}><span class=aucun></span></label>` + output; return `<label title="Aucun groupe"><input type=radio name="${partition.id}-${etudiant.etudid}" value="aucun" ${(!affected) ? "checked" : ""}><span class=aucun></span></label>` + output;
})()} })()}
</div>`; </div>`;
}) })