Skip to content
Snippets Groups Projects
Commit 272c6a65 authored by RomanSteinberg's avatar RomanSteinberg
Browse files

FIX: 100 rate bug

parent fbd4ed8d
Branches
Tags
No related merge requests found
......@@ -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);
......
......@@ -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 %}
......
......@@ -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 %}
......
......@@ -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(){
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment