diff --git a/~dev_rating/media/js/rating.js b/~dev_rating/media/js/rating.js index 50afac526a4d26cf13dc6d0e668cce7eb35383dd..e1de3678e70f1b7e2fb66e40c2a334f0acafbc75 100644 --- a/~dev_rating/media/js/rating.js +++ b/~dev_rating/media/js/rating.js @@ -1,6 +1,27 @@ var $ = jQuery; $(function() { + + function controlRowVisualization(jRow) { + var jAutoPassCheckBox = jRow.children(".autoPass").children(".autoPassCheck"); + var semesterRate = parseInt(jRow.children(".semesterRateResultCell").text()); + var absence = jRow.children(".absenceCell").children(".absenceCheck").is(":checked"); + if ((semesterRate < 60) || (absence)) + jAutoPassCheckBox.attr("disabled", true); + else + jAutoPassCheckBox.removeAttr("disabled"); + } + + function controlVisualization() { + $(".autoPassCheck") + .each( function() { + controlRowVisualization($(this).parent().parent()); + }); + } + + // on page loaded + controlVisualization(); + var g_col; var g_row; var g_isFocusCell = false; // Стоит фокус на ячейки или нет @@ -159,10 +180,13 @@ $(function() { { // страница оценивания jThis.siblings(".commonCell").each(function(){ // добавим сумму баллов в соседних ячейках - if ($(this).children("input").val() !== "") - rateResult += parseInt($(this).children("input").val()); + var rate = $(this).children("input").val(); + if (rate) + rateResult += parseInt(rate); }); - rateResult += parseInt(jThis.siblings(".examCell").text()); + var examRateStr = jThis.siblings(".examCell").children("p").text(); + if (examRateStr) + rateResult += parseInt(examRateStr); } if (newRate <= g_submoduleMaxRate) @@ -185,11 +209,7 @@ $(function() { jThis.siblings(".rateResultCell").text(correctRate); EventInspector_ShowMsg("Балл добавлен/изменен", "success"); } - else - { - jThis.children("input").val(oldRate); - EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error"); - } + else EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error"); jThis.children("input").removeAttr("disabled"); } } @@ -200,7 +220,9 @@ $(function() { jThis.children("input").val(oldRate); else jThis.children("input").val("0"); - + if(jThis.children("input").val()=="0") + jThis.children("input").val(""); + EventInspector_ShowMsg("Текущий балл превышает максимальный для данного модуля", "error"); jThis.children("input").removeAttr("disabled"); } @@ -235,6 +257,7 @@ $(function() { Rating($(this), oldRate); TdUnFocus(); UnsetTdInfo($(this)); + controlRowVisualization($(this).parent()); }); $(".commonCell").keyup(function(e){ @@ -287,8 +310,11 @@ $(function() { $(".commonCell").children("input").keydown(function(event) { KeyDownOnlyNumber(event); }); - - + + // Нажатие на чекбокс "Автомат" + $(".absenceCheck").click(function(event) { + controlRowVisualization($(this).parent().parent()); + }); // Фильтр по группе $(".groupSelector").change(function() {