2021-11-12 22:17:46 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="fr">
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<script src="/ScoDoc/static/jQuery/jquery.js"></script>
|
|
|
|
<script src="/ScoDoc/static/js/table_editor.js"></script>
|
|
|
|
<link href="/ScoDoc/static/css/table_editor.css" rel="stylesheet" type="text/css" />
|
|
|
|
<title>Édition coef. formation</title>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<h2>Formation {{formation.titre}} ({{formation.acronyme}})
|
2021-11-13 09:11:00 +01:00
|
|
|
[version {{formation.version}}] code {{formation.code}}</h2>
|
|
|
|
|
2021-11-17 10:28:51 +01:00
|
|
|
<form onchange="change_semestre()">Semestre:
|
|
|
|
<select name="semestre_idx" id="semestre_idx" >
|
|
|
|
{% for i in semestre_ids %}
|
|
|
|
<option value="{{i}}" {%if semestre_idx == i%}selected{%endif%}>{{i}}</option>
|
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</form>
|
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
<div class="tableau"></div>
|
|
|
|
|
|
|
|
<script>
|
2021-11-17 10:28:51 +01:00
|
|
|
function change_semestre() {
|
|
|
|
let semestre_idx = $("#semestre_idx")[0].value;
|
|
|
|
let url = window.location.href.replace( /\/[\-0-9]*$/, "/" + semestre_idx);
|
|
|
|
window.location.href = url;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
$(function () {
|
2021-11-17 10:28:51 +01:00
|
|
|
let semestre_idx = $("#semestre_idx")[0].value;
|
|
|
|
if (semestre_idx > -10) {
|
|
|
|
let base_url = "{{data_source}}";
|
|
|
|
let data_url = base_url.replace( /\/[\-0-9]*$/, "/" + semestre_idx);
|
|
|
|
console.log("data_url=", data_url );
|
|
|
|
$.getJSON(data_url, function (data) {
|
|
|
|
console.log("build_table")
|
|
|
|
build_table(data);
|
|
|
|
});
|
|
|
|
}
|
2021-11-12 22:17:46 +01:00
|
|
|
});
|
|
|
|
function save(obj) {
|
2021-11-13 09:11:00 +01:00
|
|
|
var value = obj.innerText.trim();
|
|
|
|
if (value.length == 0) {
|
|
|
|
value = "0";
|
|
|
|
}
|
2021-11-13 09:43:13 +01:00
|
|
|
if (!/^[\d.,]+$/.test(value)) {
|
2021-11-13 09:11:00 +01:00
|
|
|
message("Il est attendu un nombre");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (value == obj.dataset.data) {
|
|
|
|
return true; // Aucune modification, pas d'enregistrement mais on continue normalement
|
2021-11-12 22:17:46 +01:00
|
|
|
}
|
2021-11-13 09:11:00 +01:00
|
|
|
obj.dataset.data = value;
|
|
|
|
obj.classList.add("wait");
|
2021-11-12 22:17:46 +01:00
|
|
|
// XXX DEBUG
|
2021-11-13 09:43:13 +01:00
|
|
|
// console.log(`
|
|
|
|
// x : ${getComputedStyle(obj).getPropertyValue("--x")}
|
|
|
|
// y : ${getComputedStyle(obj).getPropertyValue("--y")}
|
|
|
|
// data : ${value}
|
|
|
|
// ue_id: ${obj.dataset.ue_id}
|
|
|
|
// module_id : ${obj.dataset.module_id}
|
|
|
|
// `);
|
2021-11-12 22:17:46 +01:00
|
|
|
$.post("{{data_save}}",
|
|
|
|
{
|
2021-11-13 09:43:13 +01:00
|
|
|
module_id: obj.dataset.module_id,
|
|
|
|
ue_id: obj.dataset.ue_id,
|
|
|
|
coef: value
|
2021-11-12 22:17:46 +01:00
|
|
|
},
|
|
|
|
function (result) {
|
2021-11-13 09:11:00 +01:00
|
|
|
obj.classList.remove("wait");
|
2021-11-13 09:43:13 +01:00
|
|
|
if (obj.dataset.orig != value)
|
|
|
|
obj.classList.add("modified");
|
|
|
|
else
|
|
|
|
obj.classList.remove("modified");
|
|
|
|
// Lorsque les données sont bien enregistrées, on enlève
|
2021-11-13 09:11:00 +01:00
|
|
|
// l'indication que c'est bon au bout d'un temps
|
2021-11-13 09:43:13 +01:00
|
|
|
//setTimeout(() => {
|
|
|
|
// obj.classList.remove("modified");
|
|
|
|
//}, 1000);
|
2021-11-12 22:17:46 +01:00
|
|
|
}
|
|
|
|
);
|
2021-11-13 12:07:22 +01:00
|
|
|
return true;
|
2021-11-12 22:17:46 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|