diff --git a/~dev_rating/application/classes/Controller/Teacher/Rating.php b/~dev_rating/application/classes/Controller/Teacher/Rating.php index 2816a5ea5b0793d52ebf38b2119a05859ba10db0..818c70a0aeabb94c9d690381f0ab4eeede4866e9 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Rating.php +++ b/~dev_rating/application/classes/Controller/Teacher/Rating.php @@ -197,6 +197,7 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { // Шапка таблицы: структура УКД (модули и мероприятия) $structure = $this->model_rating->GetMapForDisciplineExam($this->UserInfo['TeacherID'], $id); + $disciplineInfo = $this->getDisciplineInformation($id); if($structure->count() == 0) throw HTTP_Exception::factory (404, "Страница не найдена"); @@ -353,14 +354,14 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $curStudent['RateSemesterResult'] = $total - $curStudent['RateResult']; $curStudent['RateResult'] = $total; - $magic_bottom = 32; - $magic_top = 38; + $bottomLimit = 0; + $topLimit = ($disciplineInfo['ExamType'] == 'exam') ? 38 : 60; $extra_rate = 0; - if ($curStudent['RateSemesterResult'] >= $magic_bottom && - $curStudent['RateSemesterResult'] <= $magic_top) + if ($curStudent['RateSemesterResult'] >= $bottomLimit && + $curStudent['RateSemesterResult'] <= $topLimit) { - $extra_rate = $magic_top - $curStudent['RateSemesterResult']; + $extra_rate = $topLimit - $curStudent['RateSemesterResult']; } if ($lastExtra >= 0) { $curStudent['Rates'][$lastExtra]['MaxRate'] = $extra_rate; @@ -378,7 +379,7 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $twig->rateTable = $rateHandled; $twig->groups = $groupsHandled; - $twig->disciplineInfo = $this->getDisciplineInformation($id); + $twig->disciplineInfo = $disciplineInfo; $twig->disciplineInfo_JSON = json_encode($twig->disciplineInfo); $this->response->body($twig); diff --git a/~dev_rating/application/views/teacher/exam.twig b/~dev_rating/application/views/teacher/exam.twig index ee45f1d58b86e9b6b83a18f26e542cb8719486e7..9143382306d6a742f0a5ed1c5e2d25ec7421f038 100644 --- a/~dev_rating/application/views/teacher/exam.twig +++ b/~dev_rating/application/views/teacher/exam.twig @@ -111,7 +111,7 @@ {% endif %} {% endfor %} - <td class="rateResultCell staticCell">{{ student.RateResult }}</td> + <td class="rateResultCell staticCell">{% if student.RateResult > 100 %} 100+ {% else %} {{ student.RateResult }} {% endif %}</td> </tr> {% endfor %} diff --git a/~dev_rating/application/views/teacher/rating.twig b/~dev_rating/application/views/teacher/rating.twig index 08b19cd6c5fe39dcd1f422d86c2d6e1ece24b34a..97bd2e9c35a36a1fab97b8b4e9db65696430c2ef 100644 --- a/~dev_rating/application/views/teacher/rating.twig +++ b/~dev_rating/application/views/teacher/rating.twig @@ -113,7 +113,7 @@ </td> {% endif %} {% endfor %} - <td class="rateResultCell staticCell">{{ student.RateResult }}</td> + <td class="rateResultCell staticCell">{% if student.RateResult > 100 %} 100+ {% else %} {{ student.RateResult }} {% endif %}</td> </tr> {% endfor %} diff --git a/~dev_rating/media/js/rating.js b/~dev_rating/media/js/rating.js index 171119ff167b681aecede3000cfcb312d81ecac3..9944dacf5bad02122b1943ae58666bcc39d763cc 100644 --- a/~dev_rating/media/js/rating.js +++ b/~dev_rating/media/js/rating.js @@ -137,78 +137,70 @@ $(function() { oldRate = parseInt(oldRate); // Здесь jThis - div rateCell, а не input, который является дочкой jThis.children("input").attr("disabled", true); - - var newRate = 0; - if (jThis.children("input").val() !== "") - newRate = parseInt(jThis.children("input").val()); - //var maxRate = parseInt($(".RatingTableSubmodulesHeadMaxRate #"+g_submoduleID).children("input").val()); - - var rateResult = parseInt(jThis.siblings(".rateResultCell").text()) - oldRate + newRate; - - // страница сессии + + + var newRate = 0; + if (jThis.children("input").val() !== "") + newRate = parseInt(jThis.children("input").val()); + var rateResult = newRate; + + // считаем баллы по строке if (jThis.attr("class").indexOf("attemptCell") >= 0) { - //if (jThis.siblings(".semesterRateResultCell ").length > 0) { - rateResult = parseInt(jThis.siblings(".semesterRateResultCell").text()) + newRate; // todo + // страница сессии + rateResult += parseInt(jThis.siblings(".semesterRateResultCell").text()); jThis.siblings(".additionalCell").each(function(){ if ($(this).children("input").val() !== "") - rateResult += parseInt($(this).children("input").val()); + rateResult += parseInt($(this).children("input").val()); }); - //} + } + else + { + // страница оценивания + jThis.siblings(".commonCell").each(function(){ // добавим сумму баллов в соседних ячейках + if ($(this).children("input").val() !== "") + rateResult += parseInt($(this).children("input").val()); + console.log($(this).attr("id")+" "+$(this).children("input").val()+" "); + }); + rateResult += parseInt(jThis.siblings(".examCell").text()); + } + + if (newRate <= g_submoduleMaxRate) + { + $.ajax({ + type: "POST", + url: URLdir + "handler/rating/setRate", + data: "student="+g_studentID+"&submodule="+g_submoduleID+"&rate="+newRate, + statusCode: { + 403: function() { + EventInspector_ShowMsg("Сессия истекла", "error"); + jThis.children("input").val(oldRate); + jThis.children("input").removeAttr("disabled"); + window.location.replace(URLdir); + }, + 200: function(data) { + data = $.parseJSON(data); + if(data.success === true) { + var correctRate = (rateResult > 100) ? '100+' : rateResult; + jThis.siblings(".rateResultCell").text(correctRate); + EventInspector_ShowMsg("Балл добавлен/изменен", "success"); + } + else EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error"); + jThis.children("input").removeAttr("disabled"); + } + } + }); + } + else { + if (oldRate <= g_submoduleMaxRate) + jThis.children("input").val(oldRate); + else + jThis.children("input").val("0"); + + EventInspector_ShowMsg("Текущий балл превышает максимальный для данного модуля", "error"); + jThis.children("input").removeAttr("disabled"); } - //end страница сессии - - if (rateResult > 100) { - jThis.children("input").val(oldRate); - EventInspector_ShowMsg("Сумма баллов не может привышать 100", "error"); - jThis.children("input").removeAttr("disabled"); - } - else - { - if ((json_settings.ExamType == "exam") && (rateResult - parseInt(jThis.siblings(".examCell").text())) > 60) - { - jThis.children("input").val(oldRate); - EventInspector_ShowMsg("Сумма баллов не может привышать 60 (т.к. 40 на экзамен)", "error"); - jThis.children("input").removeAttr("disabled"); - return -1; - } - - if (newRate <= g_submoduleMaxRate) - { - $.ajax({ - type: "POST", - url: URLdir + "handler/rating/setRate", - data: "student="+g_studentID+"&submodule="+g_submoduleID+"&rate="+newRate, - statusCode: { - 403: function() { - EventInspector_ShowMsg("Сессия истекла", "error"); - jThis.children("input").val(oldRate); - jThis.children("input").removeAttr("disabled"); - window.location.replace(URLdir); - }, - 200: function(data) { - data = $.parseJSON(data); - if(data.success === true) { - jThis.siblings(".rateResultCell").text(rateResult); - EventInspector_ShowMsg("Балл добавлен/изменен", "success"); - } - else EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error"); - jThis.children("input").removeAttr("disabled"); - } - } - }); - } - else { - if (oldRate <= g_submoduleMaxRate) - jThis.children("input").val(oldRate); - else - jThis.children("input").val("0"); - - EventInspector_ShowMsg("Текущий балл превышает максимальный для данного модуля", "error"); - jThis.children("input").removeAttr("disabled"); - } - } } $(".commonCell").mouseenter(function(){