2020-09-26 16:19:37 +02:00
|
|
|
// Affiche et met a jour la liste des UE partageant le meme code
|
|
|
|
|
2021-06-21 18:46:35 +02:00
|
|
|
$().ready(function () {
|
2022-07-09 12:55:23 +02:00
|
|
|
if (document.querySelector("#tf_ue_id")) {
|
|
|
|
/* fonctions spécifiques pour edition UE */
|
|
|
|
update_ue_list();
|
|
|
|
$("#tf_ue_code").bind("keyup", update_ue_list);
|
2022-01-27 18:12:40 +01:00
|
|
|
|
2022-07-09 12:55:23 +02:00
|
|
|
$("select#tf_type").change(function () {
|
|
|
|
update_bonus_description();
|
|
|
|
});
|
2022-01-27 18:12:40 +01:00
|
|
|
update_bonus_description();
|
2022-07-09 12:55:23 +02:00
|
|
|
}
|
2022-10-30 16:07:06 +01:00
|
|
|
update_menus_niveau_competence();
|
2020-09-26 16:19:37 +02:00
|
|
|
});
|
|
|
|
|
2022-01-27 18:12:40 +01:00
|
|
|
function update_bonus_description() {
|
|
|
|
var ue_type = $("#tf_type")[0].value;
|
|
|
|
if (ue_type == "1") { /* UE SPORT */
|
|
|
|
$("#bonus_description").show();
|
|
|
|
var query = "/ScoDoc/get_bonus_description/default";
|
|
|
|
$.get(query, '', function (data) {
|
|
|
|
$("#bonus_description").html(data);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$("#bonus_description").html("");
|
|
|
|
$("#bonus_description").hide();
|
|
|
|
}
|
|
|
|
}
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
function update_ue_list() {
|
2022-04-29 08:17:04 +02:00
|
|
|
let ue_id = $("#tf_ue_id")[0].value;
|
|
|
|
let ue_code = $("#tf_ue_code")[0].value;
|
|
|
|
let query = SCO_URL + "/Notes/ue_sharing_code?ue_code=" + ue_code + "&hide_ue_id=" + ue_id + "&ue_id=" + ue_id;
|
2021-06-21 18:46:35 +02:00
|
|
|
$.get(query, '', function (data) {
|
|
|
|
$("#ue_list_code").html(data);
|
2020-09-26 16:19:37 +02:00
|
|
|
});
|
2021-06-21 18:46:35 +02:00
|
|
|
}
|
2022-04-29 08:17:04 +02:00
|
|
|
|
2022-10-30 16:07:06 +01:00
|
|
|
function set_ue_parcour(elem) {
|
|
|
|
let ue_id = elem.dataset.ue_id;
|
|
|
|
let parcour_id = elem.value;
|
|
|
|
let set_ue_parcour_url = elem.dataset.setter;
|
|
|
|
$.post(set_ue_parcour_url,
|
|
|
|
{
|
|
|
|
ue_id: ue_id,
|
|
|
|
parcour_id: parcour_id,
|
|
|
|
},
|
|
|
|
function (result) {
|
|
|
|
sco_message("UE associée au parcours");
|
|
|
|
update_menus_niveau_competence();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-07-09 12:55:23 +02:00
|
|
|
function set_ue_niveau_competence(elem) {
|
|
|
|
let ue_id = elem.dataset.ue_id;
|
|
|
|
let niveau_id = elem.value;
|
|
|
|
let set_ue_niveau_competence_url = elem.dataset.setter;
|
2022-04-29 08:17:04 +02:00
|
|
|
$.post(set_ue_niveau_competence_url,
|
|
|
|
{
|
|
|
|
ue_id: ue_id,
|
|
|
|
niveau_id: niveau_id,
|
|
|
|
},
|
|
|
|
function (result) {
|
2022-07-14 22:20:24 +02:00
|
|
|
sco_message("niveau de compétence enregistré");
|
|
|
|
|
|
|
|
update_menus_niveau_competence();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Met à jour les niveaux utilisés (disabled) ou non affectés
|
|
|
|
// dans les menus d'association UE <-> niveau
|
|
|
|
function update_menus_niveau_competence() {
|
2022-10-30 16:07:06 +01:00
|
|
|
// let selected_niveaux = [];
|
|
|
|
// document.querySelectorAll("form.form_ue_choix_niveau select").forEach(
|
|
|
|
// elem => { selected_niveaux.push(elem.value); }
|
|
|
|
// );
|
|
|
|
|
|
|
|
// document.querySelectorAll("form.form_ue_choix_niveau select").forEach(
|
|
|
|
// elem => {
|
|
|
|
// for (let i = 0; i < elem.options.length; i++) {
|
|
|
|
// elem.options[i].disabled = (i != elem.options.selectedIndex)
|
|
|
|
// && (selected_niveaux.indexOf(elem.options[i].value) != -1)
|
|
|
|
// && (elem.options[i].value != "");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// );
|
2022-07-14 22:20:24 +02:00
|
|
|
|
2022-10-30 16:07:06 +01:00
|
|
|
// nouveau:
|
2023-04-03 17:46:31 +02:00
|
|
|
document.querySelectorAll("select.niveau_select").forEach(
|
2022-07-14 22:20:24 +02:00
|
|
|
elem => {
|
2022-10-30 16:07:06 +01:00
|
|
|
let ue_id = elem.dataset.ue_id;
|
|
|
|
$.get("get_ue_niveaux_options_html",
|
|
|
|
{
|
|
|
|
ue_id: ue_id,
|
|
|
|
},
|
|
|
|
function (result) {
|
|
|
|
elem.innerHTML = result;
|
|
|
|
}
|
|
|
|
);
|
2022-04-29 08:17:04 +02:00
|
|
|
}
|
|
|
|
);
|
2023-04-03 17:46:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---- Nouveau formulaire choix parcours et niveau -----
|
|
|
|
//document.querySelectorAll("select.select_ue_parcours").forEach(
|
|
|
|
// elem => { elem.addEventListener('change', change_ue_parcours); }
|
|
|
|
//);
|
|
|
|
$().ready(function () {
|
|
|
|
$('select.select_ue_parcours').multiselect(
|
|
|
|
{
|
|
|
|
includeSelectAllOption: false,
|
|
|
|
nonSelectedText: 'choisir...',
|
|
|
|
// buttonContainer: '<div id="group_ids_sel_container"/>',
|
|
|
|
onChange: function (element, checked) {
|
|
|
|
var parent = element.parent();
|
|
|
|
var selectedOptions = parent.getValue().split(",");
|
|
|
|
let set_ue_parcours = element.context.dataset.set_ue_parcours;
|
|
|
|
|
|
|
|
fetch(set_ue_parcours, {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(selectedOptions)
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
if (!data.status) {
|
|
|
|
sco_message(data.message);
|
|
|
|
// get the option element corresponding to the selected value
|
|
|
|
var option = parent.find('option[value="' + element.val() + '"]');
|
|
|
|
// uncheck the option
|
|
|
|
option.prop('selected', false);
|
|
|
|
// refresh the multiselect to reflect the change
|
|
|
|
parent.multiselect('refresh');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(error => console.error('Error: ' + error));
|
|
|
|
|
|
|
|
// // referme le menu apres chaque choix:
|
|
|
|
// $("#group_selector .btn-group").removeClass('open');
|
|
|
|
|
|
|
|
// if ($("#group_ids_sel").hasClass("submit_on_change")) {
|
|
|
|
// submit_group_selector();
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
function change_ue_parcours(event) {
|
|
|
|
const multiselect = event.target;
|
|
|
|
const selectedOptions = Array.from(this.selectedOptions).map(option => option.value);
|
|
|
|
fetch('/set_option/', { // XXX TODO
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(selectedOptions)
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => console.log('Success!'))
|
|
|
|
.catch(error => console.error('Error: ' + error));
|
|
|
|
};
|