Newer
Older
var g_isFocusCell = false; // Стоит фокус или нет
var g_oldRateCell = null;
var g_submoduleID = null;
var g_studentID = null;
var g_submoduleTitle = "";
var jTdInfo_wrap = $("#tdInfo_wrap");
var jTdInfo = jTdInfo_wrap.children('#tdInfo');
var g_URL = (window.location.href).split("/");
var g_disciplineID = g_URL[g_URL.length - 1];
// studyGroupID для фильтра
var json_settings = $.parseJSON($("#hidden_div").html());
$("#hidden_div").remove();
filterGroups(json_settings.studyGroupID);
$(".groupSelector [value='"+ json_settings.studyGroupID +"']").attr("selected", "selected");
// Скрываем все остальные группы
// 0 - показать все
function filterGroups(groupID) {
if (groupID == 0) {
$(".studentsRate tbody")
.children()
.each( function() {
$(this).show();
});
} else {
$(".studentsRate tbody")
.children(":gt(2)")
.each( function() {
if ($(this).hasClass(groupID))
$(this).show();
else
$(this).hide();
});
}
}
g_col = parseInt(jThis.attr('id'));
g_row = parseInt(jThis.parent('tr').attr('id'));
$(".RatingTableSubmodulesHeadMaxRate .col_" + g_col).css("background-color", "#f1f1f1");
$(this).children('input').css("background-color", "#f1f1f1");
$(this).children('input').css("background-color", "#f1f1f1");
$("tr#" + g_row + " .staticCell").each(function(){
$(this).css("background-color", "#f1f1f1");
});
jThis.children('input').css("background-color", "#fff");
$(".RatingTableSubmodulesHeadMaxRate .col_" + g_col).css("background-color", "#fff");
$(this).children('input').css("background-color", "#fff");
$(this).children('input').css("background-color", "#fff");
$("tr#" + g_row + " .staticCell").each(function(){
$(this).css("background-color", "#fff");
});
g_submoduleID = parseInt($(".RatingTableSubmodulesHeadMaxRate .col_"+g_col+":first").attr("id"));
g_submoduleTitle = $(".RatingTableSubmodulesHead .col_"+g_col+":first").text();
if ($(".RatingTableSubmodulesHead .col_"+g_col+":first").length < 1 && $(".RatingTableModulesHead .bonus").length > 0 )
g_submoduleTitle = 'Бонусные баллы';
g_submoduleMaxRate = parseInt($(".RatingTableSubmodulesHeadMaxRate #"+g_submoduleID).children("input").val());
g_studentID = parseInt(jThis.siblings('.student').attr("id"));
g_stdName = jThis.siblings('.student').text();
jTdInfo_wrap.show();
jTdInfo.children("#student").children("b").html(g_stdName);
jTdInfo.children("#submodule").children("b").html(g_submoduleTitle);
jTdInfo.children("#maxRate").children("b").html(g_submoduleMaxRate);
// jThis.append("<div class='tdInfo'>"+g_submoduleTitle+"<br>"+g_stdName+"</div>");
// Здесь jThis - div rateCell, а не input, который является дочкой
jThis.children("input").attr("disabled", true);
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(".RateResult").text()) - oldRate + newRate;
if (rateResult > 100) {
jThis.children("input").val(oldRate);
EventInspector_ShowMsg("Сумма баллов не может привышать 100", "error");
jThis.children("input").removeAttr("disabled");
}
else
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");
200: function(data) {
data = $.parseJSON(data);
if(data.success === true) {
jThis.siblings(".RateResult").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");
}
}
}
$(".rateCell").mouseenter(function(){
if (g_isFocusCell === false)
});
$(".rateCell").mouseleave(function(){
if (g_isFocusCell === false)
});
var oldRate = 0;
$(".rateCell").focusin(function(){
g_isFocusCell = true;
if ($(this).children("input").val() !== "")
oldRate = $(this).children("input").val();
else oldRate = 0;
});
$(".rateCell").focusout(function(){
g_isFocusCell = false;
var newRate = 0;
if ($(this).children("input").val() !== "")
newRate = $(this).children("input").val();
if (newRate != oldRate)
Rating($(this), oldRate);
UnsetTdInfo($(this));
});
$(".rateCell").keyup(function(e){
// При нажатие Enter (переход к оцениванию след. студента, т.е. ниже)
if(e.keyCode==13)
if ((e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 ) {
var jTempObj = $("tr#" + row + " td#" + col + ".rateCell");
if (jTempObj.length > 0) {
TdUnFocus();
g_row = row;
g_col = col;
jTempObj.children("input").focus();
}
}
});
$(".rateCell input").focusin(function(){
$(this).select();
});
// При нажатие на элемент rateCell дочерный input получает фокус
$(".rateCell ").click(function(){
$(this).children("input").focus();
} );
// В inputCredit (где баллы вводить) разрешаем вводить только цифры
$(".rateCell").children("input").keydown(function(event) {
KeyDownOnlyNumber(event);
var val = parseInt($(this).val()); // StudyGroupID
$.post(
URLdir + "handler/rating/SelectGroup",
{
"disciplineID": g_disciplineID,
"groupSelected": val
},
function(data){
data = $.parseJSON(data);
if(data.success === true) {
}
}
);
}
$(".downloadExcel").click(function(){
$.fileDownload(URLdir + 'handler/rating/GetExcelRateTable', {
httpMethod: "POST",
data:
{
'disciplineID': g_disciplineID
},
successCallback: function (url) {
// $('#downloadStudentPDF').removeAttr('disabled');
}
// failCallback: function (html, url) {
// $('#downloadStudentPDF').removeAttr('disabled');
// alert(html);
// }
});
});