1
0
forked from ScoDoc/ScoDoc

urls in javascripts

This commit is contained in:
Emmanuel Viennet 2021-06-21 18:46:35 +02:00
parent 70eab84330
commit f177e777a9
9 changed files with 373 additions and 369 deletions

View File

@ -28,7 +28,7 @@ function ajaxFunction(mod, etudid, dat) {
document.getElementById("AjaxDiv").innerHTML = ajaxRequest.responseText; document.getElementById("AjaxDiv").innerHTML = ajaxRequest.responseText;
} }
} }
ajaxRequest.open("POST", "doSignaleAbsenceGrSemestre", true); ajaxRequest.open("POST", SCO_URL + "Absences/doSignaleAbsenceGrSemestre", true);
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
var oSelectOne = $("#abs_form")[0].elements["moduleimpl_id"]; var oSelectOne = $("#abs_form")[0].elements["moduleimpl_id"];
var index = oSelectOne.selectedIndex; var index = oSelectOne.selectedIndex;

View File

@ -1,25 +1,26 @@
function _partition_set_attr(partition_id, attr_name, attr_value) { function _partition_set_attr(partition_id, attr_name, attr_value) {
$.post('partition_set_attr', $.post(SCO_URL + '/partition_set_attr',
{ 'partition_id' : partition_id, {
'attr' : attr_name, 'partition_id': partition_id,
'value' : attr_value 'attr': attr_name,
}, 'value': attr_value
function(result) { },
sco_message(result); function (result) {
}); sco_message(result);
});
return; return;
} }
// Met à jour bul_show_rank lorsque checkbox modifiees: // Met à jour bul_show_rank lorsque checkbox modifiees:
function update_rk(e) { function update_rk(e) {
var partition_id = $(e).attr('data-partition_id'); var partition_id = $(e).attr('data-partition_id');
var v; var v;
if (e.checked) if (e.checked)
v='1'; v = '1';
else else
v='0'; v = '0';
_partition_set_attr(partition_id, 'bul_show_rank', v); _partition_set_attr(partition_id, 'bul_show_rank', v);
} }
@ -28,10 +29,10 @@ function update_show_in_list(e) {
var partition_id = $(e).attr('data-partition_id'); var partition_id = $(e).attr('data-partition_id');
var v; var v;
if (e.checked) if (e.checked)
v='1'; v = '1';
else else
v='0'; v = '0';
_partition_set_attr(partition_id, 'show_in_lists', v); _partition_set_attr(partition_id, 'show_in_lists', v);
} }

View File

@ -1,6 +1,6 @@
// Affiche et met a jour la liste des UE partageant le meme code // Affiche et met a jour la liste des UE partageant le meme code
$().ready(function(){ $().ready(function () {
update_ue_list(); update_ue_list();
$("#tf_ue_code").bind("keyup", update_ue_list); $("#tf_ue_code").bind("keyup", update_ue_list);
}); });
@ -9,8 +9,8 @@ $().ready(function(){
function update_ue_list() { function update_ue_list() {
var ue_id = $("#tf_ue_id")[0].value; var ue_id = $("#tf_ue_id")[0].value;
var ue_code = $("#tf_ue_code")[0].value; var ue_code = $("#tf_ue_code")[0].value;
var query = "ue_sharing_code?ue_code=" + ue_code +"&hide_ue_id=" + ue_id + "&ue_id=" + ue_id; var query = SCO_URL + "/Notes/ue_sharing_code?ue_code=" + ue_code + "&hide_ue_id=" + ue_id + "&ue_id=" + ue_id;
$.get( query, '', function(data){ $.get(query, '', function (data) {
$("#ue_list_code").html(data); $("#ue_list_code").html(data);
}); });
} }

View File

@ -3,7 +3,7 @@
// console.log('etud_debouche.js loaded'); // console.log('etud_debouche.js loaded');
$(function() { $(function () {
display_itemsuivis(false); display_itemsuivis(false);
}); });
@ -11,127 +11,127 @@ $(function() {
function display_itemsuivis(active) { function display_itemsuivis(active) {
var etudid = $('div#fichedebouche').data("etudid"); var etudid = $('div#fichedebouche').data("etudid");
var readonly = $('div#fichedebouche').data('readonly'); // present ro interface var readonly = $('div#fichedebouche').data('readonly'); // present ro interface
if (!readonly) { if (!readonly) {
$('#adddebouchelink').off("click").click(function(e){ $('#adddebouchelink').off("click").click(function (e) {
e.preventDefault(); e.preventDefault();
$.post( "itemsuivi_create", { etudid: etudid, format:'json' } ).done( item_insert_new ); $.post(SCO_URL + "itemsuivi_create", { etudid: etudid, format: 'json' }).done(item_insert_new);
return false; return false;
}); });
} }
// add existing items // add existing items
$.get( 'itemsuivi_list_etud', { etudid: etudid, format: 'json' }, function(L) { $.get(SCO_URL + "/itemsuivi_list_etud", { etudid: etudid, format: 'json' }, function (L) {
for (var i in L) { for (var i in L) {
item_insert( L[i]['itemsuivi_id'], L[i]['item_date'], L[i]['situation'], L[i]['tags'], readonly ); item_insert(L[i]['itemsuivi_id'], L[i]['item_date'], L[i]['situation'], L[i]['tags'], readonly);
} }
}); });
$( "div#fichedebouche" ).accordion( { $("div#fichedebouche").accordion({
heightStyle: "content", heightStyle: "content",
collapsible: true, collapsible: true,
active: active, active: active,
}); });
} }
function item_insert_new( it ) { function item_insert_new(it) {
item_insert( it.itemsuivi_id, it.item_date, it.situation, '', false ); item_insert(it.itemsuivi_id, it.item_date, it.situation, '', false);
} }
function item_insert( itemsuivi_id, item_date, situation, tags, readonly ) { function item_insert(itemsuivi_id, item_date, situation, tags, readonly) {
if ( item_date === undefined ) if (item_date === undefined)
item_date = Date2DMY(new Date()); item_date = Date2DMY(new Date());
if ( situation === undefined ) if (situation === undefined)
situation = ''; situation = '';
if ( tags === undefined ) if (tags === undefined)
tags = ''; tags = '';
var nodes = item_nodes(itemsuivi_id, item_date, situation, tags, readonly); var nodes = item_nodes(itemsuivi_id, item_date, situation, tags, readonly);
// insert just before last li: // insert just before last li:
if ($('ul.listdebouches li.adddebouche').length > 0) { if ($('ul.listdebouches li.adddebouche').length > 0) {
$('ul.listdebouches').children(':last').before(nodes); $('ul.listdebouches').children(':last').before(nodes);
} else { } else {
// mode readonly, pas de li "ajouter" // mode readonly, pas de li "ajouter"
$('ul.listdebouches').append(nodes); $('ul.listdebouches').append(nodes);
} }
}; };
function item_nodes(itemsuivi_id, item_date, situation, tags, readonly) { function item_nodes(itemsuivi_id, item_date, situation, tags, readonly) {
// console.log('item_nodes: itemsuivi_id=' + itemsuivi_id); // console.log('item_nodes: itemsuivi_id=' + itemsuivi_id);
var sel_mois = 'Situation à la date du <input type="text" class="itemsuividatepicker" size="10" value="' + item_date + '"/><span class="itemsuivi_suppress" onclick="itemsuivi_suppress(\''+itemsuivi_id+'\')"><img width="10" height="9" border="0" title="" alt="supprimer cet item" src="/ScoDoc/static/icons/delete_small_img.png"/></span>'; var sel_mois = 'Situation à la date du <input type="text" class="itemsuividatepicker" size="10" value="' + item_date + '"/><span class="itemsuivi_suppress" onclick="itemsuivi_suppress(\'' + itemsuivi_id + '\')"><img width="10" height="9" border="0" title="" alt="supprimer cet item" src="/ScoDoc/static/icons/delete_small_img.png"/></span>';
var h = sel_mois; var h = sel_mois;
// situation // situation
h += '<div class="itemsituation editable" data-type="textarea" data-url="itemsuivi_set_situation" data-placeholder="<em>décrire situation...</em>" data-object="' + itemsuivi_id + '">' + situation + '</div>'; h += '<div class="itemsituation editable" data-type="textarea" data-url="itemsuivi_set_situation" data-placeholder="<em>décrire situation...</em>" data-object="' + itemsuivi_id + '">' + situation + '</div>';
// tags: // tags:
h += '<div class="itemsuivi_tag_edit"><textarea class="itemsuivi_tag_editor">' + tags + '</textarea></div>'; h += '<div class="itemsuivi_tag_edit"><textarea class="itemsuivi_tag_editor">' + tags + '</textarea></div>';
var nodes = $($.parseHTML( '<li class="itemsuivi">' + h + '</li>' )); var nodes = $($.parseHTML('<li class="itemsuivi">' + h + '</li>'));
var dp = nodes.find('.itemsuividatepicker'); var dp = nodes.find('.itemsuividatepicker');
dp.blur( function(e) { dp.blur(function (e) {
var date = this.value; var date = this.value;
// console.log('selected text: ' + date); // console.log('selected text: ' + date);
$.post( "itemsuivi_set_date", { item_date: date, itemsuivi_id: itemsuivi_id } ); $.post(SCO_URL + "/itemsuivi_set_date", { item_date: date, itemsuivi_id: itemsuivi_id });
}); });
dp.datepicker({ dp.datepicker({
onSelect: function(date, instance) { onSelect: function (date, instance) {
// console.log('selected: ' + date + 'for itemsuivi_id ' + itemsuivi_id); // console.log('selected: ' + date + 'for itemsuivi_id ' + itemsuivi_id);
$.post( "itemsuivi_set_date", { item_date: date, itemsuivi_id: itemsuivi_id } ); $.post(SCO_URL + "/itemsuivi_set_date", { item_date: date, itemsuivi_id: itemsuivi_id });
}, },
showOn: 'button', showOn: 'button',
buttonImage: '/ScoDoc/static/icons/calendar_img.png', buttonImage: '/ScoDoc/static/icons/calendar_img.png',
buttonImageOnly: true, buttonImageOnly: true,
dateFormat: 'dd/mm/yy', dateFormat: 'dd/mm/yy',
duration : 'fast', duration: 'fast',
disabled: readonly disabled: readonly
}); });
dp.datepicker('option', $.extend({showMonthAfterYear: false}, dp.datepicker('option', $.extend({ showMonthAfterYear: false },
$.datepicker.regional['fr'])); $.datepicker.regional['fr']));
if (readonly) { if (readonly) {
// show tags read-only // show tags read-only
readOnlyTags(nodes.find('.itemsuivi_tag_editor')); readOnlyTags(nodes.find('.itemsuivi_tag_editor'));
} }
else { else {
// bind tag editor // bind tag editor
nodes.find('.itemsuivi_tag_editor').tagEditor({ nodes.find('.itemsuivi_tag_editor').tagEditor({
initialTags: '', initialTags: '',
placeholder: 'Tags...', placeholder: 'Tags...',
onChange: function(field, editor, tags) { onChange: function (field, editor, tags) {
$.post('itemsuivi_tag_set', $.post('itemsuivi_tag_set',
{ {
itemsuivi_id: itemsuivi_id, itemsuivi_id: itemsuivi_id,
taglist: tags.join() taglist: tags.join()
}); });
}, },
autocomplete: { autocomplete: {
delay: 200, // ms before suggest delay: 200, // ms before suggest
position: { collision: 'flip' }, // automatic menu position up/down position: { collision: 'flip' }, // automatic menu position up/down
source: "itemsuivi_tag_search" source: "itemsuivi_tag_search"
}, },
}); });
// bind inplace editor // bind inplace editor
nodes.find('div.itemsituation').jinplace(); nodes.find('div.itemsituation').jinplace();
} }
return nodes; return nodes;
}; };
function Date2DMY(date) { function Date2DMY(date) {
var year = date.getFullYear(); var year = date.getFullYear();
var month = (1 + date.getMonth()).toString(); var month = (1 + date.getMonth()).toString();
month = month.length > 1 ? month : '0' + month; month = month.length > 1 ? month : '0' + month;
var day = date.getDate().toString(); var day = date.getDate().toString();
day = day.length > 1 ? day : '0' + day; day = day.length > 1 ? day : '0' + day;
return day + '/' + month + '/' + year; return day + '/' + month + '/' + year;
} }
function itemsuivi_suppress(itemsuivi_id) { function itemsuivi_suppress(itemsuivi_id) {
$.post( "itemsuivi_suppress", { itemsuivi_id: itemsuivi_id } ); $.post(SCO_URL + "/itemsuivi_suppress", { itemsuivi_id: itemsuivi_id });
// Clear items and rebuild: // Clear items and rebuild:
$("ul.listdebouches li.itemsuivi").remove(); $("ul.listdebouches li.itemsuivi").remove();
display_itemsuivis(0); display_itemsuivis(0);

View File

@ -6,7 +6,7 @@
/* --- Globals ---- */ /* --- Globals ---- */
var EtudColors = [ "#E8EEF7", "#ffffff" ]; // [ "#E8EEF7", "#E0ECFF", "#E5E6BE", "#F3EAE2", "#E3EAE1" ]; var EtudColors = ["#E8EEF7", "#ffffff"]; // [ "#E8EEF7", "#E0ECFF", "#E5E6BE", "#F3EAE2", "#E3EAE1" ];
var EtudColorsIdx = 0; var EtudColorsIdx = 0;
var NbEtuds = 0; var NbEtuds = 0;
var ETUDS = new Object(); // { etudid : etud } var ETUDS = new Object(); // { etudid : etud }
@ -19,46 +19,46 @@ function loadGroupes() {
$("#gmsg")[0].innerHTML = 'Chargement des groupes en cours...'; $("#gmsg")[0].innerHTML = 'Chargement des groupes en cours...';
var partition_id = document.formGroup.partition_id.value; var partition_id = document.formGroup.partition_id.value;
$.get('XMLgetGroupsInPartition', { partition_id : partition_id } ) $.get(SCO_URL + 'XMLgetGroupsInPartition', { partition_id: partition_id })
.done( .done(
function( data ) { function (data) {
var nodes = data.getElementsByTagName('group'); var nodes = data.getElementsByTagName('group');
if (nodes) { if (nodes) {
var nbgroups = nodes.length; var nbgroups = nodes.length;
// put last group at first (etudiants sans groupes) // put last group at first (etudiants sans groupes)
if (nodes.length > 1 && nodes[nbgroups-1].attributes.getNamedItem("group_id").value == '_none_') { if (nodes.length > 1 && nodes[nbgroups - 1].attributes.getNamedItem("group_id").value == '_none_') {
populateGroup(nodes[nodes.length-1]); populateGroup(nodes[nodes.length - 1]);
nbgroups -= 1; nbgroups -= 1;
} }
// then standard groups // then standard groups
for (var i=0; i < nbgroups; i++) { for (var i = 0; i < nbgroups; i++) {
populateGroup(nodes[i]); populateGroup(nodes[i]);
} }
} }
$("#gmsg")[0].innerHTML = ''; $("#gmsg")[0].innerHTML = '';
updateginfo(); updateginfo();
} }
) )
} }
function populateGroup( node ) { function populateGroup(node) {
var group_id = node.attributes.getNamedItem("group_id").value; var group_id = node.attributes.getNamedItem("group_id").value;
var group_name = node.attributes.getNamedItem("group_name").value; var group_name = node.attributes.getNamedItem("group_name").value;
// CREE LA BOITE POUR CE GROUPE // CREE LA BOITE POUR CE GROUPE
if (group_id) { if (group_id) {
var gbox = new CGroupBox( group_id, group_name ); var gbox = new CGroupBox(group_id, group_name);
var etuds = node.getElementsByTagName('etud'); var etuds = node.getElementsByTagName('etud');
var x=''; var x = '';
gbox.sorting = false; // disable to speedup gbox.sorting = false; // disable to speedup
EtudColorsIdx = 0; // repart de la premiere couleur EtudColorsIdx = 0; // repart de la premiere couleur
for (var j=0; j < etuds.length; j++) { for (var j = 0; j < etuds.length; j++) {
var nom = etuds[j].attributes.getNamedItem("nom").value; var nom = etuds[j].attributes.getNamedItem("nom").value;
var prenom = etuds[j].attributes.getNamedItem("prenom").value; var prenom = etuds[j].attributes.getNamedItem("prenom").value;
var sexe = etuds[j].attributes.getNamedItem("sexe").value; var sexe = etuds[j].attributes.getNamedItem("sexe").value;
var etudid = etuds[j].attributes.getNamedItem("etudid").value; var etudid = etuds[j].attributes.getNamedItem("etudid").value;
var origin = etuds[j].attributes.getNamedItem("origin").value; var origin = etuds[j].attributes.getNamedItem("origin").value;
var etud = new CDraggableEtud( nom, prenom, sexe, origin, etudid ); var etud = new CDraggableEtud(nom, prenom, sexe, origin, etudid);
gbox.createEtudInGroup(etud, group_id); gbox.createEtudInGroup(etud, group_id);
} }
gbox.sorting = true; gbox.sorting = true;
@ -72,14 +72,14 @@ function populateGroup( node ) {
var groupBoxes = new Object(); // assoc group_id : groupBox var groupBoxes = new Object(); // assoc group_id : groupBox
var groupsToDelete = new Object(); // list of group_id to be supressed var groupsToDelete = new Object(); // list of group_id to be supressed
var CGroupBox = function(group_id, group_name) { var CGroupBox = function (group_id, group_name) {
group_id = $.trim(group_id); group_id = $.trim(group_id);
var regex = /^\w+$/; var regex = /^\w+$/;
if (! regex.test(group_id) ) { if (!regex.test(group_id)) {
alert("Id de groupe invalide"); alert("Id de groupe invalide");
return; return;
} }
if ( group_id in groups ) { if (group_id in groups) {
alert("Le groupe " + group_id + " existe déjà !"); alert("Le groupe " + group_id + " existe déjà !");
return; return;
} }
@ -90,7 +90,7 @@ var CGroupBox = function(group_id, group_name) {
this.nbetuds = 0; this.nbetuds = 0;
this.isNew = false; // true for newly user-created groups this.isNew = false; // true for newly user-created groups
this.sorting = true; // false to disable sorting this.sorting = true; // false to disable sorting
this.groupBox = document.createElement("div"); this.groupBox = document.createElement("div");
this.groupBox.className = "simpleDropPanel"; this.groupBox.className = "simpleDropPanel";
this.groupBox.id = group_id; this.groupBox.id = group_id;
@ -103,13 +103,13 @@ var CGroupBox = function(group_id, group_name) {
this.updateTitle(); this.updateTitle();
$(this.groupBox).droppable( $(this.groupBox).droppable(
{ {
accept : ".box", accept: ".box",
activeClass: "activatedPanel", activeClass: "activatedPanel",
drop: function( event, ui ) { drop: function (event, ui) {
// alert("drop on " + this.group_name); // alert("drop on " + this.group_name);
var etudid = ui.draggable[0].id; var etudid = ui.draggable[0].id;
var etud = ETUDS[etudid]; var etud = ETUDS[etudid];
var newGroupName = this.id; var newGroupName = this.id;
var oldGroupName = ETUD_GROUP[etudid]; var oldGroupName = ETUD_GROUP[etudid];
$(groupBoxes[newGroupName].groupBox).append(ui.draggable) $(groupBoxes[newGroupName].groupBox).append(ui.draggable)
ui.draggable[0].style.left = ""; // fix style (?) ui.draggable[0].style.left = ""; // fix style (?)
@ -119,7 +119,7 @@ var CGroupBox = function(group_id, group_name) {
} }
}); });
/* On peut s'amuser a deplacer tout un groupe (visuellement: pas droppable) */ /* On peut s'amuser a deplacer tout un groupe (visuellement: pas droppable) */
$(this.groupBox).draggable( { $(this.groupBox).draggable({
cursor: 'move', cursor: 'move',
containment: '#groups' containment: '#groups'
}); });
@ -130,25 +130,25 @@ var CGroupBox = function(group_id, group_name) {
$.extend(CGroupBox.prototype, { $.extend(CGroupBox.prototype, {
// menu for group title // menu for group title
groupTitle : function() { groupTitle: function () {
var menuSpan = document.createElement("span"); var menuSpan = document.createElement("span");
menuSpan.className = "barrenav"; menuSpan.className = "barrenav";
var h = "<table><tr><td><ul class=\"nav\"><li onmouseover=\"MenuDisplay(this)\" onmouseout=\"MenuHide(this)\"><a href=\"#\" class=\"menu custommenu\"><span id=\"titleSpan" + this.group_id + "\" class=\"groupTitle\">menu</span></a><ul>"; var h = "<table><tr><td><ul class=\"nav\"><li onmouseover=\"MenuDisplay(this)\" onmouseout=\"MenuHide(this)\"><a href=\"#\" class=\"menu custommenu\"><span id=\"titleSpan" + this.group_id + "\" class=\"groupTitle\">menu</span></a><ul>";
if (this.group_id != '_none_') { if (this.group_id != '_none_') {
h += "<li><a href=\"#\" onClick=\"suppressGroup('" + this.group_id + "');\">Supprimer</a></li>"; h += "<li><a href=\"#\" onClick=\"suppressGroup('" + this.group_id + "');\">Supprimer</a></li>";
h += "<li><a href=\"#\" onClick=\"renameGroup('" + this.group_id + "');\">Renommer</a></li>"; h += "<li><a href=\"#\" onClick=\"renameGroup('" + this.group_id + "');\">Renommer</a></li>";
} }
h += "</ul></li></ul></td></tr></table>"; h += "</ul></li></ul></td></tr></table>";
menuSpan.innerHTML = h; menuSpan.innerHTML = h;
return menuSpan; return menuSpan;
}, },
// add etud to group, attach to DOM // add etud to group, attach to DOM
createEtudInGroup: function(etud) { createEtudInGroup: function (etud) {
this.addEtudToGroup(etud); this.addEtudToGroup(etud);
this.groupBox.appendChild(etud.htmlElement); this.groupBox.appendChild(etud.htmlElement);
}, },
// add existing etud to group (does not affect DOM) // add existing etud to group (does not affect DOM)
addEtudToGroup: function(etud) { addEtudToGroup: function (etud) {
etud.group_id = this.group_id; etud.group_id = this.group_id;
this.etuds[etud.etudid] = etud; this.etuds[etud.etudid] = etud;
this.nbetuds++; this.nbetuds++;
@ -156,45 +156,45 @@ $.extend(CGroupBox.prototype, {
this.updateTitle(); this.updateTitle();
}, },
// remove etud // remove etud
removeEtud: function(etud) { removeEtud: function (etud) {
delete this.etuds[etud.etudid]; delete this.etuds[etud.etudid];
this.nbetuds--; this.nbetuds--;
this.updateTitle(); this.updateTitle();
}, },
// Update counter display // Update counter display
updateTitle: function() { updateTitle: function () {
var tclass = ''; var tclass = '';
if (this.isNew) { if (this.isNew) {
tclass = ' class="newgroup"' tclass = ' class="newgroup"'
} }
var titleSpan = document.getElementById('titleSpan'+this.group_id); var titleSpan = document.getElementById('titleSpan' + this.group_id);
if (this.group_id != '_none_') if (this.group_id != '_none_')
titleSpan.innerHTML = '<span'+tclass+'>Groupe ' + this.group_name + ' (' + this.nbetuds + ')</span>'; titleSpan.innerHTML = '<span' + tclass + '>Groupe ' + this.group_name + ' (' + this.nbetuds + ')</span>';
else else
titleSpan.innerHTML = '<span'+tclass+'>Etudiants sans groupe' + ' (' + this.nbetuds + ')</span>'; titleSpan.innerHTML = '<span' + tclass + '>Etudiants sans groupe' + ' (' + this.nbetuds + ')</span>';
this.sortList(); // maintient toujours la liste triee this.sortList(); // maintient toujours la liste triee
}, },
// Tri de la boite par nom // Tri de la boite par nom
sortList: function() { sortList: function () {
if (!this.sorting) if (!this.sorting)
return; return;
var newRows = new Array(); var newRows = new Array();
for (var i=1; i < this.groupBox.childNodes.length; i++) { // 1 car div titre for (var i = 1; i < this.groupBox.childNodes.length; i++) { // 1 car div titre
newRows[i-1] = this.groupBox.childNodes[i]; newRows[i - 1] = this.groupBox.childNodes[i];
} }
var sortfn = function(a,b) { var sortfn = function (a, b) {
// recupere les noms qui sont dans un span // recupere les noms qui sont dans un span
var nom_a = a.childNodes[1].childNodes[0].nodeValue; var nom_a = a.childNodes[1].childNodes[0].nodeValue;
var nom_b = b.childNodes[1].childNodes[0].nodeValue; var nom_b = b.childNodes[1].childNodes[0].nodeValue;
// console.log( 'comp( %s, %s )', nom_a, nom_b ); // console.log( 'comp( %s, %s )', nom_a, nom_b );
if (nom_a == nom_b) if (nom_a == nom_b)
return 0; return 0;
if (nom_a < nom_b) if (nom_a < nom_b)
return -1; return -1;
return 1; return 1;
}; };
newRows.sort(sortfn); newRows.sort(sortfn);
for (var i=0;i<newRows.length;i++) { for (var i = 0; i < newRows.length; i++) {
this.groupBox.appendChild(newRows[i]); this.groupBox.appendChild(newRows[i]);
newRows[i].style.backgroundColor = EtudColors[EtudColorsIdx]; newRows[i].style.backgroundColor = EtudColors[EtudColorsIdx];
EtudColorsIdx = (EtudColorsIdx + 1) % EtudColors.length; EtudColorsIdx = (EtudColorsIdx + 1) % EtudColors.length;
@ -203,11 +203,11 @@ $.extend(CGroupBox.prototype, {
}); });
function suppressGroup( group_id ) { function suppressGroup(group_id) {
// 1- associate all members to group _none_ // 1- associate all members to group _none_
if (!groupBoxes['_none_']) { if (!groupBoxes['_none_']) {
// create group _none_ // create group _none_
var gbox = new CGroupBox( '_none_', 'Etudiants sans groupe' ); var gbox = new CGroupBox('_none_', 'Etudiants sans groupe');
} }
var dst_group_id = groupBoxes['_none_'].group_id; var dst_group_id = groupBoxes['_none_'].group_id;
var src_box_etuds = groupBoxes[group_id].etuds; var src_box_etuds = groupBoxes[group_id].etuds;
@ -229,13 +229,13 @@ function suppressGroup( group_id ) {
} }
function renameGroup( group_id ) { function renameGroup(group_id) {
// 1-- save modifications // 1-- save modifications
if (groups_unsaved) { if (groups_unsaved) {
alert("Enregistrez ou annulez vos changement avant !"); alert("Enregistrez ou annulez vos changement avant !");
} else { } else {
// 2- form rename // 2- form rename
document.location='group_rename?group_id=' + group_id; document.location = 'group_rename?group_id=' + group_id;
} }
} }
@ -257,26 +257,26 @@ function createGroup() {
return false; return false;
} }
// check name: // check name:
for (var group_id in groupBoxes) { for (var group_id in groupBoxes) {
if (group_id != 'extend') { if (group_id != 'extend') {
if (groupBoxes[group_id].group_name == group_name) { if (groupBoxes[group_id].group_name == group_name) {
alert("Nom de groupe déja existant !"); alert("Nom de groupe déja existant !");
return false; return false;
} }
} }
} }
var group_id = newGroupId(); var group_id = newGroupId();
groups_unsaved = true; groups_unsaved = true;
var gbox = new CGroupBox( group_id, group_name ); var gbox = new CGroupBox(group_id, group_name);
gbox.isNew = true; gbox.isNew = true;
gbox.updateTitle(); gbox.updateTitle();
return true; return true;
} }
/* --- Etudiant draggable --- */ /* --- Etudiant draggable --- */
var CDraggableEtud = function(nom, prenom, sexe, origin, etudid) { var CDraggableEtud = function (nom, prenom, sexe, origin, etudid) {
this.type = 'Custom'; this.type = 'Custom';
this.name = etudid; this.name = etudid;
this.etudid = etudid; this.etudid = etudid;
this.nom = nom; this.nom = nom;
this.prenom = prenom; this.prenom = prenom;
@ -284,14 +284,14 @@ var CDraggableEtud = function(nom, prenom, sexe, origin, etudid) {
this.origin = origin; this.origin = origin;
this.createNode(); this.createNode();
ETUDS[etudid] = this; ETUDS[etudid] = this;
NbEtuds ++; NbEtuds++;
} }
$.extend(CDraggableEtud.prototype, { $.extend(CDraggableEtud.prototype, {
repr: function() { repr: function () {
return this.sexe + ' ' + this.prenom + ' <span class="nom">' + this.nom + '</span> ' + '<b>'+this.origin+'</b>'; return this.sexe + ' ' + this.prenom + ' <span class="nom">' + this.nom + '</span> ' + '<b>' + this.origin + '</b>';
}, },
createNode: function() { createNode: function () {
// Create DOM element for student // Create DOM element for student
var e = document.createElement("div"); var e = document.createElement("div");
this.htmlElement = e; this.htmlElement = e;
@ -303,39 +303,39 @@ $.extend(CDraggableEtud.prototype, {
//e.appendChild(txtNode); //e.appendChild(txtNode);
e.innerHTML = this.repr(); e.innerHTML = this.repr();
// declare as draggable // declare as draggable
$(e).draggable( { $(e).draggable({
cursor: 'move', cursor: 'move',
stack: '#groups div', stack: '#groups div',
containment: '#groups', containment: '#groups',
revert: 'invalid' revert: 'invalid'
}); });
}, },
endDrag: function() { endDrag: function () {
var el = this.htmlElement; var el = this.htmlElement;
var p = el.parentNode; var p = el.parentNode;
// alert("endDrag: [" + this.name +"] " + p.id ); // alert("endDrag: [" + this.name +"] " + p.id );
this.changeGroup( this.group_id, p.id ); this.changeGroup(this.group_id, p.id);
this.htmlElement.style.fontStyle = 'italic'; // italic pour les etudiants deplaces this.htmlElement.style.fontStyle = 'italic'; // italic pour les etudiants deplaces
}, },
// Move a student from a group to another // Move a student from a group to another
changeGroup: function( oldGroupName, newGroupName ) { changeGroup: function (oldGroupName, newGroupName) {
if (oldGroupName==newGroupName) { if (oldGroupName == newGroupName) {
// drop on original group, just sort // drop on original group, just sort
groupBoxes[oldGroupName].updateTitle(); groupBoxes[oldGroupName].updateTitle();
return; return;
} }
var oldGroupBox = null; var oldGroupBox = null;
if (oldGroupName) { if (oldGroupName) {
oldGroupBox = groupBoxes[oldGroupName]; oldGroupBox = groupBoxes[oldGroupName];
} }
var newGroupBox = groupBoxes[newGroupName]; var newGroupBox = groupBoxes[newGroupName];
newGroupBox.addEtudToGroup(this); newGroupBox.addEtudToGroup(this);
if (oldGroupBox) if (oldGroupBox)
oldGroupBox.removeEtud(this); oldGroupBox.removeEtud(this);
groups_unsaved = true; groups_unsaved = true;
updatesavedinfo(); updatesavedinfo();
} }
}); });
/* --- Upload du resultat --- */ /* --- Upload du resultat --- */
@ -343,66 +343,66 @@ function processResponse(value) {
location.reload(); // necessaire pour reinitialiser les id des groupes créés location.reload(); // necessaire pour reinitialiser les id des groupes créés
} }
function handleError( msg ) { function handleError(msg) {
alert( 'Error: ' + msg ); alert('Error: ' + msg);
console.log( 'Error: ' + msg ); console.log('Error: ' + msg);
} }
function submitGroups() { function submitGroups() {
var url = 'setGroups'; var url = SCO_URL + '/setGroups';
// build post request body: groupname \n etudid; ... // build post request body: groupname \n etudid; ...
var groupsLists = ''; var groupsLists = '';
var groupsToCreate=''; var groupsToCreate = '';
for (var group_id in groupBoxes) { for (var group_id in groupBoxes) {
if (group_id != 'extend') { // je ne sais pas ce dont il s'agit ??? if (group_id != 'extend') { // je ne sais pas ce dont il s'agit ???
if (group_id != '_none_') { // ne renvoie pas le groupe des sans-groupes if (group_id != '_none_') { // ne renvoie pas le groupe des sans-groupes
groupBox = groupBoxes[group_id]; groupBox = groupBoxes[group_id];
if (groupBox.isNew) { if (groupBox.isNew) {
groupsToCreate += groupBox.group_name + ';'; groupsToCreate += groupBox.group_name + ';';
for (var etudid in groupBox.etuds) { for (var etudid in groupBox.etuds) {
if (etudid != 'extend') if (etudid != 'extend')
groupsToCreate += etudid + ';'; groupsToCreate += etudid + ';';
} }
groupsToCreate += '\n'; groupsToCreate += '\n';
groupBox.isNew = false; // is no more new ! groupBox.isNew = false; // is no more new !
} else { } else {
groupsLists += group_id + ';'; groupsLists += group_id + ';';
for (var etudid in groupBox.etuds) { for (var etudid in groupBox.etuds) {
if (etudid != 'extend') if (etudid != 'extend')
groupsLists += etudid + ';'; groupsLists += etudid + ';';
} }
groupsLists += '\n'; groupsLists += '\n';
} }
} }
} }
} }
var todel = ''; var todel = '';
for (var group_id in groupsToDelete) { for (var group_id in groupsToDelete) {
todel += group_id + ';'; todel += group_id + ';';
} }
groupsToDelete = new Object(); // empty groupsToDelete = new Object(); // empty
var partition_id = document.formGroup.partition_id.value; var partition_id = document.formGroup.partition_id.value;
// Send to server // Send to server
$.get( url, { $.get(url, {
groupsLists : groupsLists, // encodeURIComponent groupsLists: groupsLists, // encodeURIComponent
partition_id : partition_id, partition_id: partition_id,
groupsToDelete : todel, groupsToDelete: todel,
groupsToCreate : groupsToCreate groupsToCreate: groupsToCreate
}) })
.done( function (data) { .done(function (data) {
processResponse(data); processResponse(data);
}) })
.fail(function() { .fail(function () {
handleError("Erreur lors de l'enregistrement de groupes"); handleError("Erreur lors de l'enregistrement de groupes");
}); });
} }
// Move to another partition (specified by menu) // Move to another partition (specified by menu)
function GotoAnother() { function GotoAnother() {
if (groups_unsaved) { if (groups_unsaved) {
alert("Enregistrez ou annulez vos changement avant !"); alert("Enregistrez ou annulez vos changement avant !");
} else } else
document.location='affectGroups?partition_id='+document.formGroup.other_partition_id.value; document.location = SCO_URL + '/affectGroups?partition_id=' + document.formGroup.other_partition_id.value;
} }
@ -411,13 +411,13 @@ function updateginfo() {
var g = document.getElementById('ginfo'); var g = document.getElementById('ginfo');
var group_names = new Array(); var group_names = new Array();
for (var group_id in groupBoxes) { for (var group_id in groupBoxes) {
if ((group_id != 'extend') && (groupBoxes[group_id].group_name)){ if ((group_id != 'extend') && (groupBoxes[group_id].group_name)) {
group_names.push(groupBoxes[group_id].group_name); group_names.push(groupBoxes[group_id].group_name);
} }
} }
g.innerHTML = '<b>Groupes définis: ' + group_names.join(', ') + '<br/>' g.innerHTML = '<b>Groupes définis: ' + group_names.join(', ') + '<br/>'
+ "Nombre d'etudiants: " + NbEtuds + '</b>'; + "Nombre d'etudiants: " + NbEtuds + '</b>';
updatesavedinfo(); updatesavedinfo();
} }
@ -426,16 +426,16 @@ function updatesavedinfo() {
var g = document.getElementById('savedinfo'); var g = document.getElementById('savedinfo');
if (groups_unsaved) { if (groups_unsaved) {
g.innerHTML = 'modifications non enregistrées'; g.innerHTML = 'modifications non enregistrées';
g.style.visibility='visible'; g.style.visibility = 'visible';
} else { } else {
g.innerHTML = ''; g.innerHTML = '';
g.style.visibility='hidden'; g.style.visibility = 'hidden';
} }
return true; return true;
} }
$(function() { $(function () {
loadGroupes(); loadGroupes();
}); });

View File

@ -5,7 +5,7 @@
// //
// Ce code utilise d3.js // Ce code utilise d3.js
$().ready(function(){ $().ready(function () {
var etudid = $("#etudid")[0].value; var etudid = $("#etudid")[0].value;
var formsemestre_id = $("#formsemestre_id")[0].value; var formsemestre_id = $("#formsemestre_id")[0].value;
get_notes_and_draw(formsemestre_id, etudid); get_notes_and_draw(formsemestre_id, etudid);
@ -14,12 +14,12 @@ $().ready(function(){
var WIDTH = 460; // taille du canvas SVG var WIDTH = 460; // taille du canvas SVG
var HEIGHT = WIDTH; var HEIGHT = WIDTH;
var CX = WIDTH/2; // coordonnees centre du cercle var CX = WIDTH / 2; // coordonnees centre du cercle
var CY = HEIGHT/2; var CY = HEIGHT / 2;
var RR = 0.4*WIDTH; // Rayon du cercle exterieur var RR = 0.4 * WIDTH; // Rayon du cercle exterieur
/* Emplacements des marques (polygones et axe gradué) */ /* Emplacements des marques (polygones et axe gradué) */
var R_TICS = [ 8, 10, 20 ]; /* [6, 8, 10, 12, 14, 16, 18, 20]; */ var R_TICS = [8, 10, 20]; /* [6, 8, 10, 12, 14, 16, 18, 20]; */
var R_AXIS_TICS = [4, 6, 8, 10, 12, 14, 16, 18, 20]; var R_AXIS_TICS = [4, 6, 8, 10, 12, 14, 16, 18, 20];
var NB_TICS = R_TICS.length; var NB_TICS = R_TICS.length;
@ -33,72 +33,75 @@ function get_notes_and_draw(formsemestre_id, etudid) {
'moy' : 16 }, 'moy' : 16 },
]; ];
*/ */
var query = "formsemestre_bulletinetud?formsemestre_id=" + formsemestre_id + "&etudid=" + etudid + "&format=json&version=selectedevals&force_publishing=1" var query = SCO_URL + "/Notes/formsemestre_bulletinetud?formsemestre_id=" + formsemestre_id + "&etudid=" + etudid + "&format=json&version=selectedevals&force_publishing=1"
$.get( query, '', function(bul){ $.get(query, '', function (bul) {
var notes = []; var notes = [];
bul.ue.forEach( bul.ue.forEach(
function(ue, i, ues) { function (ue, i, ues) {
ue['module'].forEach( function(m, i) { ue['module'].forEach(function (m, i) {
notes.push( { 'code': m['code'], notes.push({
'titre' : m['titre'], 'code': m['code'],
'note':m['note']['value'], 'titre': m['titre'],
'moy':m['note']['moy'] } ); 'note': m['note']['value'],
}); } ); 'moy': m['note']['moy']
draw_radar(notes); });
});
});
draw_radar(notes);
}); });
} }
function draw_radar(notes) { function draw_radar(notes) {
/* Calcul coordonnées des éléments */ /* Calcul coordonnées des éléments */
var nmod = notes.length; var nmod = notes.length;
var angle = 2*Math.PI/nmod; var angle = 2 * Math.PI / nmod;
for (var i=0; i<notes.length; i++) { for (var i = 0; i < notes.length; i++) {
var d = notes[i]; var d = notes[i];
var cx = Math.sin(i*angle); var cx = Math.sin(i * angle);
var cy = - Math.cos(i*angle); var cy = - Math.cos(i * angle);
d["x_v"] = CX + RR * d.note/20 * cx; d["x_v"] = CX + RR * d.note / 20 * cx;
d["y_v"] = CY + RR * d.note/20 * cy; d["y_v"] = CY + RR * d.note / 20 * cy;
d["x_moy"] = CX + RR * d.moy/20 * cx; d["x_moy"] = CX + RR * d.moy / 20 * cx;
d["y_moy"] = CY + RR * d.moy/20 * cy; d["y_moy"] = CY + RR * d.moy / 20 * cy;
d["x_20"] = CX + RR * cx; d["x_20"] = CX + RR * cx;
d["y_20"] = CY + RR * cy; d["y_20"] = CY + RR * cy;
d["x_label"] = CX + (RR + 25) * cx - 10 d["x_label"] = CX + (RR + 25) * cx - 10
d["y_label"] = CY + (RR + 25) * cy + 10; d["y_label"] = CY + (RR + 25) * cy + 10;
d["tics"] = []; d["tics"] = [];
// Coords des tics sur chaque axe // Coords des tics sur chaque axe
for (var j=0; j < NB_TICS; j++) { for (var j = 0; j < NB_TICS; j++) {
var r = R_TICS[j]/20 * RR; var r = R_TICS[j] / 20 * RR;
d["tics"][j] = { "x" : CX + r * cx, "y" : CY + r * cy }; d["tics"][j] = { "x": CX + r * cx, "y": CY + r * cy };
} }
} }
var notes_circ = notes.slice(0); var notes_circ = notes.slice(0);
notes_circ.push(notes[0]) notes_circ.push(notes[0])
var notes_circ_valid = notes_circ.filter( function(e,i,a) { return e.note != 'NA' && e.note != '-'; } ); var notes_circ_valid = notes_circ.filter(function (e, i, a) { return e.note != 'NA' && e.note != '-'; });
var notes_valid = notes.filter( function(e,i,a) { return e.note != 'NA' && e.note != '-'; } ) var notes_valid = notes.filter(function (e, i, a) { return e.note != 'NA' && e.note != '-'; })
/* Crée l'élément SVG */ /* Crée l'élément SVG */
g = d3.select("#radar_bulletin").append("svg") g = d3.select("#radar_bulletin").append("svg")
.attr("class", "radar") .attr("class", "radar")
.attr("width", WIDTH+100) .attr("width", WIDTH + 100)
.attr("height", HEIGHT); .attr("height", HEIGHT);
/* Centre */ /* Centre */
g.append( "circle" ).attr("cy", CY) g.append("circle").attr("cy", CY)
.attr("cx", CX) .attr("cx", CX)
.attr("r", 2) .attr("r", 2)
.attr("class", "radar_center_mark"); .attr("class", "radar_center_mark");
/* Lignes "tics" */ /* Lignes "tics" */
for (var j=0; j < NB_TICS; j++) { for (var j = 0; j < NB_TICS; j++) {
var ligne_tics = d3.svg.line() var ligne_tics = d3.svg.line()
.x(function(d) { return d["tics"][j]["x"]; }) .x(function (d) { return d["tics"][j]["x"]; })
.y(function(d) { return d["tics"][j]["y"]; }); .y(function (d) { return d["tics"][j]["y"]; });
g.append( "svg:path" ) g.append("svg:path")
.attr("class", "radar_disk_tic") .attr("class", "radar_disk_tic")
.attr("id", "radar_disk_tic_" + R_TICS[j]) .attr("id", "radar_disk_tic_" + R_TICS[j])
.attr("d", ligne_tics(notes_circ)); .attr("d", ligne_tics(notes_circ));
} }
@ -108,25 +111,25 @@ function draw_radar(notes) {
.enter().append("line") .enter().append("line")
.attr("x1", CX) .attr("x1", CX)
.attr("y1", CY) .attr("y1", CY)
.attr("x2", function(d) { return d["x_20"]; }) .attr("x2", function (d) { return d["x_20"]; })
.attr("y2", function(d) { return d["y_20"]; }) .attr("y2", function (d) { return d["y_20"]; })
.attr("class", "radarrad"); .attr("class", "radarrad");
/* Lignes entre notes */ /* Lignes entre notes */
var ligne = d3.svg.line() var ligne = d3.svg.line()
.x(function(d) { return d["x_v"]; }) .x(function (d) { return d["x_v"]; })
.y(function(d) { return d["y_v"]; }); .y(function (d) { return d["y_v"]; });
g.append( "svg:path" ) g.append("svg:path")
.attr("class", "radarnoteslines") .attr("class", "radarnoteslines")
.attr("d", ligne(notes_circ_valid)); .attr("d", ligne(notes_circ_valid));
var ligne_moy = d3.svg.line() var ligne_moy = d3.svg.line()
.x(function(d) { return d["x_moy"]; }) .x(function (d) { return d["x_moy"]; })
.y(function(d) { return d["y_moy"]; }) .y(function (d) { return d["y_moy"]; })
g.append( "svg:path" ) g.append("svg:path")
.attr("class", "radarmoylines") .attr("class", "radarmoylines")
.attr("d", ligne_moy(notes_circ_valid)); .attr("d", ligne_moy(notes_circ_valid));
@ -134,15 +137,15 @@ function draw_radar(notes) {
g.selectAll("circle1") g.selectAll("circle1")
.data(notes_valid) .data(notes_valid)
.enter().append("circle") .enter().append("circle")
.attr("cx", function(d) { return d["x_v"]; }) .attr("cx", function (d) { return d["x_v"]; })
.attr("cy", function(d) { return d["y_v"]; }) .attr("cy", function (d) { return d["y_v"]; })
.attr("r", function(x, i) { return 3; } ) .attr("r", function (x, i) { return 3; })
.style("stroke-width", 1) .style("stroke-width", 1)
.style("stroke", "black") .style("stroke", "black")
.style("fill", "blue") .style("fill", "blue")
.on("mouseover", function(d) { .on("mouseover", function (d) {
var rwidth = 310; var rwidth = 310;
var x = d["x_v"]; var x = d["x_v"];
if ((x - CX) < 0) { if ((x - CX) < 0) {
x = x + 5; x = x + 5;
if (x + rwidth + 12 > WIDTH) { if (x + rwidth + 12 > WIDTH) {
@ -157,7 +160,7 @@ function draw_radar(notes) {
} }
} }
else { else {
x = CX - rwidth/2; x = CX - rwidth / 2;
} }
} }
var yrect = d["y_v"]; var yrect = d["y_v"];
@ -169,19 +172,19 @@ function draw_radar(notes) {
else { else {
yrect = yrect + 5; yrect = yrect + 5;
ytext = ytext + 5 + 16; ytext = ytext + 5 + 16;
} }
var r = g.append("rect") var r = g.append("rect")
.attr('class','radartip') .attr('class', 'radartip')
.attr("x", x) .attr("x", x)
.attr("y", yrect ); .attr("y", yrect);
var txt = g.append("text").text("Note: " + d.note + "/20, moyenne promo: " + d.moy + "/20") var txt = g.append("text").text("Note: " + d.note + "/20, moyenne promo: " + d.moy + "/20")
.attr('class','radartip') .attr('class', 'radartip')
.attr("x", x + 5) .attr("x", x + 5)
.attr("y", ytext); .attr("y", ytext);
r.attr("width", rwidth).attr("height", 20); r.attr("width", rwidth).attr("height", 20);
}) })
.on("mouseout", function(d){ .on("mouseout", function (d) {
d3.selectAll(".radartip").remove() d3.selectAll(".radartip").remove()
}); });
@ -189,11 +192,11 @@ function draw_radar(notes) {
g.selectAll("notes_labels") g.selectAll("notes_labels")
.data(notes_valid) .data(notes_valid)
.enter().append("text") .enter().append("text")
.text(function(d) { return d["note"]; }) .text(function (d) { return d["note"]; })
.attr("x", function(d) { .attr("x", function (d) {
return d["x_v"]; return d["x_v"];
}) })
.attr("y", function(d) { .attr("y", function (d) {
if (d["y_v"] > CY) if (d["y_v"] > CY)
return d["y_v"] + 16; return d["y_v"] + 16;
else else
@ -205,36 +208,36 @@ function draw_radar(notes) {
g.selectAll("circle2") g.selectAll("circle2")
.data(notes_valid) .data(notes_valid)
.enter().append("circle") .enter().append("circle")
.attr("cx", function(d) { return d["x_moy"]; }) .attr("cx", function (d) { return d["x_moy"]; })
.attr("cy", function(d) { return d["y_moy"]; }) .attr("cy", function (d) { return d["y_moy"]; })
.attr("r", function(x, i) { return 2; } ) .attr("r", function (x, i) { return 2; })
.style("stroke-width", 0) .style("stroke-width", 0)
.style("stroke", "black") .style("stroke", "black")
.style("fill", "rgb(20,90,50)"); .style("fill", "rgb(20,90,50)");
/* Valeurs sur axe */ /* Valeurs sur axe */
g.selectAll("textaxis") g.selectAll("textaxis")
.data( R_AXIS_TICS ) .data(R_AXIS_TICS)
.enter().append("text") .enter().append("text")
.text(String) .text(String)
.attr("x", CX - 10) .attr("x", CX - 10)
.attr("y", function(x, i) { return CY - x*RR/20 + 6; }) .attr("y", function (x, i) { return CY - x * RR / 20 + 6; })
.attr("class", "textaxis"); .attr("class", "textaxis");
/* Noms des modules */ /* Noms des modules */
g.selectAll("text_modules") g.selectAll("text_modules")
.data(notes) .data(notes)
.enter().append("text") .enter().append("text")
.text( function(d) { return d['code']; } ) .text(function (d) { return d['code']; })
.attr("x", function(d) { return d['x_label']; } ) .attr("x", function (d) { return d['x_label']; })
.attr("y", function(d) { return d['y_label']; }) .attr("y", function (d) { return d['y_label']; })
.attr("dx", 0) .attr("dx", 0)
.attr("dy", 0) .attr("dy", 0)
.on("mouseover", function(d) { .on("mouseover", function (d) {
var x = d["x_label"]; var x = d["x_label"];
var yrect = d["y_label"]; var yrect = d["y_label"];
var ytext = d["y_label"]; var ytext = d["y_label"];
var titre = d['titre'].replace("&apos;", "'").substring(0,64); var titre = d['titre'].replace("&apos;", "'").substring(0, 64);
var rwidth = titre.length * 9; // rough estimate of string width in pixels var rwidth = titre.length * 9; // rough estimate of string width in pixels
if ((x - CX) < 0) { if ((x - CX) < 0) {
x = x + 5; x = x + 5;
@ -250,7 +253,7 @@ function draw_radar(notes) {
} }
} }
else { else {
x = CX - rwidth/2; x = CX - rwidth / 2;
} }
} }
if ((yrect - CY) > 0) { if ((yrect - CY) > 0) {
@ -260,19 +263,19 @@ function draw_radar(notes) {
else { else {
yrect = yrect + 5; yrect = yrect + 5;
ytext = ytext + 5 + 16; ytext = ytext + 5 + 16;
} }
var r = g.append("rect") var r = g.append("rect")
.attr('class','radartip') .attr('class', 'radartip')
.attr("x", x) .attr("x", x)
.attr("y", yrect) .attr("y", yrect)
.attr("height", 20) .attr("height", 20)
.attr("width", rwidth); .attr("width", rwidth);
var txt = g.append("text").text( titre ) var txt = g.append("text").text(titre)
.attr('class','radartip') .attr('class', 'radartip')
.attr("x", x + 5) .attr("x", x + 5)
.attr("y", ytext); .attr("y", ytext);
}) })
.on("mouseout", function(d){ .on("mouseout", function (d) {
d3.selectAll(".radartip").remove() d3.selectAll(".radartip").remove()
}); });
} }

View File

@ -1,22 +1,22 @@
// Formulaire saisie des notes // Formulaire saisie des notes
$().ready(function(){ $().ready(function () {
$("#formnotes .note").bind("blur", valid_note); $("#formnotes .note").bind("blur", valid_note);
$("#formnotes input").bind("paste", paste_text); $("#formnotes input").bind("paste", paste_text);
}); });
function is_valid_note(v) { function is_valid_note(v) {
if (!v) if (!v)
return true; return true;
var note_min = parseFloat($("#eval_note_min").text()); var note_min = parseFloat($("#eval_note_min").text());
var note_max = parseFloat($("#eval_note_max").text()); var note_max = parseFloat($("#eval_note_max").text());
if (! v.match("^-?[0-9.]*$")) { if (!v.match("^-?[0-9.]*$")) {
return (v=="ABS")||(v=="EXC")||(v=="SUPR")||(v=="ATT")||(v=="DEM"); return (v == "ABS") || (v == "EXC") || (v == "SUPR") || (v == "ATT") || (v == "DEM");
} else { } else {
var x = parseFloat(v); var x = parseFloat(v);
return (x >= note_min) && (x <= note_max); return (x >= note_min) && (x <= note_max);
@ -41,33 +41,33 @@ function save_note(elem, v, etudid) {
var evaluation_id = $("#formnotes_evaluation_id").attr("value"); var evaluation_id = $("#formnotes_evaluation_id").attr("value");
var formsemestre_id = $("#formnotes_formsemestre_id").attr("value"); var formsemestre_id = $("#formnotes_formsemestre_id").attr("value");
$('#sco_msg').html("en cours...").show(); $('#sco_msg').html("en cours...").show();
$.post( 'save_note', $.post(SCO_URL + 'Notes/save_note',
{ {
'etudid' : etudid, 'etudid': etudid,
'evaluation_id' : evaluation_id, 'evaluation_id': evaluation_id,
'value' : v, 'value': v,
'comment' : $("#formnotes_comment").attr("value") 'comment': $("#formnotes_comment").attr("value")
}, },
function(result) { function (result) {
sco_message("enregistré"); sco_message("enregistré");
elem.className = "note_saved"; elem.className = "note_saved";
if (result['nbchanged'] > 0) { if (result['nbchanged'] > 0) {
// il y avait une decision de jury ? // il y avait une decision de jury ?
if (result.existing_decisions[0] == etudid) { if (result.existing_decisions[0] == etudid) {
if (v != $(elem).attr('data-orig-value')) { if (v != $(elem).attr('data-orig-value')) {
$("#jurylink_"+etudid).html('<a href="formsemestre_validation_etud_form?formsemestre_id=' + formsemestre_id + '&etudid=' + etudid + '">mettre à jour décision de jury</a>'); $("#jurylink_" + etudid).html('<a href="formsemestre_validation_etud_form?formsemestre_id=' + formsemestre_id + '&etudid=' + etudid + '">mettre à jour décision de jury</a>');
} else { } else {
$("#jurylink_"+etudid).html(''); $("#jurylink_" + etudid).html('');
}
}
// mise a jour menu historique
if (result['history_menu']) {
$("#hist_"+etudid).html(result['history_menu']);
} }
} }
$(elem).attr('data-last-saved-value', v) // mise a jour menu historique
if (result['history_menu']) {
$("#hist_" + etudid).html(result['history_menu']);
}
} }
); $(elem).attr('data-last-saved-value', v)
}
);
} }
function change_history(e) { function change_history(e) {
@ -91,23 +91,23 @@ function paste_text(e) {
var data = clipb.getData('Text'); var data = clipb.getData('Text');
var list = data.split(/\r\n|\r|\n|\t| /g); var list = data.split(/\r\n|\r|\n|\t| /g);
var currentInput = event.currentTarget; var currentInput = event.currentTarget;
for(var i=0 ; i<list.length ; i++){ for (var i = 0; i < list.length; i++) {
currentInput.value = list[i]; currentInput.value = list[i];
var evt = document.createEvent("HTMLEvents"); var evt = document.createEvent("HTMLEvents");
evt.initEvent("blur", false, true); evt.initEvent("blur", false, true);
currentInput.dispatchEvent(evt); currentInput.dispatchEvent(evt);
var sibbling = currentInput.parentElement.parentElement.nextElementSibling; var sibbling = currentInput.parentElement.parentElement.nextElementSibling;
while (sibbling && sibbling.style.display == "none") { while (sibbling && sibbling.style.display == "none") {
sibbling = sibbling.nextElementSibling; sibbling = sibbling.nextElementSibling;
} }
if (sibbling) { if (sibbling) {
currentInput = sibbling.querySelector("input"); currentInput = sibbling.querySelector("input");
if(!currentInput){ if (!currentInput) {
return; return;
} }
} else { } else {
return; return;
} }
} }
} }

View File

@ -1,11 +1,11 @@
// Affichage progressif du trombinoscope html // Affichage progressif du trombinoscope html
$().ready(function(){ $().ready(function () {
var spans = $(".unloaded_img"); var spans = $(".unloaded_img");
for (var i=0; i < spans.size(); i++) { for (var i = 0; i < spans.size(); i++) {
var sp = spans[i]; var sp = spans[i];
var etudid = sp.id; var etudid = sp.id;
$(sp).load('etud_photo_html?etudid='+etudid); $(sp).load(SCO_URL + "/etud_photo_html?etudid=" + etudid);
} }
}); });

View File

@ -1,6 +1,6 @@
// Affiche et met a jour la liste des UE partageant le meme code // Affiche et met a jour la liste des UE partageant le meme code
$().ready(function(){ $().ready(function () {
update_ue_validations(); update_ue_validations();
update_ue_list(); update_ue_list();
$("#tf_ue_id").bind("change", update_ue_list); $("#tf_ue_id").bind("change", update_ue_list);
@ -11,21 +11,21 @@ $().ready(function(){
function update_ue_list() { function update_ue_list() {
var ue_id = $("#tf_ue_id")[0].value; var ue_id = $("#tf_ue_id")[0].value;
if (ue_id) { if (ue_id) {
var query = "ue_sharing_code?ue_id=" + ue_id; var query = "ue_sharing_code?ue_id=" + ue_id;
$.get( query, '', function(data){ $.get(query, '', function (data) {
$("#ue_list_code").html(data); $("#ue_list_code").html(data);
}); });
} }
} }
function update_ue_validations() { function update_ue_validations() {
var etudid = $("#tf_etudid")[0].value; var etudid = $("#tf_etudid")[0].value;
var ue_id = $("#tf_ue_id")[0].value; var ue_id = $("#tf_ue_id")[0].value;
var formsemestre_id = $("#tf_formsemestre_id")[0].value; var formsemestre_id = $("#tf_formsemestre_id")[0].value;
if (ue_id) { if (ue_id) {
var query = "get_etud_ue_cap_html?ue_id="+ue_id+"&etudid="+etudid+"&formsemestre_id="+formsemestre_id; var query = SCO_URL + "/Notes/get_etud_ue_cap_html?ue_id=" + ue_id + "&etudid=" + etudid + "&formsemestre_id=" + formsemestre_id;
$.get( query, '', function(data){ $.get(query, '', function (data) {
$("#ue_list_etud_validations").html(data); $("#ue_list_etud_validations").html(data);
}); });
} }
} }