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

fix: rating page unexpected end of input.

parent 8848a23a
Branches
Tags
No related merge requests found
......@@ -157,7 +157,7 @@
</div>
</div>
<div id="hidden_div">
{{ discipline_JSON|raw }}
{{ Discipline_JSON|raw }}
</div>
<input type="hidden" id="pageType" value="rating"/>
{% endblock %}
......@@ -2,6 +2,8 @@ var $ = jQuery;
$(function() {
// inititializations
var pageType = $("#pageType").val();
var optionsViewData = {
'absence': {
sendingOption : 'absence',
......@@ -42,65 +44,71 @@ $(function() {
}
function controlRowVisualization(jRow) {
if ($("#pageType").val() === "exam") {
var jAutoPassCheckBox = jRow.children(".autoPass").children(".autoPassCheck");
var jAbsenceCheckBoxes = jRow.children(".absenceCell").children(".absenceCheck");
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);
else
jAutoPassCheckBox.removeAttr("disabled");
// суммарный добор
var extra = 0;
jExtraInputs.each(function() {
extra += $(this).val();
});
if (pageType !== "exam") {
return;
}
var jAutoPassCheckBox = jRow.children(".autoPass").children(".autoPassCheck");
var jAbsenceCheckBoxes = jRow.children(".absenceCell").children(".absenceCheck");
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);
} else {
jAutoPassCheckBox.removeAttr("disabled");
}
// суммарный добор
var extra = 0;
jExtraInputs.each(function() {
extra += $(this).val();
});
// чекбоксы влияют на соседей
var row = parseInt(jRow.attr('id').substr(4)); // одинаковая для всех
var otherDisabled = false;
var firstInARow = true;
jAbsenceCheckBoxes.each(function() {
var id = $(this).parent().attr('id');
var col = parseInt(id.substr(8));
var neighborExam = $("#col_"+col+"_row_"+row);
$(this).removeAttr("disabled");
if (autopass) // автомат
$(this).attr("disabled", true);
else if (firstInARow && (semesterRate < 38)) // задолженник
$(this).attr("disabled", true);
else if (semesterRate + extra < 38) // задолженник до сих пор
$(this).attr("disabled", true);
if (($(this)[0].checked) || autopass || otherDisabled) // автомат, неявка или сдал до этого
// чекбоксы влияют на соседей
var row = parseInt(jRow.attr('id').substr(4)); // одинаковая для всех
var otherDisabled = false;
var firstInARow = true;
jAbsenceCheckBoxes.each(function() {
var id = $(this).parent().attr('id');
var col = parseInt(id.substr(8));
var neighborExam = $("#col_"+col+"_row_"+row);
$(this).removeAttr("disabled");
if (autopass || // автомат
( firstInARow && (semesterRate < 38) ) || // задолженник
( semesterRate + extra < 38 )) // задолженник до сих пор
{
$(this).attr("disabled", true);
}
if (($(this)[0].checked) || autopass || otherDisabled) { // автомат, неявка или сдал до этого
neighborExam.children().attr("disabled", true);
} else {
if (firstInARow && (semesterRate < 38)) { // задолженник
neighborExam.children().attr("disabled", true);
else {
if (firstInARow && (semesterRate < 38)) // задолженник
neighborExam.children().attr("disabled", true);
else if (semesterRate + extra < 38) // задолженник до сих пор
neighborExam.children().attr("disabled", true);
else {
neighborExam.children().removeAttr("disabled");
if (neighborExam.children().val() == "")
otherDisabled = true;
} else if (semesterRate + extra < 38) { // задолженник до сих пор
neighborExam.children().attr("disabled", true);
} else {
neighborExam.children().removeAttr("disabled");
if (neighborExam.children().val() === "") {
otherDisabled = true;
}
}
}
firstInARow = false;
});
}
firstInARow = false;
});
}
function controlVisualization() {
$(".studentsRate").children().children("tr")
.each(function () {
if (($(this).prop("id") != "") && ($(this).attr("id").substr(0, 3) == "row"))
controlRowVisualization($(this));
if (($(this).prop("id") !== "") && ($(this).attr("id").substr(0, 3) === "row")) {
controlRowVisualization($(this));
}
});
}
......@@ -271,7 +279,7 @@ $(function() {
var rateResult = newRate;
// считаем баллы по строке
if ($("#pageType").val() === "exam") //(jThis.attr("class").indexOf("attemptCell") >= 0)
if (pageType === "exam") //(jThis.attr("class").indexOf("attemptCell") >= 0)
{
// страница сессии
rateResult += parseInt(jThis.siblings(".semesterRateResultCell").text());
......@@ -282,7 +290,7 @@ $(function() {
rateResult += parseInt($(this).children("input").val());
});
}
else if ($("#pageType").val() === "rating") {
else if (pageType === "rating") {
// страница оценивания
jThis.siblings(".commonCell").each(function () { // добавим сумму баллов в соседних ячейках
var rate = $(this).children("input").val();
......
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