diff --git a/app/static/js/abs_ajax.js b/app/static/js/abs_ajax.js index 3fed2731eb..4e5aee1a0d 100644 --- a/app/static/js/abs_ajax.js +++ b/app/static/js/abs_ajax.js @@ -28,7 +28,7 @@ function ajaxFunction(mod, etudid, dat) { 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"); var oSelectOne = $("#abs_form")[0].elements["moduleimpl_id"]; var index = oSelectOne.selectedIndex; diff --git a/app/static/js/editPartitionForm.js b/app/static/js/editPartitionForm.js index 242c539dcb..9d4b7fd92d 100644 --- a/app/static/js/editPartitionForm.js +++ b/app/static/js/editPartitionForm.js @@ -1,25 +1,26 @@ function _partition_set_attr(partition_id, attr_name, attr_value) { - $.post('partition_set_attr', - { 'partition_id' : partition_id, - 'attr' : attr_name, - 'value' : attr_value - }, - function(result) { - sco_message(result); - }); + $.post(SCO_URL + '/partition_set_attr', + { + 'partition_id': partition_id, + 'attr': attr_name, + 'value': attr_value + }, + function (result) { + sco_message(result); + }); return; -} +} // Met à jour bul_show_rank lorsque checkbox modifiees: function update_rk(e) { var partition_id = $(e).attr('data-partition_id'); var v; if (e.checked) - v='1'; + v = '1'; else - v='0'; + v = '0'; _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 v; if (e.checked) - v='1'; + v = '1'; else - v='0'; - - _partition_set_attr(partition_id, 'show_in_lists', v); -} + v = '0'; + + _partition_set_attr(partition_id, 'show_in_lists', v); +} diff --git a/app/static/js/edit_ue.js b/app/static/js/edit_ue.js index 6d41fa5363..34e8e9c8b1 100644 --- a/app/static/js/edit_ue.js +++ b/app/static/js/edit_ue.js @@ -1,6 +1,6 @@ // Affiche et met a jour la liste des UE partageant le meme code -$().ready(function(){ +$().ready(function () { update_ue_list(); $("#tf_ue_code").bind("keyup", update_ue_list); }); @@ -9,8 +9,8 @@ $().ready(function(){ function update_ue_list() { var ue_id = $("#tf_ue_id")[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; - $.get( query, '', function(data){ - $("#ue_list_code").html(data); + 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) { + $("#ue_list_code").html(data); }); -} +} diff --git a/app/static/js/etud_debouche.js b/app/static/js/etud_debouche.js index a72dc6f86e..da0febd66b 100644 --- a/app/static/js/etud_debouche.js +++ b/app/static/js/etud_debouche.js @@ -3,7 +3,7 @@ // console.log('etud_debouche.js loaded'); -$(function() { +$(function () { display_itemsuivis(false); }); @@ -11,127 +11,127 @@ $(function() { function display_itemsuivis(active) { var etudid = $('div#fichedebouche').data("etudid"); var readonly = $('div#fichedebouche').data('readonly'); // present ro interface - + if (!readonly) { - $('#adddebouchelink').off("click").click(function(e){ - e.preventDefault(); - $.post( "itemsuivi_create", { etudid: etudid, format:'json' } ).done( item_insert_new ); - - return false; - }); + $('#adddebouchelink').off("click").click(function (e) { + e.preventDefault(); + $.post(SCO_URL + "itemsuivi_create", { etudid: etudid, format: 'json' }).done(item_insert_new); + + return false; + }); } // add existing items - $.get( 'itemsuivi_list_etud', { etudid: etudid, format: 'json' }, function(L) { - for (var i in L) { - item_insert( L[i]['itemsuivi_id'], L[i]['item_date'], L[i]['situation'], L[i]['tags'], readonly ); - } + $.get(SCO_URL + "/itemsuivi_list_etud", { etudid: etudid, format: 'json' }, function (L) { + for (var i in L) { + item_insert(L[i]['itemsuivi_id'], L[i]['item_date'], L[i]['situation'], L[i]['tags'], readonly); + } }); - $( "div#fichedebouche" ).accordion( { - heightStyle: "content", - collapsible: true, - active: active, + $("div#fichedebouche").accordion({ + heightStyle: "content", + collapsible: true, + active: active, }); } -function item_insert_new( it ) { - item_insert( it.itemsuivi_id, it.item_date, it.situation, '', false ); +function item_insert_new(it) { + item_insert(it.itemsuivi_id, it.item_date, it.situation, '', false); } -function item_insert( itemsuivi_id, item_date, situation, tags, readonly ) { - if ( item_date === undefined ) - item_date = Date2DMY(new Date()); - if ( situation === undefined ) - situation = ''; - if ( tags === undefined ) - tags = ''; +function item_insert(itemsuivi_id, item_date, situation, tags, readonly) { + if (item_date === undefined) + item_date = Date2DMY(new Date()); + if (situation === undefined) + situation = ''; + if (tags === undefined) + tags = ''; var nodes = item_nodes(itemsuivi_id, item_date, situation, tags, readonly); // insert just before last li: if ($('ul.listdebouches li.adddebouche').length > 0) { - $('ul.listdebouches').children(':last').before(nodes); + $('ul.listdebouches').children(':last').before(nodes); } else { - // mode readonly, pas de li "ajouter" - $('ul.listdebouches').append(nodes); + // mode readonly, pas de li "ajouter" + $('ul.listdebouches').append(nodes); } }; function item_nodes(itemsuivi_id, item_date, situation, tags, readonly) { // console.log('item_nodes: itemsuivi_id=' + itemsuivi_id); - var sel_mois = 'Situation à la date du supprimer cet item'; - + var sel_mois = 'Situation à la date du supprimer cet item'; + var h = sel_mois; // situation h += '
' + situation + '
'; // tags: h += '
'; - - var nodes = $($.parseHTML( '
  • ' + h + '
  • ' )); + + var nodes = $($.parseHTML('
  • ' + h + '
  • ')); var dp = nodes.find('.itemsuividatepicker'); - dp.blur( function(e) { - var date = this.value; - // console.log('selected text: ' + date); - $.post( "itemsuivi_set_date", { item_date: date, itemsuivi_id: itemsuivi_id } ); + dp.blur(function (e) { + var date = this.value; + // console.log('selected text: ' + date); + $.post(SCO_URL + "/itemsuivi_set_date", { item_date: date, itemsuivi_id: itemsuivi_id }); }); dp.datepicker({ - onSelect: function(date, instance) { - // console.log('selected: ' + date + 'for itemsuivi_id ' + itemsuivi_id); - $.post( "itemsuivi_set_date", { item_date: date, itemsuivi_id: itemsuivi_id } ); - }, - showOn: 'button', - buttonImage: '/ScoDoc/static/icons/calendar_img.png', + onSelect: function (date, instance) { + // console.log('selected: ' + date + 'for itemsuivi_id ' + itemsuivi_id); + $.post(SCO_URL + "/itemsuivi_set_date", { item_date: date, itemsuivi_id: itemsuivi_id }); + }, + showOn: 'button', + buttonImage: '/ScoDoc/static/icons/calendar_img.png', buttonImageOnly: true, - dateFormat: 'dd/mm/yy', - duration : 'fast', - disabled: readonly + dateFormat: 'dd/mm/yy', + duration: 'fast', + disabled: readonly }); - dp.datepicker('option', $.extend({showMonthAfterYear: false}, - $.datepicker.regional['fr'])); - + dp.datepicker('option', $.extend({ showMonthAfterYear: false }, + $.datepicker.regional['fr'])); + if (readonly) { - // show tags read-only - readOnlyTags(nodes.find('.itemsuivi_tag_editor')); + // show tags read-only + readOnlyTags(nodes.find('.itemsuivi_tag_editor')); } else { - // bind tag editor - nodes.find('.itemsuivi_tag_editor').tagEditor({ - initialTags: '', + // bind tag editor + nodes.find('.itemsuivi_tag_editor').tagEditor({ + initialTags: '', placeholder: 'Tags...', - onChange: function(field, editor, tags) { - $.post('itemsuivi_tag_set', - { - itemsuivi_id: itemsuivi_id, - taglist: tags.join() - }); + onChange: function (field, editor, tags) { + $.post('itemsuivi_tag_set', + { + itemsuivi_id: itemsuivi_id, + taglist: tags.join() + }); }, autocomplete: { - delay: 200, // ms before suggest - position: { collision: 'flip' }, // automatic menu position up/down - source: "itemsuivi_tag_search" + delay: 200, // ms before suggest + position: { collision: 'flip' }, // automatic menu position up/down + source: "itemsuivi_tag_search" }, - }); + }); - // bind inplace editor - nodes.find('div.itemsituation').jinplace(); + // bind inplace editor + nodes.find('div.itemsituation').jinplace(); } - + return nodes; }; function Date2DMY(date) { - var year = date.getFullYear(); + var year = date.getFullYear(); - var month = (1 + date.getMonth()).toString(); - month = month.length > 1 ? month : '0' + month; + var month = (1 + date.getMonth()).toString(); + month = month.length > 1 ? month : '0' + month; - var day = date.getDate().toString(); - day = day.length > 1 ? day : '0' + day; - - return day + '/' + month + '/' + year; + var day = date.getDate().toString(); + day = day.length > 1 ? day : '0' + day; + + return day + '/' + month + '/' + year; } 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: $("ul.listdebouches li.itemsuivi").remove(); display_itemsuivis(0); diff --git a/app/static/js/groupmgr.js b/app/static/js/groupmgr.js index 1f89361d4f..90a50272f9 100644 --- a/app/static/js/groupmgr.js +++ b/app/static/js/groupmgr.js @@ -6,7 +6,7 @@ /* --- Globals ---- */ -var EtudColors = [ "#E8EEF7", "#ffffff" ]; // [ "#E8EEF7", "#E0ECFF", "#E5E6BE", "#F3EAE2", "#E3EAE1" ]; +var EtudColors = ["#E8EEF7", "#ffffff"]; // [ "#E8EEF7", "#E0ECFF", "#E5E6BE", "#F3EAE2", "#E3EAE1" ]; var EtudColorsIdx = 0; var NbEtuds = 0; var ETUDS = new Object(); // { etudid : etud } @@ -19,46 +19,46 @@ function loadGroupes() { $("#gmsg")[0].innerHTML = 'Chargement des groupes en cours...'; var partition_id = document.formGroup.partition_id.value; - $.get('XMLgetGroupsInPartition', { partition_id : partition_id } ) + $.get(SCO_URL + 'XMLgetGroupsInPartition', { partition_id: partition_id }) .done( - function( data ) { - var nodes = data.getElementsByTagName('group'); - if (nodes) { - var nbgroups = nodes.length; - // put last group at first (etudiants sans groupes) - if (nodes.length > 1 && nodes[nbgroups-1].attributes.getNamedItem("group_id").value == '_none_') { - populateGroup(nodes[nodes.length-1]); - nbgroups -= 1; - } - // then standard groups - for (var i=0; i < nbgroups; i++) { - populateGroup(nodes[i]); - } - } - $("#gmsg")[0].innerHTML = ''; - updateginfo(); - } + function (data) { + var nodes = data.getElementsByTagName('group'); + if (nodes) { + var nbgroups = nodes.length; + // put last group at first (etudiants sans groupes) + if (nodes.length > 1 && nodes[nbgroups - 1].attributes.getNamedItem("group_id").value == '_none_') { + populateGroup(nodes[nodes.length - 1]); + nbgroups -= 1; + } + // then standard groups + for (var i = 0; i < nbgroups; i++) { + populateGroup(nodes[i]); + } + } + $("#gmsg")[0].innerHTML = ''; + updateginfo(); + } ) } -function populateGroup( node ) { +function populateGroup(node) { 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 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 x=''; + var x = ''; gbox.sorting = false; // disable to speedup 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 prenom = etuds[j].attributes.getNamedItem("prenom").value; var sexe = etuds[j].attributes.getNamedItem("sexe").value; var etudid = etuds[j].attributes.getNamedItem("etudid").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.sorting = true; @@ -72,14 +72,14 @@ function populateGroup( node ) { var groupBoxes = new Object(); // assoc group_id : groupBox 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); var regex = /^\w+$/; - if (! regex.test(group_id) ) { + if (!regex.test(group_id)) { alert("Id de groupe invalide"); return; } - if ( group_id in groups ) { + if (group_id in groups) { alert("Le groupe " + group_id + " existe déjà !"); return; } @@ -90,7 +90,7 @@ var CGroupBox = function(group_id, group_name) { this.nbetuds = 0; this.isNew = false; // true for newly user-created groups this.sorting = true; // false to disable sorting - + this.groupBox = document.createElement("div"); this.groupBox.className = "simpleDropPanel"; this.groupBox.id = group_id; @@ -103,13 +103,13 @@ var CGroupBox = function(group_id, group_name) { this.updateTitle(); $(this.groupBox).droppable( { - accept : ".box", + accept: ".box", activeClass: "activatedPanel", - drop: function( event, ui ) { + drop: function (event, ui) { // alert("drop on " + this.group_name); var etudid = ui.draggable[0].id; var etud = ETUDS[etudid]; - var newGroupName = this.id; + var newGroupName = this.id; var oldGroupName = ETUD_GROUP[etudid]; $(groupBoxes[newGroupName].groupBox).append(ui.draggable) 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) */ - $(this.groupBox).draggable( { + $(this.groupBox).draggable({ cursor: 'move', containment: '#groups' }); @@ -130,25 +130,25 @@ var CGroupBox = function(group_id, group_name) { $.extend(CGroupBox.prototype, { // menu for group title - groupTitle : function() { + groupTitle: function () { var menuSpan = document.createElement("span"); menuSpan.className = "barrenav"; var h = "
    "; menuSpan.innerHTML = h; return menuSpan; }, // add etud to group, attach to DOM - createEtudInGroup: function(etud) { + createEtudInGroup: function (etud) { this.addEtudToGroup(etud); this.groupBox.appendChild(etud.htmlElement); }, // add existing etud to group (does not affect DOM) - addEtudToGroup: function(etud) { + addEtudToGroup: function (etud) { etud.group_id = this.group_id; this.etuds[etud.etudid] = etud; this.nbetuds++; @@ -156,45 +156,45 @@ $.extend(CGroupBox.prototype, { this.updateTitle(); }, // remove etud - removeEtud: function(etud) { + removeEtud: function (etud) { delete this.etuds[etud.etudid]; this.nbetuds--; this.updateTitle(); }, // Update counter display - updateTitle: function() { + updateTitle: function () { var tclass = ''; if (this.isNew) { tclass = ' class="newgroup"' } - var titleSpan = document.getElementById('titleSpan'+this.group_id); - if (this.group_id != '_none_') - titleSpan.innerHTML = 'Groupe ' + this.group_name + ' (' + this.nbetuds + ')'; + var titleSpan = document.getElementById('titleSpan' + this.group_id); + if (this.group_id != '_none_') + titleSpan.innerHTML = 'Groupe ' + this.group_name + ' (' + this.nbetuds + ')'; else - titleSpan.innerHTML = 'Etudiants sans groupe' + ' (' + this.nbetuds + ')'; + titleSpan.innerHTML = 'Etudiants sans groupe' + ' (' + this.nbetuds + ')'; this.sortList(); // maintient toujours la liste triee }, // Tri de la boite par nom - sortList: function() { - if (!this.sorting) + sortList: function () { + if (!this.sorting) return; var newRows = new Array(); - for (var i=1; i < this.groupBox.childNodes.length; i++) { // 1 car div titre - newRows[i-1] = this.groupBox.childNodes[i]; + for (var i = 1; i < this.groupBox.childNodes.length; i++) { // 1 car div titre + 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 var nom_a = a.childNodes[1].childNodes[0].nodeValue; var nom_b = b.childNodes[1].childNodes[0].nodeValue; // console.log( 'comp( %s, %s )', nom_a, nom_b ); - if (nom_a == nom_b) + if (nom_a == nom_b) return 0; - if (nom_a < nom_b) + if (nom_a < nom_b) return -1; return 1; }; - newRows.sort(sortfn); - for (var i=0;i' + this.nom + ' ' + ''+this.origin+''; + repr: function () { + return this.sexe + ' ' + this.prenom + ' ' + this.nom + ' ' + '' + this.origin + ''; }, - createNode: function() { + createNode: function () { // Create DOM element for student var e = document.createElement("div"); this.htmlElement = e; @@ -303,39 +303,39 @@ $.extend(CDraggableEtud.prototype, { //e.appendChild(txtNode); e.innerHTML = this.repr(); // declare as draggable - $(e).draggable( { + $(e).draggable({ cursor: 'move', stack: '#groups div', containment: '#groups', revert: 'invalid' }); }, - endDrag: function() { + endDrag: function () { var el = this.htmlElement; var p = el.parentNode; // 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 }, // Move a student from a group to another - changeGroup: function( oldGroupName, newGroupName ) { - if (oldGroupName==newGroupName) { - // drop on original group, just sort - groupBoxes[oldGroupName].updateTitle(); - return; + changeGroup: function (oldGroupName, newGroupName) { + if (oldGroupName == newGroupName) { + // drop on original group, just sort + groupBoxes[oldGroupName].updateTitle(); + return; } var oldGroupBox = null; if (oldGroupName) { - oldGroupBox = groupBoxes[oldGroupName]; + oldGroupBox = groupBoxes[oldGroupName]; } var newGroupBox = groupBoxes[newGroupName]; newGroupBox.addEtudToGroup(this); if (oldGroupBox) - oldGroupBox.removeEtud(this); + oldGroupBox.removeEtud(this); groups_unsaved = true; updatesavedinfo(); } -}); +}); /* --- Upload du resultat --- */ @@ -343,66 +343,66 @@ function processResponse(value) { location.reload(); // necessaire pour reinitialiser les id des groupes créés } -function handleError( msg ) { - alert( 'Error: ' + msg ); - console.log( 'Error: ' + msg ); +function handleError(msg) { + alert('Error: ' + msg); + console.log('Error: ' + msg); } function submitGroups() { - var url = 'setGroups'; + var url = SCO_URL + '/setGroups'; // build post request body: groupname \n etudid; ... var groupsLists = ''; - var groupsToCreate=''; - for (var group_id in groupBoxes) { + var groupsToCreate = ''; + for (var group_id in groupBoxes) { 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 - groupBox = groupBoxes[group_id]; - if (groupBox.isNew) { - groupsToCreate += groupBox.group_name + ';'; - for (var etudid in groupBox.etuds) { - if (etudid != 'extend') - groupsToCreate += etudid + ';'; - } - groupsToCreate += '\n'; - groupBox.isNew = false; // is no more new ! - } else { - groupsLists += group_id + ';'; - for (var etudid in groupBox.etuds) { - if (etudid != 'extend') - groupsLists += etudid + ';'; - } - groupsLists += '\n'; - } + groupBox = groupBoxes[group_id]; + if (groupBox.isNew) { + groupsToCreate += groupBox.group_name + ';'; + for (var etudid in groupBox.etuds) { + if (etudid != 'extend') + groupsToCreate += etudid + ';'; + } + groupsToCreate += '\n'; + groupBox.isNew = false; // is no more new ! + } else { + groupsLists += group_id + ';'; + for (var etudid in groupBox.etuds) { + if (etudid != 'extend') + groupsLists += etudid + ';'; + } + groupsLists += '\n'; + } } } } var todel = ''; for (var group_id in groupsToDelete) { - todel += group_id + ';'; + todel += group_id + ';'; } groupsToDelete = new Object(); // empty var partition_id = document.formGroup.partition_id.value; // Send to server - $.get( url, { - groupsLists : groupsLists, // encodeURIComponent - partition_id : partition_id, - groupsToDelete : todel, - groupsToCreate : groupsToCreate - }) - .done( function (data) { - processResponse(data); + $.get(url, { + groupsLists: groupsLists, // encodeURIComponent + partition_id: partition_id, + groupsToDelete: todel, + groupsToCreate: groupsToCreate + }) + .done(function (data) { + processResponse(data); }) - .fail(function() { + .fail(function () { handleError("Erreur lors de l'enregistrement de groupes"); }); -} +} // Move to another partition (specified by menu) function GotoAnother() { if (groups_unsaved) { alert("Enregistrez ou annulez vos changement avant !"); } 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 group_names = new Array(); 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); } } g.innerHTML = 'Groupes définis: ' + group_names.join(', ') + '
    ' + "Nombre d'etudiants: " + NbEtuds + '
    '; - + updatesavedinfo(); } @@ -426,16 +426,16 @@ function updatesavedinfo() { var g = document.getElementById('savedinfo'); if (groups_unsaved) { g.innerHTML = 'modifications non enregistrées'; - g.style.visibility='visible'; + g.style.visibility = 'visible'; } else { g.innerHTML = ''; - g.style.visibility='hidden'; + g.style.visibility = 'hidden'; } return true; } -$(function() { +$(function () { loadGroupes(); }); diff --git a/app/static/js/radar_bulletin.js b/app/static/js/radar_bulletin.js index 231399ca64..2a60081ed3 100644 --- a/app/static/js/radar_bulletin.js +++ b/app/static/js/radar_bulletin.js @@ -5,7 +5,7 @@ // // Ce code utilise d3.js -$().ready(function(){ +$().ready(function () { var etudid = $("#etudid")[0].value; var formsemestre_id = $("#formsemestre_id")[0].value; get_notes_and_draw(formsemestre_id, etudid); @@ -14,12 +14,12 @@ $().ready(function(){ var WIDTH = 460; // taille du canvas SVG var HEIGHT = WIDTH; -var CX = WIDTH/2; // coordonnees centre du cercle -var CY = HEIGHT/2; -var RR = 0.4*WIDTH; // Rayon du cercle exterieur +var CX = WIDTH / 2; // coordonnees centre du cercle +var CY = HEIGHT / 2; +var RR = 0.4 * WIDTH; // Rayon du cercle exterieur /* 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 NB_TICS = R_TICS.length; @@ -33,72 +33,75 @@ function get_notes_and_draw(formsemestre_id, etudid) { 'moy' : 16 }, ]; */ - var query = "formsemestre_bulletinetud?formsemestre_id=" + formsemestre_id + "&etudid=" + etudid + "&format=json&version=selectedevals&force_publishing=1" - - $.get( query, '', function(bul){ + var query = SCO_URL + "/Notes/formsemestre_bulletinetud?formsemestre_id=" + formsemestre_id + "&etudid=" + etudid + "&format=json&version=selectedevals&force_publishing=1" + + $.get(query, '', function (bul) { var notes = []; - bul.ue.forEach( - function(ue, i, ues) { - ue['module'].forEach( function(m, i) { - notes.push( { 'code': m['code'], - 'titre' : m['titre'], - 'note':m['note']['value'], - 'moy':m['note']['moy'] } ); - }); } ); - draw_radar(notes); + bul.ue.forEach( + function (ue, i, ues) { + ue['module'].forEach(function (m, i) { + notes.push({ + 'code': m['code'], + 'titre': m['titre'], + 'note': m['note']['value'], + 'moy': m['note']['moy'] + }); + }); + }); + draw_radar(notes); }); } function draw_radar(notes) { /* Calcul coordonnées des éléments */ var nmod = notes.length; - var angle = 2*Math.PI/nmod; + var angle = 2 * Math.PI / nmod; - for (var i=0; i WIDTH) { @@ -157,7 +160,7 @@ function draw_radar(notes) { } } else { - x = CX - rwidth/2; + x = CX - rwidth / 2; } } var yrect = d["y_v"]; @@ -169,19 +172,19 @@ function draw_radar(notes) { else { yrect = yrect + 5; ytext = ytext + 5 + 16; - } - var r = g.append("rect") - .attr('class','radartip') - .attr("x", x) - .attr("y", yrect ); - - var txt = g.append("text").text("Note: " + d.note + "/20, moyenne promo: " + d.moy + "/20") - .attr('class','radartip') - .attr("x", x + 5) + } + var r = g.append("rect") + .attr('class', 'radartip') + .attr("x", x) + .attr("y", yrect); + + var txt = g.append("text").text("Note: " + d.note + "/20, moyenne promo: " + d.moy + "/20") + .attr('class', 'radartip') + .attr("x", x + 5) .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() }); @@ -189,11 +192,11 @@ function draw_radar(notes) { g.selectAll("notes_labels") .data(notes_valid) .enter().append("text") - .text(function(d) { return d["note"]; }) - .attr("x", function(d) { - return d["x_v"]; + .text(function (d) { return d["note"]; }) + .attr("x", function (d) { + return d["x_v"]; }) - .attr("y", function(d) { + .attr("y", function (d) { if (d["y_v"] > CY) return d["y_v"] + 16; else @@ -205,36 +208,36 @@ function draw_radar(notes) { g.selectAll("circle2") .data(notes_valid) .enter().append("circle") - .attr("cx", function(d) { return d["x_moy"]; }) - .attr("cy", function(d) { return d["y_moy"]; }) - .attr("r", function(x, i) { return 2; } ) + .attr("cx", function (d) { return d["x_moy"]; }) + .attr("cy", function (d) { return d["y_moy"]; }) + .attr("r", function (x, i) { return 2; }) .style("stroke-width", 0) .style("stroke", "black") .style("fill", "rgb(20,90,50)"); /* Valeurs sur axe */ g.selectAll("textaxis") - .data( R_AXIS_TICS ) + .data(R_AXIS_TICS) .enter().append("text") .text(String) .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"); /* Noms des modules */ g.selectAll("text_modules") .data(notes) .enter().append("text") - .text( function(d) { return d['code']; } ) - .attr("x", function(d) { return d['x_label']; } ) - .attr("y", function(d) { return d['y_label']; }) + .text(function (d) { return d['code']; }) + .attr("x", function (d) { return d['x_label']; }) + .attr("y", function (d) { return d['y_label']; }) .attr("dx", 0) .attr("dy", 0) - .on("mouseover", function(d) { + .on("mouseover", function (d) { var x = d["x_label"]; var yrect = d["y_label"]; var ytext = d["y_label"]; - var titre = d['titre'].replace("'", "'").substring(0,64); + var titre = d['titre'].replace("'", "'").substring(0, 64); var rwidth = titre.length * 9; // rough estimate of string width in pixels if ((x - CX) < 0) { x = x + 5; @@ -250,7 +253,7 @@ function draw_radar(notes) { } } else { - x = CX - rwidth/2; + x = CX - rwidth / 2; } } if ((yrect - CY) > 0) { @@ -260,19 +263,19 @@ function draw_radar(notes) { else { yrect = yrect + 5; ytext = ytext + 5 + 16; - } + } var r = g.append("rect") - .attr('class','radartip') - .attr("x", x) + .attr('class', 'radartip') + .attr("x", x) .attr("y", yrect) .attr("height", 20) .attr("width", rwidth); - var txt = g.append("text").text( titre ) - .attr('class','radartip') - .attr("x", x + 5) + var txt = g.append("text").text(titre) + .attr('class', 'radartip') + .attr("x", x + 5) .attr("y", ytext); }) - .on("mouseout", function(d){ + .on("mouseout", function (d) { d3.selectAll(".radartip").remove() }); } diff --git a/app/static/js/saisie_notes.js b/app/static/js/saisie_notes.js index 3fc029d5bb..b1907df4ea 100644 --- a/app/static/js/saisie_notes.js +++ b/app/static/js/saisie_notes.js @@ -1,22 +1,22 @@ // Formulaire saisie des notes -$().ready(function(){ - +$().ready(function () { + $("#formnotes .note").bind("blur", valid_note); $("#formnotes input").bind("paste", paste_text); - + }); function is_valid_note(v) { if (!v) - return true; - + return true; + var note_min = parseFloat($("#eval_note_min").text()); var note_max = parseFloat($("#eval_note_max").text()); - - if (! v.match("^-?[0-9.]*$")) { - return (v=="ABS")||(v=="EXC")||(v=="SUPR")||(v=="ATT")||(v=="DEM"); + + if (!v.match("^-?[0-9.]*$")) { + return (v == "ABS") || (v == "EXC") || (v == "SUPR") || (v == "ATT") || (v == "DEM"); } else { var x = parseFloat(v); 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 formsemestre_id = $("#formnotes_formsemestre_id").attr("value"); $('#sco_msg').html("en cours...").show(); - $.post( 'save_note', - { - 'etudid' : etudid, - 'evaluation_id' : evaluation_id, - 'value' : v, - 'comment' : $("#formnotes_comment").attr("value") - }, - function(result) { - sco_message("enregistré"); - elem.className = "note_saved"; - if (result['nbchanged'] > 0) { - // il y avait une decision de jury ? - if (result.existing_decisions[0] == etudid) { - if (v != $(elem).attr('data-orig-value')) { - $("#jurylink_"+etudid).html('mettre à jour décision de jury'); - } else { - $("#jurylink_"+etudid).html(''); - } - } - // mise a jour menu historique - if (result['history_menu']) { - $("#hist_"+etudid).html(result['history_menu']); + $.post(SCO_URL + 'Notes/save_note', + { + 'etudid': etudid, + 'evaluation_id': evaluation_id, + 'value': v, + 'comment': $("#formnotes_comment").attr("value") + }, + function (result) { + sco_message("enregistré"); + elem.className = "note_saved"; + if (result['nbchanged'] > 0) { + // il y avait une decision de jury ? + if (result.existing_decisions[0] == etudid) { + if (v != $(elem).attr('data-orig-value')) { + $("#jurylink_" + etudid).html('mettre à jour décision de jury'); + } else { + $("#jurylink_" + etudid).html(''); } } - $(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) { @@ -91,23 +91,23 @@ function paste_text(e) { var data = clipb.getData('Text'); var list = data.split(/\r\n|\r|\n|\t| /g); var currentInput = event.currentTarget; - - for(var i=0 ; i