Skip to content
Snippets Groups Projects
Commit 42c3c964 authored by PavelBegunkov's avatar PavelBegunkov
Browse files

Refactor exam.js (adjusting code style & eliminating warnings)

parent ea248c36
No related merge requests found
......@@ -24,26 +24,31 @@ $(function () {
messageFail: 'Отмена автомата не удалась'
}
};
var json_settings = $.parseJSON($("#hidden_div").html());
var pageType = $("#pageType").val();
var disciplineType = $("#ExamType").val();
var json_settings = (function () {
var $hiddenInfo = $('#hidden_div');
var data = $.parseJSON($hiddenInfo.html());
$hiddenInfo.remove();
return data;
})();
var pageType = $('#pageType').val();
var disciplineType = $('#ExamType').val();
var cancelFlag = false;
var g_col;
var g_row;
var g_isFocusCell = false; // Стоит фокус на ячейки или нет
var g_isFocusCell = false; // Стоит фокус на ячейке или нет
var g_oldRateCell = null;
var g_submoduleID = null;
var g_studentID = null;
var g_submoduleTitle = "";
var g_submoduleTitle = '';
var g_submoduleMaxRate = 0;
var g_stdName = "";
var g_stdName = '';
var jCommonCell = $('.commonCell');
var jTdInfo_wrap = $("#tdInfo_wrap");
var jTdInfo_wrap = $('#tdInfo_wrap');
var jTdInfo = jTdInfo_wrap.children('#tdInfo');
var g_URL = (window.location.href).split("/");
var g_disciplineID = $('#disciplineID').val();
var StudentState = {
successful: 0, // успевающий
beforeExam: 1, // экзамен еще не состоялся
......@@ -52,7 +57,7 @@ $(function () {
admitted: 4, // допуск получен, экзамен еще не состоялся
admittedAndPassed: 5, // задолженность закрыта полностью
admittedAndNotPassed: 6 // допуск получен, экзамен не сдал
}
};
// on page loaded
// Настройки дисциплины:
......@@ -60,16 +65,21 @@ $(function () {
// + studyGroupID_Filter - studyGroupID для фильтра (Эффект памяти)
controlVisualization();
$("div.main_content").ready(AdjustTable);
$('div.main_content').ready(AdjustTable);
$(window).resize(AdjustTable);
$("#hidden_div").remove();
filterGroups(json_settings.GroupID_Filter);
$(".groupSelector [value='" + json_settings.GroupID_Filter + "']").attr("selected", "selected");
// выставить фильтр по группам
(function () {
var groupID = json_settings['GroupID_Filter'];
if (groupID) {
filterGroups(groupID);
$(".groupSelector [value='" + groupID + "']").attr('selected', 'selected');
}
})();
function AdjustTable() {
var jWrap = $('div.main_layer');
var jTable = $("div.main_content");
var jTable = $('div.main_content');
var tableWidth = jTable.get(0).scrollWidth;
// check scroll bar
if (tableWidth <= jTable.width() + 10) {
......@@ -80,24 +90,24 @@ $(function () {
tableWidth *= 1.1;
var maxWidth = $(window).width() * 0.95;
var newWidth = (tableWidth > maxWidth) ? maxWidth : tableWidth;
jWrap.css("max-width", newWidth);
jWrap.css('max-width', newWidth);
}
function deriveStudentState (semesterRate, extraRate, examRate, autopass, firstAttempt) {
function deriveStudentState(semesterRate, extraRate, examRate, autopass, firstAttempt) {
var admissionRate = semesterRate + extraRate;
if (admissionRate >= 38) {
if ((semesterRate >= 38) && firstAttempt) {
if ((examRate >=22) || autopass)
if ((examRate >= 22) || autopass)
return StudentState.successful; // успевающий
else if (examRate == -1)
else if (examRate == -1)
return StudentState.beforeExam; // экзамен еще не состоялся
else
else
return StudentState.notPassed; // пытался сдать экзамен и не сдал
} else {
if (examRate == -1)
return StudentState.admitted; // допуск получен, экзамен еще не состоялся
else if (examRate >=22)
else if (examRate >= 22)
return StudentState.admittedAndPassed; // задолженность закрыта
else
return StudentState.admittedAndNotPassed; // допуск получен, экзамен не сдал
......@@ -105,31 +115,31 @@ $(function () {
} else
return StudentState.notAdmitted; // недопущенный задолженник
}
function setCellAccess(cell, access) {
if (access)
$(cell).removeAttr("disabled");
$(cell).removeAttr('disabled');
else
$(cell).attr("disabled", true);
$(cell).attr('disabled', true);
}
function controlRowVisualization(jRow) {
if ((pageType !== "exam") || (disciplineType !== "exam")) { // || (json_settings.ExamType !== "exam")) {
if ((pageType !== 'exam') || (disciplineType !== 'exam')) { // || (json_settings.ExamType !== 'exam')) {
return;
}
var jAutoPassCheckBox = jRow.children(".autoPass").children(".autoPassCheck");
var jAbsenceCheckBoxes = jRow.children(".absenceCell").children(".absenceCheck");
var jAttemptCells = jRow.children(".attemptCell").find(":text").parent();
var jExtraInputs = jRow.children(".additionalCell").children(".extra");
var semesterRate = parseInt(jRow.children(".semesterRateResultCell").text());
var jAutoPassCheckBox = jRow.children('.autoPass').children('.autoPassCheck');
var jAbsenceCheckBoxes = jRow.children('.absenceCell').children('.absenceCheck');
var jAttemptCells = jRow.children('.attemptCell').find(':text').parent();
var jExtraInputs = jRow.children('.additionalCell').children('.extra');
var semesterRate = parseInt(jRow.children('.semesterRateResultCell').text());
var autopass = jAutoPassCheckBox[0].checked;
var absence = jAbsenceCheckBoxes[0].checked;
if (semesterRate < 60 || absence) {
jAutoPassCheckBox.attr("disabled", true);
jAutoPassCheckBox.attr('disabled', true);
} else {
jAutoPassCheckBox.removeAttr("disabled");
jAutoPassCheckBox.removeAttr('disabled');
}
// суммарный добор
......@@ -139,80 +149,77 @@ $(function () {
});
var row = +jRow.attr('id').substr(4); // одинаковая для всех
// Определим экзамен
var curExamCell = 0;
var curExamRate = 0;
var curExamCellIndex = 0;
var index = 0;
var dependentCells = [[0,0], [0, 0], [0,0]]; // размер зависит от jAttemptCells.length
var dependentCells = [[0, 0], [0, 0], [0, 0]]; // размер зависит от jAttemptCells.length
jAttemptCells.each(function () {
var needToRemeber = (curExamCell == 0); // инициализация первым экзаменом
var id = $(this).attr('id');
var col = +id.substr(4,1);
var neighborAbsenceCheck = $($("#absence_" + col + "_" + row).children()[0]);
var col = +id.substr(4, 1);
var neighborAbsenceCheck = $($('#absence_' + col + '_' + row).children()[0]);
dependentCells[index][0] = $(this);
dependentCells[index][1] = neighborAbsenceCheck.parent();
var strVal = $(this).children()[0].value;
var examRate = +strVal;
if (strVal === "") {
examRate = -1; // спец значение, означает "не было оценки за экзамен"
if (strVal === '') {
examRate = -1; // спец значение, означает 'не было оценки за экзамен'
if (neighborAbsenceCheck.is(':checked')) {// неявка = 0 баллов
examRate = 0;
needToRemeber = true;
}
} else
} else
needToRemeber = true;
if (needToRemeber) {
curExamCell = $(this);
curExamCell = $(this);
curExamRate = examRate;
curExamCellIndex = index;
}
index++;
});
var state = deriveStudentState(semesterRate, extraRate, curExamRate, autopass, curExamCellIndex == 0)
var state = deriveStudentState(semesterRate, extraRate, curExamRate, autopass, curExamCellIndex == 0);
// Выставляем доступность ячеек
// Доступность добора
var needAccess = !(state == StudentState.successful ||
state == StudentState.beforeExam ||
state == StudentState.notPassed);
var needAccess = !(state == StudentState.successful ||
state == StudentState.beforeExam ||
state == StudentState.notPassed);
setCellAccess($(jExtraInputs[0]), needAccess);
// Доступность экзаменов
var examAccess = [false, false, false];
if (state == StudentState.successful || state == StudentState.beforeExam)
examAccess[0] = true; // только основная сдача
else if (state == StudentState.admitted)
examAccess[1] = true; // только пересдача 1
else if (state == StudentState.admittedAndPassed)
else if (state == StudentState.admittedAndPassed)
examAccess[curExamCellIndex] = true; // только текущая пересдача
else if (state == StudentState.notPassed || state == StudentState.admittedAndNotPassed) {
examAccess[curExamCellIndex] = true; // текущая сдача и следующий
if (++curExamCellIndex < 3) // 3 == jAttemptCells.length
examAccess[curExamCellIndex] = true;
examAccess[curExamCellIndex] = true;
}
for(index = 0; index < 3; ++index) { // 3 == jAttemptCells.length
for (index = 0; index < 3; ++index) { // 3 == jAttemptCells.length
var examCell = dependentCells[index][0];
var val = +examCell.children()[0].value;
var absenceCell = dependentCells[index][1];
var absenceChecked = absenceCell.children()[0].checked;
needAccess = examAccess[index] && !absenceChecked;
setCellAccess(examCell.children()[0], needAccess);
needAccess = examAccess[index]; //&& (val == 0);
setCellAccess(absenceCell.children()[0], needAccess);
}
// чекбоксы влияют на соседей
/*
var followingExamsDisabled = false;
......@@ -220,36 +227,36 @@ $(function () {
jAbsenceCheckBoxes.each(function () {
var id = $(this).parent().attr('id');
var col = parseInt(id.substr(8));
var neighborExamInput = $("#col_" + col + "_row_" + row).children();
var neighborExamInput = $('#col_' + col + '_row_' + row).children();
var failedStudy = (semesterRate < 38);
var stillFailedStudy = (semesterRate + extraRate < 38);
$(this).removeAttr("disabled");
$(this).removeAttr('disabled');
if (autopass || // автомат
(firstInARow && failedStudy) || // задолженник
stillFailedStudy) // задолженник до сих пор
{
$(this).attr("disabled", true);
$(this).attr('disabled', true);
}
// TODO: условия этого и предыдущего if вынести в отдельную функцию, проверяющую допустимость
if (($(this)[0].checked) || autopass || followingExamsDisabled || stillFailedStudy) { // автомат, неявка или сдал до этого или не сдал вовсе
neighborExamInput.attr("disabled", true);
neighborExamInput.attr('disabled', true);
} else {
var needEnable = false;
if (failedStudy)// задолженник или задолженник до сих пор
{
if (firstInARow)
neighborExamInput.attr("disabled", true);
neighborExamInput.attr('disabled', true);
else
needEnable = true;
} else
needEnable = true;
if (needEnable) {
neighborExamInput.removeAttr("disabled");
neighborExamInput.removeAttr('disabled');
curExamRate = +neighborExamInput.val();
if ((neighborExamInput.val() === "") || (curExamRate >= 22)) { // не приступал к сдаче или уже сдал
if ((neighborExamInput.val() === '') || (curExamRate >= 22)) { // не приступал к сдаче или уже сдал
followingExamsDisabled = true;
}
}
......@@ -260,9 +267,9 @@ $(function () {
}
function controlVisualization() {
$(".studentsRate").children().children("tr")
$('.studentsRate').children().children('tr')
.each(function () {
if (($(this).prop("id") !== "") && ($(this).attr("id").substr(0, 3) === "row")) {
if (($(this).prop('id') !== '') && ($(this).attr('id').substr(0, 3) === 'row')) {
controlRowVisualization($(this));
}
});
......@@ -272,16 +279,16 @@ $(function () {
// 0 - показать все
function filterGroups(groupID) {
if (groupID == 0) {
$(".studentsRate tbody")
$('.studentsRate tbody')
.children()
.each(function () {
$(this).show();
});
} else {
$(".studentsRate tbody")
.children(":gt(2)")
$('.studentsRate tbody')
.children(':gt(2)')
.each(function () {
if ($(this).hasClass("group_" + groupID))
if ($(this).hasClass('group_' + groupID))
$(this).show();
else
$(this).hide();
......@@ -296,61 +303,61 @@ $(function () {
g_row = jThis.parent('tr').attr('id');
g_row = parseInt(g_row.substr(4));
g_oldRateCell = jThis.children("input").val();
$("td#col_" + g_col + ".commonCell").each(function () {
$(this).children('input').css("background-color", "#f1f1f1");
g_oldRateCell = jThis.children('input').val();
$('td#col_' + g_col + '.commonCell').each(function () {
$(this).children('input').css('background-color', '#f1f1f1');
});
$("td#col_" + g_col + ".staticCell").each(function () {
$(this).children('input').css("background-color", "#f1f1f1");
$('td#col_' + g_col + '.staticCell').each(function () {
$(this).children('input').css('background-color', '#f1f1f1');
});
$("tr#row_" + g_row + " .commonCell").each(function () {
$(this).children('input').css("background-color", "#f1f1f1");
$('tr#row_' + g_row + ' .commonCell').each(function () {
$(this).children('input').css('background-color', '#f1f1f1');
});
$("tr#row_" + g_row + " .staticCell").each(function () {
$(this).css("background-color", "#f1f1f1");
$(this).children('input').css("background-color", "#f1f1f1");
$('tr#row_' + g_row + ' .staticCell').each(function () {
$(this).css('background-color', '#f1f1f1');
$(this).children('input').css('background-color', '#f1f1f1');
});
jThis.children('input').css("background-color", "#fff");
jThis.children('input').css('background-color', '#fff');
}
// Убираем подстветку
function TdUnFocus() {
$("td#col_" + g_col + ".commonCell").each(function () {
$(this).children('input').css("background-color", "#fff");
$('td#col_' + g_col + '.commonCell').each(function () {
$(this).children('input').css('background-color', '#fff');
});
$("td#col_" + g_col + ".staticCell").each(function () {
$(this).children('input').css("background-color", "#fff");
$('td#col_' + g_col + '.staticCell').each(function () {
$(this).children('input').css('background-color', '#fff');
});
$("tr#row_" + g_row + " .commonCell").each(function () {
$(this).children('input').css("background-color", "#fff");
$('tr#row_' + g_row + ' .commonCell').each(function () {
$(this).children('input').css('background-color', '#fff');
});
$("tr#row_" + g_row + " .staticCell").each(function () {
$(this).css("background-color", "#fff");
$(this).children('input').css("background-color", "#fff");
$('tr#row_' + g_row + ' .staticCell').each(function () {
$(this).css('background-color', '#fff');
$(this).children('input').css('background-color', '#fff');
});
}
function TdInfo(jThis) {
var disciplinePassRate = 60; // credit pass rate
if (disciplineType === "exam")
if (disciplineType === 'exam')
disciplinePassRate = 38;
// Получаем подмодуль
var jCurSubmoduleInfo = $(".RatingTableSubmodulesInfo .col_" + g_col + ":first");
var jCurSubmoduleHead = $(".RatingTableSubmodulesHead .col_" + g_col + ":first");
var jCurSubmoduleInfo = $('.RatingTableSubmodulesInfo .col_' + g_col + ':first');
var jCurSubmoduleHead = $('.RatingTableSubmodulesHead .col_' + g_col + ':first');
g_submoduleID = parseInt(jCurSubmoduleInfo.attr("id"));
g_submoduleID = parseInt(jCurSubmoduleInfo.attr('id'));
g_submoduleTitle = jCurSubmoduleHead.text();
if (jCurSubmoduleHead.length < 1 && $(".RatingTableModulesHead .bonus").length > 0)
if (jCurSubmoduleHead.length < 1 && $('.RatingTableModulesHead .bonus').length > 0)
g_submoduleTitle = 'Бонусные баллы';
g_submoduleMaxRate = parseInt($(".RatingTableSubmodulesHeadMaxRate .col_" + g_col).text());
g_submoduleMaxRate = parseInt($('.RatingTableSubmodulesHeadMaxRate .col_' + g_col).text());
// Проверяем допустимое значение (только для добора)
if (jThis.attr("class").indexOf("additionalCell") >= 0) {
var semesterRate = parseInt(jThis.siblings(".semesterRateResultCell").text());
if (jThis.attr('class').indexOf('additionalCell') >= 0) {
var semesterRate = parseInt(jThis.siblings('.semesterRateResultCell').text());
if (semesterRate <= disciplinePassRate)
g_submoduleMaxRate = disciplinePassRate - semesterRate;
else
......@@ -358,22 +365,22 @@ $(function () {
}
// Получаем студента
g_studentID = jThis.siblings('.studentCell').attr("id");
g_studentID = jThis.siblings('.studentCell').attr('id');
g_studentID = g_studentID.substr(8);
g_stdName = jThis.siblings('.studentCell').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);
jTdInfo.children('#student').children('b').html(g_stdName);
jTdInfo.children('#submodule').children('b').html(g_submoduleTitle);
jTdInfo.children('#maxRate').children('b').html(g_submoduleMaxRate);
//if (jThis.children('.tdInfo').length <= 0)
// jThis.append("<div class='tdInfo'>"+g_submoduleTitle+"<br>"+g_stdName+"</div>");
// jThis.append('<div class='tdInfo'>'+g_submoduleTitle+'<br>'+g_stdName+'</div>');
}
function UnsetTdInfo(jThis) {
//jThis.children(".tdInfo").remove();
//jThis.children('.tdInfo').remove();
jTdInfo_wrap.hide();
g_submoduleID = null;
g_studentID = null;
......@@ -385,74 +392,74 @@ $(function () {
// Здесь jThis - div rateCell, а не input, который является дочкой
if (cancelFlag) {
var str = ""
var str = '';
if (oldRate != -1)
str = oldRate;
jThis.children("input").val(str);
jThis.children('input').val(str);
cancelFlag = false;
return;
}
var newRate = -1; // если пустая строка в ячейке, значит ничего не поставлено
if (jThis.children("input").val() !== "")
newRate = parseInt(jThis.children("input").val());
if (jThis.children('input').val() !== '')
newRate = parseInt(jThis.children('input').val());
if (newRate == oldRate)
return;
// блокируем ячейку пока не обработаем коллбек
jThis.children("input").attr("disabled", true);
jThis.children('input').attr('disabled', true);
var rateResult = newRate;
var bonus = parseInt(jThis.siblings(".bonus").text());
var bonus = parseInt(jThis.siblings('.bonus').text());
// считаем баллы по строке
if (pageType === "exam") //(jThis.attr("class").indexOf("attemptCell") >= 0)
if (pageType === 'exam') //(jThis.attr('class').indexOf('attemptCell') >= 0)
{
// страница сессии
rateResult += parseInt(jThis.siblings(".semesterRateResultCell").text());
rateResult += parseInt(jThis.siblings('.semesterRateResultCell').text());
jThis.siblings(".additionalCell").each(function () {
if ($(this).children("input").val() !== "")
rateResult += +$(this).children("input").val();
jThis.siblings('.additionalCell').each(function () {
if ($(this).children('input').val() !== '')
rateResult += +$(this).children('input').val();
});
}
if (newRate <= g_submoduleMaxRate) {
$.ajax({
type: "POST",
url: URLdir + "handler/rating/setRate",
data: "studentID=" + g_studentID + "&submoduleID=" + g_submoduleID + "&rate=" + newRate,
type: 'POST',
url: URLdir + 'handler/rating/setRate',
data: 'studentID=' + g_studentID + '&submoduleID=' + g_submoduleID + '&rate=' + newRate,
complete: function (jqXHR, textStatus) {
switch (jqXHR.status) {
case 403:
EventInspector.error("Сессия истекла");
jThis.children("input").val(oldRate);
EventInspector.error('Сессия истекла');
jThis.children('input').val(oldRate);
window.location.replace(URLdir);
break;
case 200:
data = $.parseJSON(jqXHR.responseText);
if (data.success === true) {
var correctRate = (rateResult+bonus > 100) ? '100+' : rateResult+bonus;
jThis.siblings(".rateResultCell").text(correctRate);
var correctRate = (rateResult + bonus > 100) ? '100+' : rateResult + bonus;
jThis.siblings('.rateResultCell').text(correctRate);
// Открываем доступ к след. ячейке добора баллов
if (jThis.hasClass("additionalCell")) {
nextAdditionalCell = $("#col_" + (g_col + 1) + "_row_" + g_row);
if (jThis.hasClass('additionalCell')) {
nextAdditionalCell = $('#col_' + (g_col + 1) + '_row_' + g_row);
placeholderMaxVal = (rateResult < 60) ? (60 - rateResult) : 0;//(60 - oldRate);
if (nextAdditionalCell.hasClass("additionalCell")) {
var placeholderMax = (placeholderMaxVal > 0) ? placeholderMax = "макс. " + placeholderMaxVal : "---";
nextAdditionalCell.find("input").attr("placeholder", placeholderMax);
if (nextAdditionalCell.hasClass('additionalCell')) {
var placeholderMax = (placeholderMaxVal > 0) ? placeholderMax = 'макс. ' + placeholderMaxVal : '---';
nextAdditionalCell.find('input').attr('placeholder', placeholderMax);
}
}
EventInspector.success("Балл добавлен/изменен");
EventInspector.success('Балл добавлен/изменен');
}
else EventInspector.error("Не удалось добавить/изменить балл");
else EventInspector.error('Не удалось добавить/изменить балл');
break;
default:
EventInspector.error(" " + jqXHR.status);
EventInspector.error(' ' + jqXHR.status);
}
}
});
......@@ -460,16 +467,16 @@ $(function () {
else {
if (oldRate <= g_submoduleMaxRate) {
if (oldRate != -1)
jThis.children("input").val(oldRate);
jThis.children('input').val(oldRate);
else
jThis.children("input").val("");
jThis.children('input').val('');
}
else
jThis.children("input").val("0");
jThis.children('input').val('0');
EventInspector.error("Текущий балл превышает максимальный для данного модуля");
EventInspector.error('Текущий балл превышает максимальный для данного модуля');
}
jThis.children("input").removeAttr("disabled");
jThis.children('input').removeAttr('disabled');
}
jCommonCell.mouseenter(function () {
......@@ -488,8 +495,8 @@ $(function () {
TdFocus($(this));
TdInfo($(this));
if ($(this).children("input").val() !== "") {
oldRate = $(this).children("input").val();
if ($(this).children('input').val() !== '') {
oldRate = $(this).children('input').val();
}
else oldRate = -1;
});
......@@ -524,30 +531,30 @@ $(function () {
case Direction.Up:
do {
row--;
currentCell = $("tr#row_" + row + " td#col_" + g_col + ".commonCell")
currentCell = $('tr#row_' + row + ' td#col_' + g_col + '.commonCell')
} while ((currentCell.length > 0) &&
(currentCell.children("input").attr("disabled") == "disabled"));
(currentCell.children('input').attr('disabled') == 'disabled'));
return currentCell;
case Direction.Right:
do {
col++;
currentCell = $("tr#row_" + g_row + " td#col_" + col + ".commonCell")
currentCell = $('tr#row_' + g_row + ' td#col_' + col + '.commonCell')
} while ((currentCell.length > 0) &&
(currentCell.children("input").attr("disabled") == "disabled"));
(currentCell.children('input').attr('disabled') == 'disabled'));
return currentCell;
case Direction.Down:
do {
row++;
currentCell = $("tr#row_" + row + " td#col_" + g_col + ".commonCell")
currentCell = $('tr#row_' + row + ' td#col_' + g_col + '.commonCell')
} while ((currentCell.length > 0) &&
(currentCell.children("input").attr("disabled") == "disabled"));
(currentCell.children('input').attr('disabled') == 'disabled'));
return currentCell;
case Direction.Left:
do {
col--;
currentCell = $("tr#row_" + g_row + " td#col_" + col + ".commonCell")
currentCell = $('tr#row_' + g_row + ' td#col_' + col + '.commonCell')
} while ((currentCell.length > 0) &&
(currentCell.children("input").attr("disabled") == "disabled"));
(currentCell.children('input').attr('disabled') == 'disabled'));
return currentCell;
}
return null;
......@@ -581,27 +588,27 @@ $(function () {
TdUnFocus();
g_row = row;
g_col = col;
whereToMoveFocus.children("input").focus();
whereToMoveFocus.children('input').focus();
} else
$(this).children("input").blur();
$(this).children('input').blur();
});
$(".commonCell input").focusin(function () {
$('.commonCell input').focusin(function () {
$(this).select();
});
// При нажатии на элемент commonCell дочерный input получает фокус
jCommonCell.click(function () {
$(this).children("input").focus();
$(this).children('input').focus();
});
// В inputCredit (где баллы вводить) разрешаем вводить только цифры
jCommonCell.children("input").keydown(function (event) {
jCommonCell.children('input').keydown(function (event) {
KeyDownOnlyNumber(event);
});
// Нажатие на чекбокс "Неявка"
$(".absenceCheck").click(function (event) {
$('.absenceCheck').click(function (event) {
// prepare
var option = 'absence';
var checked = $(this)[0].checked;
......@@ -622,7 +629,7 @@ $(function () {
controlRowVisualization(thisTd.parent());
});
$(".autoPassCheck").click(function (event) {
$('.autoPassCheck').click(function (event) {
// prepare
var option = 'pass';
var checked = $(this)[0].checked;
......@@ -645,19 +652,20 @@ $(function () {
function setExamPeriodOption(jThis, option) {
jThis.attr("disabled", true);
jThis.attr('disabled', true);
var statusCode = 0;
$.ajax({
type: "POST",
url: URLdir + "handler/rating/SetExamPeriodOption",
data: "studentID=" + g_studentID + "&submoduleID=" + g_submoduleID +
"&option=" + optionsViewData[option].sendingOption,
type: 'POST',
url: URLdir + 'handler/rating/SetExamPeriodOption',
data: 'studentID=' + g_studentID + '&submoduleID=' + g_submoduleID +
'&option=' + optionsViewData[option].sendingOption,
complete: function (jqXHR, textStatus) {
statusCode = jqXHR.status;
switch (jqXHR.status) {
case 403:
EventInspector.error("Сессия истекла");
EventInspector.error('Сессия истекла');
window.location.replace(URLdir);
break;
case 200:
data = $.parseJSON(jqXHR.responseText);
if (data.success === true) {
......@@ -668,39 +676,34 @@ $(function () {
EventInspector.error(optionsViewData[option].messageFail);
break;
default:
EventInspector.error(" " + jqXHR.status);
EventInspector.error(' ' + jqXHR.status);
}
}
});
jThis.removeAttr("disabled");
jThis.removeAttr('disabled');
return statusCode;
}
// Фильтр по группе
$(".groupSelector").change(function () {
$('.groupSelector').change(function () {
var group = $(this).val();
if (group >= 0) {
filterGroups(group);
$.post(
URLdir + "handler/rating/SelectGroup",
{
"disciplineID": g_disciplineID,
"groupSelected": group
},
function (data) {
data = $.parseJSON(data);
if (data.success === true) {
if (!(group >= 0))
return;
}
}
);
}
filterGroups(group);
$.post(
URLdir + 'handler/rating/SelectGroup',
{
'disciplineID': g_disciplineID,
'groupSelected': group
}
);
});
// Скачать таблицу оценивания в формате excel // depricated
$(".downloadExcel").click(function () {
$('.downloadExcel').click(function () {
$.fileDownload(URLdir + 'handler/FileCreator/GenerateExcelRatingTable', {
httpMethod: "POST",
httpMethod: 'POST',
data: {
'disciplineID': g_disciplineID
},
......@@ -716,22 +719,18 @@ $(function () {
// Ведомость в формате excel
$('body').on('click', '.downloadExcelStatement', function () {
var groupID = parseInt($(this).attr("id").substr(6))
var jStageSelector = $("#stageSelector_" + groupID);
var groupID = parseInt($(this).attr('id').substr(6));
var jStageSelector = $('#stageSelector_' + groupID);
$.fileDownload(URLdir + 'handler/FileCreator/GenerateFinalForm', {
httpMethod: "POST",
httpMethod: 'POST',
data: {
"disciplineID": g_disciplineID,
"groupID": groupID,
"stage": parseInt(jStageSelector.val())
},
successCallback: function () {
'disciplineID': g_disciplineID,
'groupID': groupID,
'stage': parseInt(jStageSelector.val())
},
failCallback: function () {
}
successCallback: function () {},
failCallback: 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