2022-03-26 23:33:57 +01:00
|
|
|
// Tableau recap notes
|
|
|
|
$(function () {
|
|
|
|
$(function () {
|
2022-06-25 12:32:00 +02:00
|
|
|
let hidden_colums = ["codes", "identite_detail", "partition_aux", "partition_rangs", "admission", "col_empty"];
|
|
|
|
let mode_jury_but_bilan = $('table.table_recap').hasClass("table_jury_but_bilan");
|
|
|
|
if (mode_jury_but_bilan) {
|
|
|
|
// table bilan décisions: cache les notes
|
|
|
|
hidden_colums = hidden_colums.concat(["col_ue", "col_rcue", "col_lien_saisie_but"]);
|
|
|
|
} else {
|
|
|
|
hidden_colums = hidden_colums.concat(["recorded_code"]);
|
|
|
|
}
|
2022-06-25 16:23:39 +02:00
|
|
|
// Etat (tri des colonnes) de la table:
|
|
|
|
|
|
|
|
const url = new URL(document.URL);
|
|
|
|
const formsemestre_id = url.searchParams.get("formsemestre_id");
|
|
|
|
const order_info_key = JSON.stringify([url.pathname, formsemestre_id]);
|
|
|
|
let order_info;
|
|
|
|
if (formsemestre_id) {
|
|
|
|
const x = localStorage.getItem(order_info_key);
|
|
|
|
if (x) {
|
|
|
|
try {
|
|
|
|
order_info = JSON.parse(x);
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-14 17:43:57 +01:00
|
|
|
|
|
|
|
// Les colonnes visibles étant mémorisé, il faut initialiser les titres des boutons
|
|
|
|
function update_buttons_labels(dt) {
|
|
|
|
dt.buttons('toggle_ident:name').text(dt.columns(".identite_detail").visible()[0] ? "Nom seul" : "Civ/Nom/Prénom");
|
|
|
|
dt.buttons('toggle_partitions:name').text(dt.columns(".partition_aux").visible()[0] ? "Cacher les groupes" : "Montrer groupes");
|
|
|
|
if (!$('table.table_recap').hasClass("table_jury_but")) {
|
|
|
|
// Bouton "rangs groupes", sauf pour table jury BUT
|
|
|
|
dt.buttons('toggle_partitions_rangs:name').text(dt.columns(".partition_rangs").visible()[0] ? "Cacher rangs groupes" : "Rangs groupes");
|
|
|
|
dt.buttons('toggle_admission:name').text(dt.columns(".admission").visible()[0] ? "Cacher infos admission" : "Montrer infos admission");
|
|
|
|
} else {
|
|
|
|
// table jury BUT: avec ou sans codes enregistrés
|
|
|
|
dt.buttons('toggle_recorded_code:name').text(dt.columns(".recorded_code").visible()[0] ? "Cacher codes jury" : "Code jury enregistrés");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Boutons non visibles en mode jury:
|
|
|
|
if (!$('table.table_recap').hasClass("jury")) {
|
|
|
|
// Ces boutons dépendent du mode BUT ou classique:
|
|
|
|
if ($('table.table_recap').hasClass("apc")) {
|
|
|
|
dt.buttons('toggle_res:name').text(dt.columns(".col_res").visible()[0] ? "Cacher les ressources" : "Montrer les ressources");
|
|
|
|
dt.buttons('toggle_sae:name').text(dt.columns(".col_sae").visible()[0] ? "Cacher les SAÉs" : "Montrer les SAÉs");
|
|
|
|
} else {
|
|
|
|
dt.buttons('toggle_mod:name').text(dt.columns(".col_mod:not(.col_empty)").visible()[0] ? "Cacher les modules" : "Montrer les modules");
|
|
|
|
}
|
|
|
|
dt.buttons('toggle_col_empty:name').text(dt.columns(".col_empty").visible()[0] ? "Cacher mod. vides" : "Montrer mod. vides");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-28 18:13:51 +02:00
|
|
|
let buttons = [
|
|
|
|
{
|
|
|
|
name: "toggle_ident",
|
|
|
|
text: "Civ/Nom/Prénom",
|
|
|
|
action: function (e, dt, node, config) {
|
|
|
|
let visible = dt.columns(".identite_detail").visible()[0];
|
|
|
|
dt.columns(".identite_detail").visible(!visible);
|
|
|
|
dt.columns(".identite_court").visible(visible);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(dt);
|
2022-03-28 18:13:51 +02:00
|
|
|
}
|
|
|
|
},
|
2022-03-29 00:03:38 +02:00
|
|
|
{
|
|
|
|
name: "toggle_partitions",
|
2022-05-23 10:59:43 +02:00
|
|
|
text: "Montrer groupes",
|
2022-03-29 00:03:38 +02:00
|
|
|
action: function (e, dt, node, config) {
|
|
|
|
let visible = dt.columns(".partition_aux").visible()[0];
|
|
|
|
dt.columns(".partition_aux").visible(!visible);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(dt);
|
2022-03-29 00:03:38 +02:00
|
|
|
}
|
2022-05-23 10:59:43 +02:00
|
|
|
},
|
|
|
|
];
|
2022-06-24 12:00:08 +02:00
|
|
|
// Bouton "rangs groupes", sauf pour table jury BUT
|
|
|
|
if (!$('table.table_recap').hasClass("table_jury_but")) {
|
|
|
|
buttons.push(
|
|
|
|
{
|
|
|
|
name: "toggle_partitions_rangs",
|
|
|
|
text: "Rangs groupes",
|
|
|
|
action: function (e, dt, node, config) {
|
|
|
|
let rangs_visible = dt.columns(".partition_rangs").visible()[0];
|
|
|
|
dt.columns(".partition_rangs").visible(!rangs_visible);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(dt);
|
2022-06-24 12:00:08 +02:00
|
|
|
}
|
|
|
|
});
|
2022-06-24 16:57:44 +02:00
|
|
|
} else {
|
|
|
|
// table jury BUT: avec ou sans codes enregistrés
|
|
|
|
buttons.push(
|
|
|
|
{
|
|
|
|
name: "toggle_recorded_code",
|
|
|
|
text: "Code jury enregistrés",
|
|
|
|
action: function (e, dt, node, config) {
|
|
|
|
let visible = dt.columns(".recorded_code").visible()[0];
|
|
|
|
dt.columns(".recorded_code").visible(!visible);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(dt);
|
2022-06-24 16:57:44 +02:00
|
|
|
}
|
|
|
|
});
|
2022-06-24 12:00:08 +02:00
|
|
|
}
|
|
|
|
|
2022-04-07 23:31:08 +02:00
|
|
|
if (!$('table.table_recap').hasClass("jury")) {
|
|
|
|
buttons.push(
|
|
|
|
$('table.table_recap').hasClass("apc") ?
|
|
|
|
{
|
|
|
|
name: "toggle_res",
|
2023-01-14 17:43:57 +01:00
|
|
|
text: "Visilité ressources",
|
2022-04-07 23:31:08 +02:00
|
|
|
action: function (e, dt, node, config) {
|
|
|
|
let visible = dt.columns(".col_res").visible()[0];
|
|
|
|
dt.columns(".col_res").visible(!visible);
|
|
|
|
dt.columns(".col_ue_bonus").visible(!visible);
|
|
|
|
dt.columns(".col_malus").visible(!visible);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(dt);
|
2022-04-07 23:31:08 +02:00
|
|
|
}
|
|
|
|
} : {
|
|
|
|
name: "toggle_mod",
|
|
|
|
text: "Cacher les modules",
|
|
|
|
action: function (e, dt, node, config) {
|
|
|
|
let visible = dt.columns(".col_mod:not(.col_empty)").visible()[0];
|
|
|
|
dt.columns(".col_mod:not(.col_empty)").visible(!visible);
|
|
|
|
dt.columns(".col_ue_bonus").visible(!visible);
|
|
|
|
dt.columns(".col_malus").visible(!visible);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(dt);
|
2022-04-07 23:31:08 +02:00
|
|
|
}
|
2022-03-28 18:13:51 +02:00
|
|
|
}
|
2022-04-07 23:31:08 +02:00
|
|
|
);
|
|
|
|
if ($('table.table_recap').hasClass("apc")) {
|
|
|
|
buttons.push({
|
|
|
|
name: "toggle_sae",
|
2023-01-14 17:43:57 +01:00
|
|
|
text: "Visibilité SAÉs",
|
2022-03-28 18:13:51 +02:00
|
|
|
action: function (e, dt, node, config) {
|
2022-04-07 23:31:08 +02:00
|
|
|
let visible = dt.columns(".col_sae").visible()[0];
|
|
|
|
dt.columns(".col_sae").visible(!visible);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(dt);
|
2022-03-28 18:13:51 +02:00
|
|
|
}
|
2022-04-07 23:31:08 +02:00
|
|
|
})
|
|
|
|
}
|
2022-03-28 18:13:51 +02:00
|
|
|
buttons.push({
|
2022-04-07 23:31:08 +02:00
|
|
|
name: "toggle_col_empty",
|
2023-01-14 17:43:57 +01:00
|
|
|
text: "Visibilité mod. vides",
|
2022-03-28 18:13:51 +02:00
|
|
|
action: function (e, dt, node, config) {
|
2022-04-07 23:31:08 +02:00
|
|
|
let visible = dt.columns(".col_empty").visible()[0];
|
|
|
|
dt.columns(".col_empty").visible(!visible);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(dt);
|
2022-03-28 18:13:51 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2022-06-24 12:00:08 +02:00
|
|
|
// Boutons admission, sauf pour table jury BUT
|
|
|
|
if (!$('table.table_recap').hasClass("table_jury_but")) {
|
|
|
|
buttons.push({
|
|
|
|
name: "toggle_admission",
|
|
|
|
text: "Montrer infos admission",
|
|
|
|
action: function (e, dt, node, config) {
|
|
|
|
let visible = dt.columns(".admission").visible()[0];
|
|
|
|
dt.columns(".admission").visible(!visible);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(dt);
|
2022-06-24 12:00:08 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-07-03 16:14:03 +02:00
|
|
|
let table = $('table.table_recap').DataTable(
|
2022-03-26 23:33:57 +01:00
|
|
|
{
|
|
|
|
paging: false,
|
|
|
|
searching: true,
|
|
|
|
info: false,
|
|
|
|
autoWidth: false,
|
|
|
|
fixedHeader: {
|
|
|
|
header: true,
|
2022-03-28 18:13:51 +02:00
|
|
|
footer: false
|
2022-03-26 23:33:57 +01:00
|
|
|
},
|
|
|
|
orderCellsTop: true, // cellules ligne 1 pour tri
|
|
|
|
aaSorting: [], // Prevent initial sorting
|
|
|
|
colReorder: true,
|
2022-07-03 16:14:03 +02:00
|
|
|
stateSave: true, // enregistre état de la table (tris, ...)
|
2022-03-26 23:33:57 +01:00
|
|
|
"columnDefs": [
|
|
|
|
{
|
2022-04-04 09:35:52 +02:00
|
|
|
// cache les codes, le détail de l'identité, les groupes, les colonnes admission et les vides
|
2022-06-25 12:32:00 +02:00
|
|
|
targets: hidden_colums,
|
2022-04-04 09:35:52 +02:00
|
|
|
visible: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Elimine les 0 à gauche pour les exports excel et les "copy"
|
2022-07-01 16:34:36 +02:00
|
|
|
targets: ["col_mod", "col_moy_gen", "col_ue", "col_res", "col_sae", "evaluation", "col_rcue"],
|
2022-04-04 09:35:52 +02:00
|
|
|
render: function (data, type, row) {
|
|
|
|
return type === 'export' ? data.replace(/0(\d\..*)/, '$1') : data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Elimine les décorations (fleches bonus/malus) pour les exports
|
|
|
|
targets: ["col_ue_bonus", "col_malus"],
|
|
|
|
render: function (data, type, row) {
|
|
|
|
return type === 'export' ? data.replace(/.*(\d\d\.\d\d)/, '$1').replace(/0(\d\..*)/, '$1') : data;
|
|
|
|
}
|
2022-03-26 23:33:57 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
dom: 'Bfrtip',
|
2022-04-04 09:35:52 +02:00
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
extend: 'copyHtml5',
|
|
|
|
text: 'Copier',
|
|
|
|
exportOptions: { orthogonal: 'export' }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
extend: 'excelHtml5',
|
2023-01-14 21:56:41 +01:00
|
|
|
// footer: true, // ne fonctionne pas ?
|
2022-04-04 09:35:52 +02:00
|
|
|
exportOptions: { orthogonal: 'export' },
|
|
|
|
title: document.querySelector('table.table_recap').dataset.filename
|
|
|
|
},
|
2022-03-26 23:33:57 +01:00
|
|
|
{
|
|
|
|
extend: 'collection',
|
2022-03-29 00:03:38 +02:00
|
|
|
text: 'Colonnes affichées',
|
2022-03-26 23:33:57 +01:00
|
|
|
autoClose: true,
|
2022-03-28 18:13:51 +02:00
|
|
|
buttons: buttons,
|
2022-03-29 00:03:38 +02:00
|
|
|
},
|
2022-06-25 16:23:39 +02:00
|
|
|
],
|
|
|
|
"drawCallback": function (settings) {
|
|
|
|
// permet de conserver l'ordre de tri des colonnes
|
|
|
|
let order_info = JSON.stringify($('table.table_recap').DataTable().order());
|
|
|
|
if (formsemestre_id) {
|
|
|
|
localStorage.setItem(order_info_key, order_info);
|
|
|
|
}
|
2022-06-29 22:53:56 +02:00
|
|
|
let etudids = [];
|
2023-01-23 21:30:54 +01:00
|
|
|
document.querySelectorAll("td.identite_court").forEach(e => {
|
2022-06-29 22:53:56 +02:00
|
|
|
etudids.push(e.dataset.etudid);
|
|
|
|
});
|
|
|
|
let noms = [];
|
2023-01-23 21:30:54 +01:00
|
|
|
document.querySelectorAll("td.identite_court").forEach(e => {
|
2022-06-29 22:53:56 +02:00
|
|
|
noms.push(e.dataset.nomprenom);
|
|
|
|
});
|
|
|
|
const etudids_key = JSON.stringify(["etudids", url.origin, formsemestre_id]);
|
|
|
|
localStorage.setItem(etudids_key, JSON.stringify(etudids));
|
|
|
|
const noms_key = JSON.stringify(["noms", url.origin, formsemestre_id]);
|
|
|
|
localStorage.setItem(noms_key, JSON.stringify(noms));
|
2022-06-25 16:23:39 +02:00
|
|
|
},
|
|
|
|
"order": order_info,
|
2022-03-26 23:33:57 +01:00
|
|
|
}
|
|
|
|
);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(table);
|
2022-03-26 23:33:57 +01:00
|
|
|
});
|
2022-03-27 18:49:15 +02:00
|
|
|
$('table.table_recap tbody').on('click', 'tr', function () {
|
|
|
|
if ($(this).hasClass('selected')) {
|
|
|
|
$(this).removeClass('selected');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('table.table_recap tr.selected').removeClass('selected');
|
|
|
|
$(this).addClass('selected');
|
|
|
|
}
|
|
|
|
});
|
2022-06-25 12:32:00 +02:00
|
|
|
// Pour montrer et surligner l'étudiant sélectionné:
|
2022-04-07 23:31:08 +02:00
|
|
|
$(function () {
|
2022-06-25 12:32:00 +02:00
|
|
|
let row_selected = document.querySelector("#row_selected");
|
|
|
|
if (row_selected) {
|
2022-07-03 16:14:03 +02:00
|
|
|
/*row_selected.scrollIntoView();
|
|
|
|
window.scrollBy(0, -50);*/
|
2022-06-25 12:32:00 +02:00
|
|
|
row_selected.classList.add("selected");
|
|
|
|
}
|
2022-04-07 23:31:08 +02:00
|
|
|
});
|
2022-03-26 23:33:57 +01:00
|
|
|
});
|