/usr/lib/python2.7/dist-packages/schooltool/gradebook/browser/resources/gradebook_overview.js is in python-schooltool.gradebook 2.6.3-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | /* This is the Javascript to be included when rendering the gradebook overview. */
function setNotEdited()
{
edited = false;
}
function checkChanges()
{
if (!edited)
return;
saveFlag = window.confirm(warningText);
if (saveFlag == true)
{
button = document.getElementsByName('UPDATE_SUBMIT')[0];
button.click();
}
else
return true;
}
function onLoadHandler()
{
// highlight error values
for (a = 0; a < numactivities; a++)
{
activity = activities[a];
for (s = 0; s < numstudents; s++)
{
name = activity + '_' + students[s];
value = document.getElementById(name).value;
setBackgroundColor(name, activity, value, true);
}
}
}
function handleCellFocus(cell, activity)
{
currentCell = cell;
cell.select();
setDescription(activity);
}
function setDescription(activity)
{
desc = document.getElementById('description');
currentDesc = descriptions[activity];
desc.innerHTML = currentDesc;
}
function tempDescription(activity)
{
desc = document.getElementById('description');
desc.innerHTML = descriptions[activity];
}
function restoreDescription()
{
desc = document.getElementById('description');
desc.innerHTML = currentDesc;
}
function spreadsheetBehaviour(e)
{
var keynum;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
var my_name = currentCell.id;
var s, a, done;
done = new Boolean(false);
for (s = 0; s != numstudents; s++)
{
for (a = 0; a != numactivities; a++)
{
try_name = activities[a] + '_' + students[s]
if (try_name == my_name)
{
done = true;
break;
}
}
if (done == true)
break;
}
var i_stayed_put = new Boolean(true);
if (keynum == 37) // left arrow
{
if (a != 0) { a--; i_stayed_put = false;}
}
if (keynum == 39) // right arrow
{
if (a != numactivities - 1) {a++; i_stayed_put = false;}
}
if (keynum == 38) // up arrow
{
if (s != 0) {s--; i_stayed_put = false;}
}
if ((keynum == 40) || (keynum == 13)) // down arrow or enter
{
if (s != numstudents - 1) {s++; i_stayed_put = false;}
}
if (i_stayed_put == true)
return true;
var newname = activities[a] + '_' + students[s];
var el = document.getElementsByName(newname)[0]
el.focus();
return false;
}
function checkValid(e, name)
{
var activity = name.split('_')[0];
if(activity == "fd")
activity = name.split('_')[1];
if (e == null)
return true;
var keynum;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
if (keynum < 48 || (keynum > 57 && keynum < 65) || (keynum > 90 && keynum < 97) || keynum > 122)
{
return true;
}
edited = true;
var element = document.getElementById(name);
var elementCell = document.getElementById(name+'_cell');
var value = element.value;
return setBackgroundColor(name, activity, value, false);
}
function setBackgroundColor(name, activity, value, errors_only)
{
changeBackgroundColor(name+'_cell', 'default_bg');
if (value == '')
return true;
// handle validation of discrete score system
var actScores = scores[activity];
if (actScores[0] == 'd')
{
for(var index in actScores)
{
if (index > 0 && value == actScores[index])
{
if (!errors_only)
changeBackgroundColor(name+'_cell', 'changed_bg');
return true;
}
}
changeBackgroundColor(name+'_cell', 'error_bg');
return false;
}
// handle validation of ranged score system
else
{
var min = parseInt(actScores[1]);
var max = parseInt(actScores[2]);
var intValue = parseInt(value);
var regex = /[0-9]+$/;
if (!value.match(regex) || intValue < min)
{
changeBackgroundColor(name+'_cell', 'error_bg');
return false;
}
if (errors_only)
return true;
if (intValue > max)
{
changeBackgroundColor(name+'_cell', 'warning_bg');
return true;
}
}
changeBackgroundColor(name+'_cell', 'changed_bg');
return true;
}
function performFillDown(activity) {
var fd = document.getElementById('fd_'+activity);
if (fd.value=='') return false;
changeBackgroundColor('fd_'+activity+'_cell', 'default_bg');
if (checkValid(null, 'fd_'+activity) == false) {
changeBackgroundColor('fd_'+activity+'_cell', 'warning_bg');
return false;
}
for(j=0;j!=numstudents;j++) {
name = activity+'_'+students[j];
document.getElementById(name).value = fd.value;
setBackgroundColor(name, activity, fd.value, false);
}
document.getElementById('fd_'+activity).value = '';
document.getElementById('fdbtn_'+activity).style.display = 'none';
changeBackgroundColor('fd_'+activity+'_cell', 'default_bg');
edited = true;
}
function checkFillDown(activity)
{
var fd = document.getElementById('fd_'+activity);
if (checkValid(null, 'fd_'+activity))
{
var el = document.getElementById('fdbtn_'+activity);
el.style.display='block';
if (document.getElementById('fd_'+activity).value=='') {
changeBackgroundColor('fd_'+activity+'_cell', 'default_bg');
el.style.display='none';
}
}
else
{
document.getElementById('fdbtn_'+activity).style.display='none';
if (document.getElementById('fd_'+activity).value=='') {
changeBackgroundColor('fd_'+activity+'_cell', 'default_bg');
}
}
}
function changeBackgroundColor(id, class) {
obj = document.getElementById(id);
$(obj).removeClass('default_bg');
$(obj).removeClass('changed_bg');
$(obj).removeClass('warning_bg');
$(obj).removeClass('error_bg');
$(obj).addClass(class);
}
|