diff --git a/.gitignore b/.gitignore index fce9dbb845b358e601b76dc08e17996aa376fc40..9ad54f92a6c4a7d608f1b67cd37d367e29aab38a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ nbproject/ /.project /.idea ~dev_rating/.idea/ -/~dev_rating/modules/unittest/vendor/ \ No newline at end of file +/~dev_rating/modules/unittest/vendor/ +db/disciplines activity.sql diff --git a/db/StoredFunctions.sql b/db/StoredFunctions.sql index 6e0460a6642675bb6504a0629ccd4e058efc5ccd..124e2242778807d24085363831bdf57ae33b4d1c 100644 --- a/db/StoredFunctions.sql +++ b/db/StoredFunctions.sql @@ -115,8 +115,8 @@ BEGIN END // -DROP FUNCTION IF EXISTS SetSessionOption// -CREATE FUNCTION `SetSessionOption` +DROP FUNCTION IF EXISTS SetExamPeriodOption// +CREATE FUNCTION `SetExamPeriodOption` ( `pStudentID` INT, `pSubmoduleID` INT, `pType` VARCHAR(30) CHARSET utf8 # enum('absence','pass') ) RETURNS int(11) @@ -124,10 +124,10 @@ CREATE FUNCTION `SetSessionOption` BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION RETURN -1; - INSERT INTO `session_options` + INSERT INTO `exam_period_options` (StudentID, SubmoduleID, Type) VALUES(pStudentID, pSubmoduleID, pType) ON DUPLICATE KEY UPDATE - session_options.Type = pType; + exam_period_options.Type = pType; RETURN 0; END // diff --git a/db/StoredProcedures.sql b/db/StoredProcedures.sql index 90b19257eba5f5b8706fc4d244fa832dbd1298dc..8cb8b35323fc48fe11181a4c1471c2daec662dbd 100644 --- a/db/StoredProcedures.sql +++ b/db/StoredProcedures.sql @@ -754,21 +754,24 @@ END // DROP PROCEDURE IF EXISTS GetRatesForGroupByStage// CREATE PROCEDURE `GetRatesForGroupByStage` - ( IN `pDisciplineID` INT, IN `pGroupID` INT, IN `pMilestone` INT) - NO SQL + ( IN `pDisciplineID` INT, IN `pGroupID` INT, IN `pMilestone` INT) +NO SQL BEGIN SELECT view_disciplines_students.StudentID, - view_disciplines_students.LastName As LastName, - view_disciplines_students.FirstName As FirstName, - view_disciplines_students.SecondName As SecondName, - SUM(rating_table.Rate*(view_roadmap.ModuleType = 'regular')) AS 'regular', - SUM(rating_table.Rate*(view_roadmap.ModuleType = 'bonus')) AS 'bonus', - SUM(rating_table.Rate*(view_roadmap.ModuleType = 'extra')) AS 'extra', - SUM(rating_table.Rate*(view_roadmap.ModuleType = 'exam')) AS 'exam' + view_disciplines_students.LastName As LastName, + view_disciplines_students.FirstName As FirstName, + view_disciplines_students.SecondName As SecondName, + SUM(rating_table.Rate*(view_roadmap.ModuleType = 'regular')) AS 'regular', + SUM(rating_table.Rate*(view_roadmap.ModuleType = 'bonus')) AS 'bonus', + SUM(rating_table.Rate*(view_roadmap.ModuleType = 'extra')) AS 'extra', + SUM(rating_table.Rate*(view_roadmap.ModuleType = 'exam')) AS 'exam', + COALESCE(exam_period_options.Type) As 'option' FROM `view_disciplines_students` - LEFT JOIN `view_roadmap` ON view_roadmap.DisciplineID = pDisciplineID - LEFT JOIN `rating_table` ON rating_table.StudentID = view_disciplines_students.StudentID AND - rating_table.SubmoduleID = view_roadmap.SubmoduleID + LEFT JOIN `view_roadmap` ON view_roadmap.DisciplineID = view_disciplines_students.DisciplineID + LEFT JOIN `rating_table` ON rating_table.StudentID = view_disciplines_students.StudentID AND + rating_table.SubmoduleID = view_roadmap.SubmoduleID + LEFT JOIN `exam_period_options` ON exam_period_options.submoduleID = view_roadmap.SubmoduleID AND + exam_period_options.StudentID = view_disciplines_students.StudentID WHERE view_disciplines_students.DisciplineID = pDisciplineID AND view_disciplines_students.GroupID = pGroupID AND NOT view_disciplines_students.AttachType <=> 'detach' AND @@ -798,12 +801,12 @@ BEGIN view_roadmap.ModuleType, rating_table.Rate, rating_table.Date, - session_options.Type + exam_period_options.Type As ExamPeriodOption FROM `view_roadmap` LEFT JOIN `rating_table` ON view_roadmap.SubmoduleID = rating_table.SubmoduleID AND rating_table.StudentID = pStudentID - LEFT JOIN `session_options` ON session_options.StudentID = pStudentID AND - session_options.SubmoduleID = rating_table.SubmoduleID + LEFT JOIN `exam_period_options` ON exam_period_options.StudentID = pStudentID AND + exam_period_options.SubmoduleID = rating_table.SubmoduleID WHERE view_roadmap.DisciplineID = pDisciplineID AND ( view_roadmap.ModuleType != 'exam' OR @@ -837,10 +840,13 @@ BEGIN view_roadmap.SubmoduleType, rating_table.Rate, rating_table.Date, - view_roadmap.ModuleType + view_roadmap.ModuleType, + exam_period_options.Type As ExamPeriodOption FROM `view_roadmap` LEFT JOIN `rating_table` ON rating_table.SubmoduleID = view_roadmap.SubmoduleID AND rating_table.StudentID = pStudentID + LEFT JOIN `exam_period_options` ON exam_period_options.StudentID = pStudentID AND + exam_period_options.SubmoduleID = view_roadmap.SubmoduleID WHERE view_roadmap.DisciplineID = pDisciplineID ORDER BY view_roadmap.ModuleOrderNum ASC, view_roadmap.SubmoduleOrderNum ASC; diff --git a/db/Structure.sql b/db/Structure.sql index e88e11cb9300dbe05c60cdd13d92332332acc50f..8096002abf240ff8890e014138c0296896b4dd74 100644 --- a/db/Structure.sql +++ b/db/Structure.sql @@ -539,14 +539,14 @@ CREATE TABLE IF NOT EXISTS `students_groups` ( -- -------------------------------------------------------- -- --- Структура таблицы `session_options` +-- Структура таблицы `exam_period_options` -- -CREATE TABLE IF NOT EXISTS `session_options` ( +CREATE TABLE IF NOT EXISTS `exam_period_options` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `SubmoduleID` int(11) NOT NULL, `StudentID` int(11) NOT NULL, - `Type` enum('absence','pass') NOT NULL, + `Type` enum('absence','pass'), PRIMARY KEY (`ID`), UNIQUE KEY `SubmoduleID` (`SubmoduleID`,`StudentID`), KEY `SubmoduleID_2` (`SubmoduleID`), @@ -757,11 +757,11 @@ ALTER TABLE `students_groups` -- --- Ограничения внешнего ключа таблицы `session_options` +-- Ограничения внешнего ключа таблицы `exam_period_options` -- -ALTER TABLE `session_options` - ADD CONSTRAINT `session_options_ibfk_2` FOREIGN KEY (`StudentID`) REFERENCES `students` (`ID`), - ADD CONSTRAINT `session_options_ibfk_1` FOREIGN KEY (`SubmoduleID`) REFERENCES `submodules` (`ID`); +ALTER TABLE `exam_period_options` + ADD CONSTRAINT `exam_period_options_ibfk_2` FOREIGN KEY (`StudentID`) REFERENCES `students` (`ID`), + ADD CONSTRAINT `exam_period_options_ibfk_1` FOREIGN KEY (`SubmoduleID`) REFERENCES `submodules` (`ID`); diff --git a/db/fix.sql b/db/fix.sql index aa21a5bcdce486e10855e1e0be8f48a545472b46..7d5326a77005ae825407830bc91e1c3b20a9fe66 100644 --- a/db/fix.sql +++ b/db/fix.sql @@ -1,25 +1,22 @@ -# 24.05.15 +# 03.06.15 -ALTER TABLE `disciplines` CHANGE `ExamType` `ExamType` ENUM( 'exam', 'credit', 'grading_credit' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; -ALTER TABLE `disciplines` ADD `Subtype` ENUM( 'scientific_coursework', 'disciplinary_coursework' ) NULL DEFAULT NULL ; -ALTER TABLE `disciplines` CHANGE `isMilestone` `Milestone` INT( 11 ) NOT NULL DEFAULT '0'; - - -CREATE TABLE IF NOT EXISTS `session_options` ( - `ID` int(11) NOT NULL AUTO_INCREMENT, - `SubmoduleID` int(11) NOT NULL, - `StudentID` int(11) NOT NULL, - `Type` enum('absence','pass') NOT NULL, - PRIMARY KEY (`ID`), - UNIQUE KEY `SubmoduleID` (`SubmoduleID`,`StudentID`), - KEY `SubmoduleID_2` (`SubmoduleID`), - KEY `StudentID` (`StudentID`), - KEY `StudentID_2` (`StudentID`), - KEY `StudentID_3` (`StudentID`) +DROP TABLE `session_options`; +CREATE TABLE IF NOT EXISTS `exam_period_options` ( + `ID` int(11) NOT NULL AUTO_INCREMENT, + `SubmoduleID` int(11) NOT NULL, + `StudentID` int(11) NOT NULL, + `Type` enum('absence','pass'), + PRIMARY KEY (`ID`), + UNIQUE KEY `SubmoduleID` (`SubmoduleID`,`StudentID`), + KEY `SubmoduleID_2` (`SubmoduleID`), + KEY `StudentID` (`StudentID`), + KEY `StudentID_2` (`StudentID`), + KEY `StudentID_3` (`StudentID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -ALTER TABLE `session_options` -ADD CONSTRAINT `session_options_ibfk_2` FOREIGN KEY (`StudentID`) REFERENCES `students` (`ID`), -ADD CONSTRAINT `session_options_ibfk_1` FOREIGN KEY (`SubmoduleID`) REFERENCES `submodules` (`ID`); + +ALTER TABLE `exam_period_options` +ADD CONSTRAINT `exam_period_options_ibfk_2` FOREIGN KEY (`StudentID`) REFERENCES `students` (`ID`), +ADD CONSTRAINT `exam_period_options_ibfk_1` FOREIGN KEY (`SubmoduleID`) REFERENCES `submodules` (`ID`); UPDATE `subjects` SET `Name`= "Курсовая работа", `Abbr` = "Курсовая" WHERE `ID` = 346; diff --git a/~dev_rating/application/classes/Controller/Handler/FileCreator.php b/~dev_rating/application/classes/Controller/Handler/FileCreator.php index fc5083c91a78a9d2f5a8fc1c7b9b9fa43a34e9af..c45e1843526ae330f6646cc9982eea716c9898ce 100644 --- a/~dev_rating/application/classes/Controller/Handler/FileCreator.php +++ b/~dev_rating/application/classes/Controller/Handler/FileCreator.php @@ -266,6 +266,7 @@ class Controller_Handler_FileCreator extends Controller_Handler $ratesSet['bonus'] = (int)$studentRates['bonus']; $ratesSet['extra'] = (int)$studentRates['extra']; $ratesSet['exam'] = (int)$studentRates['exam']; + $ratesSet['option'] = $studentRates['option']; list($totalRateStr, $stringRate, $examRateStr) = $this->formStringsForRates($ratesSet, $type, $examHold); @@ -632,7 +633,7 @@ class Controller_Handler_FileCreator extends Controller_Handler protected function checkExamIsHold(&$studentsRates) { foreach($studentsRates as $studentInfo){ - if ($studentInfo['exam'] >= 0) + if ($studentInfo['exam'] > 0) return 1; } return 0; @@ -643,7 +644,7 @@ class Controller_Handler_FileCreator extends Controller_Handler $total = $attestationAdmission + $ratesSet['bonus'] + $ratesSet['exam']; switch ($type) { case 'exam': - return $this->formRateOfFive($attestationAdmission, $ratesSet['exam'], $total, $examHold); + return $this->formRateOfFive($attestationAdmission, $ratesSet['exam'], $total, $examHold, $ratesSet['option']); case 'grading_credit': { // emulate exam to call formRateOfFive $ratesSet['exam'] = 22; @@ -680,8 +681,19 @@ class Controller_Handler_FileCreator extends Controller_Handler } // Определяет оценку по пятибальной системе для экзамена - protected function formRateOfFive($examAdmission, $examRateValue, $totalRateValue, $examHold) + protected function formRateOfFive($examAdmission, $examRateValue, $totalRateValue, $examHold, $option = null) { + // особые случаи: неявка и автомат + if ($option == 'absence') + return array('', 'н/я', ''); + if ($option == 'pass') { + if ($examAdmission == 60) + return array($totalRateValue, 'удовл', '0'); + else + return array('', 'автомат не допустим', ''); + } + + // стандартная ситуация с оцениванием if ($totalRateValue > 100) $totalRateValue = 100; $totalRateStr = ''; diff --git a/~dev_rating/application/classes/Controller/Handler/Rating.php b/~dev_rating/application/classes/Controller/Handler/Rating.php index a6ad8b57686e14f4af5b26fdbe8bd15795543617..70acfa03a1b7e25cd65462f9a54bd5ba0e47763e 100644 --- a/~dev_rating/application/classes/Controller/Handler/Rating.php +++ b/~dev_rating/application/classes/Controller/Handler/Rating.php @@ -14,16 +14,16 @@ class Controller_Handler_Rating extends Controller_Handler public function action_SetRate() { $data['success'] = false; - $this->post -> rule('student', 'not_empty') - -> rule('student', 'digit') - -> rule('submodule', 'not_empty') - -> rule('submodule', 'digit') + $this->post -> rule('studentID', 'not_empty') + -> rule('studentID', 'digit') + -> rule('submoduleID', 'not_empty') + -> rule('submoduleID', 'digit') -> rule('rate', 'digit') -> rule('rate', 'range', array(':value', 0, 100)); if($this->post->check()) { - $result = $this->model->SetStudentRate( $this->user['TeacherID'], - $this->post['student'], - $this->post['submodule'], + $result = Model_Rating::SetStudentRate( $this->user['TeacherID'], + $this->post['studentID'], + $this->post['submoduleID'], $this->post['rate']); $data['success'] = ($result[0]['Num'] == 0); } @@ -48,4 +48,30 @@ class Controller_Handler_Rating extends Controller_Handler $this->response->body(json_encode($data)); } + public function action_SetExamPeriodOption() { + $data['success'] = false; + $this->post -> rule('studentID', 'not_empty') + -> rule('studentID', 'digit') + -> rule('submoduleID', 'not_empty') + -> rule('submoduleID', 'digit'); + + if($this->post->check()) { + // option check + $parametersCheckPassed = true; + switch ($this->post['option']) { + case 'null' : + case 'absence': + case 'pass': + break; + default: + $parametersCheckPassed = false; + } + if ($parametersCheckPassed) { + $res = Model_Rating::setExamPeriodOption($this->post['studentID'], $this->post['submoduleID'], $this->post['option']); + if ($res['ErrorCode'] == 0) + $data['success'] = true; + } + } + $this->response->body(json_encode($data)); + } } \ No newline at end of file diff --git a/~dev_rating/application/classes/Controller/Teacher/Rating.php b/~dev_rating/application/classes/Controller/Teacher/Rating.php index c9e88d539c9cdd6ed98bc65d6954552771b58938..e8277dd16119a2327b0ac57455a73932eeed400a 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Rating.php +++ b/~dev_rating/application/classes/Controller/Teacher/Rating.php @@ -178,6 +178,7 @@ class Controller_Teacher_Rating extends Controller_UserEnvironment { $curStudent['Rates'][$rowIndex]['SubmoduleID'] = $curRate['SubmoduleID']; $curStudent['Rates'][$rowIndex]['Rate'] = $curRate['Rate']; $curStudent['Rates'][$rowIndex]['ModuleType'] = $curRate['ModuleType']; + $curStudent['Rates'][$rowIndex]['ExamPeriodOption'] = $curRate['ExamPeriodOption']; } switch ($curRate['ModuleType']) @@ -252,7 +253,7 @@ class Controller_Teacher_Rating extends Controller_UserEnvironment { $disciplineInfo['LocalizedExamType'] = DataHelper::LocalizeExamType($disciplineInfo['ExamType']); $structureHandled = $this->getStructure($disciplineId, $page_type); - // Студенты и их баллы + // Студенты $students = $this->model_rating->GetStudentsForRating($disciplineId); diff --git a/~dev_rating/application/classes/Model/Rating.php b/~dev_rating/application/classes/Model/Rating.php index 6467096fc529b5bfba515dadb3bb101f0940b2e1..e284cde8f1f285ff33ec3ec12d6521b600bc2e5e 100644 --- a/~dev_rating/application/classes/Model/Rating.php +++ b/~dev_rating/application/classes/Model/Rating.php @@ -59,11 +59,6 @@ class Model_Rating extends Model return DB::query(Database::SELECT, $sql)->execute(); } - public static function GetStudentRate($studentID, $disciplineID) { - $sql = "SELECT `GetRateForDisc`('$studentID', '$disciplineID') AS `Num`;"; - return DB::query(Database::SELECT, $sql)->execute(); - } - public static function getRatesForStudentsGroup($disciplineID, $groupID) { $sql = "CALL `GetRatesForGroup`('$disciplineID', '$groupID')"; return DB::query(Database::SELECT, $sql)->execute(); @@ -78,4 +73,10 @@ class Model_Rating extends Model $sql = "CALL `getFinalFormInfo`('$disciplineID', '$groupID')"; return DB::query(Database::SELECT, $sql)->execute(); } + + public static function setExamPeriodOption($studentID, $submoduleID, $option) { + // option is absence or pass or null + $sql = "SELECT `SetExamPeriodOption`('$studentID', '$submoduleID', '$option') As `ErrorCode`;"; + return DB::query(Database::SELECT, $sql)->execute()[0]; + } } diff --git a/~dev_rating/application/views/teacher/exam.twig b/~dev_rating/application/views/teacher/exam.twig index 586ba7a689ecaa7ac0b68a418c295691fdf7e3e3..48931738cc29787dbb8677452564c8d8d461be8f 100644 --- a/~dev_rating/application/views/teacher/exam.twig +++ b/~dev_rating/application/views/teacher/exam.twig @@ -165,12 +165,14 @@ {% if r.ModuleType == 'exam' %} <td class="absenceCell {{ td_class }}" id="absence_{{col}}_{{row}}"> - <input type="checkbox" class="absenceCheck"> + <input type="checkbox" class="absenceCheck" + {% if r.ExamPeriodOption == 'absence' %} checked="true" {% endif %}> </td> {% if autoPassNotAdded %} <td class="autoPass {{ td_class }}" id="autopass_{{col}}_{{row}}"> - <input type="checkbox" class="autoPassCheck"> + <input type="checkbox" class="autoPassCheck" + {% if r.ExamPeriodOption == 'pass' %} checked="true" {% endif %}> </td> {% set autoPassNotAdded = false %} {% endif %} diff --git a/~dev_rating/media/js/rating.js b/~dev_rating/media/js/rating.js index d8539aea6d68c82460daf59f5d05f9590195625c..fccf53c270b947b493e82a10bfb63b3b3334d3fe 100644 --- a/~dev_rating/media/js/rating.js +++ b/~dev_rating/media/js/rating.js @@ -1,48 +1,78 @@ var $ = jQuery; $(function() { + // inititializations + var optionsViewData = { + 'absence': { + sendingOption : 'absence', + messageOK : 'Неявка выставлена', + messageFail : 'Установка неявки не удалась' + }, + 'absence_unset': { + sendingOption : null, + messageOK : 'Неявка отменена', + messageFail : 'Отмена неявки не удалась' + }, + 'pass': { + sendingOption : 'pass', + messageOK : 'Автомат выставлен', + messageFail : 'Установка автомата не удалась' + }, + 'pass_unset': { + sendingOption : null, + messageOK : 'Автомат отменен', + messageFail : 'Отмена автомата не удалась' + } + }; function AdjustTable() { var jWrap = $('div.main_layer'); var jTable = $("div.main_content"); var tableWidth = jTable.get(0).scrollWidth; // check scroll bar - if (tableWidth <= jTable.width()+10) { + if (tableWidth <= jTable.width() + 10) { return; } //correct tableWidth *= 1.1; var maxWidth = $(window).width() * 0.95; - var newWidth = (tableWidth > maxWidth)?maxWidth:tableWidth; + var newWidth = (tableWidth > maxWidth) ? maxWidth : tableWidth; jWrap.css("max-width", newWidth); } - $("div.main_content").ready(AdjustTable); - $(window).resize(AdjustTable); - function controlRowVisualization(jRow) { var jAutoPassCheckBox = jRow.children(".autoPass").children(".autoPassCheck"); + var jAbsenceCheckBoxes = jRow.children(".absenceCell").children(".absenceCheck"); var semesterRate = parseInt(jRow.children(".semesterRateResultCell").text()); - var absence = jRow.children(".absenceCell").children(".absenceCheck").is(":checked"); + var autopass = jAutoPassCheckBox[0].checked; + var absence = jAbsenceCheckBoxes[0].checked; if ((semesterRate < 60) || (absence)) jAutoPassCheckBox.attr("disabled", true); else jAutoPassCheckBox.removeAttr("disabled"); + + if ((semesterRate < 38) || (autopass)) + jAbsenceCheckBoxes.attr("disabled", true); + else + jAbsenceCheckBoxes.removeAttr("disabled"); + + // TODO: disable CommonCell connected with this exam if absence or autopass checked } function controlVisualization() { - $(".autoPassCheck") - .each( function() { - controlRowVisualization($(this).parent().parent()); + $(".row") + .each(function () { + controlRowVisualization($(this)); }); } - controlVisualization(); - // on page loaded - //controlVisualization(); + controlVisualization(); + $("div.main_content").ready(AdjustTable); + $(window).resize(AdjustTable); + var cancelFlag = false; var g_col; var g_row; var g_isFocusCell = false; // Стоит фокус на ячейки или нет @@ -64,7 +94,7 @@ $(function() { var json_settings = $.parseJSON($("#hidden_div").html()); $("#hidden_div").remove(); filterGroups(json_settings.GroupID_Filter); - $(".groupSelector [value='"+ json_settings.GroupID_Filter +"']").attr("selected", "selected"); + $(".groupSelector [value='" + json_settings.GroupID_Filter + "']").attr("selected", "selected"); // Скрываем все остальные группы // 0 - показать все @@ -72,13 +102,13 @@ $(function() { if (groupID == 0) { $(".studentsRate tbody") .children() - .each( function() { + .each(function () { $(this).show(); }); } else { $(".studentsRate tbody") .children(":gt(2)") - .each( function() { + .each(function () { if ($(this).hasClass("group_" + groupID)) $(this).show(); else @@ -88,24 +118,24 @@ $(function() { } // Ставим подстветку - function TdFocus(jThis){ + function TdFocus(jThis) { g_col = jThis.attr('id'); g_col = parseInt(g_col.substr(4)); 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(){ + $("td#col_" + g_col + ".commonCell").each(function () { $(this).children('input').css("background-color", "#f1f1f1"); }); - $("td#col_" + g_col + ".staticCell").each(function(){ + $("td#col_" + g_col + ".staticCell").each(function () { $(this).children('input').css("background-color", "#f1f1f1"); }); - $("tr#row_" + g_row + " .commonCell").each(function(){ + $("tr#row_" + g_row + " .commonCell").each(function () { $(this).children('input').css("background-color", "#f1f1f1"); }); - $("tr#row_" + g_row + " .staticCell").each(function(){ + $("tr#row_" + g_row + " .staticCell").each(function () { $(this).css("background-color", "#f1f1f1"); $(this).children('input').css("background-color", "#f1f1f1"); }); @@ -113,18 +143,18 @@ $(function() { } // Убираем подстветку - function TdUnFocus(){ - $("td#col_" + g_col + ".commonCell").each(function(){ + function TdUnFocus() { + $("td#col_" + g_col + ".commonCell").each(function () { $(this).children('input').css("background-color", "#fff"); }); - $("td#col_" + g_col + ".staticCell").each(function(){ + $("td#col_" + g_col + ".staticCell").each(function () { $(this).children('input').css("background-color", "#fff"); }); - $("tr#row_" + g_row + " .commonCell").each(function(){ + $("tr#row_" + g_row + " .commonCell").each(function () { $(this).children('input').css("background-color", "#fff"); }); - $("tr#row_" + g_row + " .staticCell").each(function(){ + $("tr#row_" + g_row + " .staticCell").each(function () { $(this).css("background-color", "#fff"); $(this).children('input').css("background-color", "#fff"); }); @@ -137,19 +167,18 @@ $(function() { 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_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) - { + if (jThis.attr("class").indexOf("additionalCell") >= 0) { var semesterRate = parseInt(jThis.siblings(".semesterRateResultCell").text()); if (semesterRate <= disciplinePassRate) g_submoduleMaxRate = disciplinePassRate - semesterRate; @@ -172,7 +201,7 @@ $(function() { // jThis.append("<div class='tdInfo'>"+g_submoduleTitle+"<br>"+g_stdName+"</div>"); } - function UnsetTdInfo(jThis){ + function UnsetTdInfo(jThis) { //jThis.children(".tdInfo").remove(); jTdInfo_wrap.hide(); g_submoduleID = null; @@ -182,15 +211,27 @@ $(function() { function Rating(jThis, oldRate) { oldRate = parseInt(oldRate); + // Здесь jThis - div rateCell, а не input, который является дочкой - jThis.children("input").attr("disabled", true); + if (cancelFlag) { + var str = "" + if (oldRate != -1) + str = oldRate; + jThis.children("input").val(str); + cancelFlag = false; + return; + } var newRate = 0; if (jThis.children("input").val() !== "") newRate = parseInt(jThis.children("input").val()); + if (newRate == oldRate) return; + // lock input until we handle callback + jThis.children("input").attr("disabled", true); + var rateResult = newRate; // считаем баллы по строке @@ -199,15 +240,14 @@ $(function() { // страница сессии rateResult += parseInt(jThis.siblings(".semesterRateResultCell").text()); - jThis.siblings(".additionalCell").each(function(){ + jThis.siblings(".additionalCell").each(function () { if ($(this).children("input").val() !== "") rateResult += parseInt($(this).children("input").val()); }); } - else if ($("#pageType").val() === "rating") - { + else if ($("#pageType").val() === "rating") { // страница оценивания - jThis.siblings(".commonCell").each(function(){ // добавим сумму баллов в соседних ячейках + jThis.siblings(".commonCell").each(function () { // добавим сумму баллов в соседних ячейках var rate = $(this).children("input").val(); if (rate) rateResult += parseInt(rate); @@ -220,73 +260,49 @@ $(function() { rateResult += parseInt(additionalRateStr); } - - if (newRate <= g_submoduleMaxRate) - { + if (newRate <= g_submoduleMaxRate) { $.ajax({ type: "POST", url: URLdir + "handler/rating/setRate", - data: "student="+g_studentID+"&submodule="+g_submoduleID+"&rate="+newRate, - complete: function(jqXHR, textStatus) { - switch(jqXHR.status) { - case 403: - EventInspector_ShowMsg("Сессия истекла", "error"); - jThis.children("input").val(oldRate); - jThis.children("input").removeAttr("disabled"); - window.location.replace(URLdir); - break; - case 200: - data = $.parseJSON(jqXHR.responseText); - if(data.success === true) { - var correctRate = (rateResult > 100) ? '100+' : rateResult; - jThis.siblings(".rateResultCell").text(correctRate); - - // Открываем доступ к след. ячейке добора баллов - if (jThis.hasClass("additionalCell")) { - nextAdditionalCell = $("#col_" + (g_col + 1) + "_row_" + g_row); - placeholder_max = (rateResult <= 60) ? (60 - rateResult) : (60 - oldRate); - - if (placeholder_max > 0 && nextAdditionalCell.hasClass("additionalCell")) { - nextAdditionalCell.find("input").attr("placeholder", "макс. " + (placeholder_max)); - nextAdditionalCell.find("input").removeAttr("disabled"); + data: "studentID=" + g_studentID + "&submoduleID=" + g_submoduleID + "&rate=" + newRate, + complete: function (jqXHR, textStatus) { + switch (jqXHR.status) { + case 403: + EventInspector_ShowMsg("Сессия истекла", "error"); + jThis.children("input").val(oldRate); + + window.location.replace(URLdir); + break; + case 200: + data = $.parseJSON(jqXHR.responseText); + if (data.success === true) { + var correctRate = (rateResult > 100) ? '100+' : rateResult; + jThis.siblings(".rateResultCell").text(correctRate); + + // Открываем доступ к след. ячейке добора баллов + if (jThis.hasClass("additionalCell")) { + nextAdditionalCell = $("#col_" + (g_col + 1) + "_row_" + g_row); + placeholder_max = (rateResult <= 60) ? (60 - rateResult) : (60 - oldRate); + + if (placeholder_max > 0 && nextAdditionalCell.hasClass("additionalCell")) { + nextAdditionalCell.find("input").attr("placeholder", "макс. " + (placeholder_max)); + } } - } - - EventInspector_ShowMsg("Балл добавлен/изменен", "success"); - } - else EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error"); - jThis.children("input").removeAttr("disabled"); - break; - default: - EventInspector_ShowMsg(" "+statusCode, "success"); - } + EventInspector_ShowMsg("Балл добавлен/изменен", "success"); + } + else EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error"); + break; + default: + EventInspector_ShowMsg(" " + jqXHR.status, "error"); } - //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) - { - if(oldRate != -1) + if (oldRate <= g_submoduleMaxRate) { + if (oldRate != -1) jThis.children("input").val(oldRate); else jThis.children("input").val(""); @@ -295,37 +311,36 @@ $(function() { jThis.children("input").val("0"); EventInspector_ShowMsg("Текущий балл превышает максимальный для данного модуля", "error"); - jThis.children("input").removeAttr("disabled"); } + jThis.children("input").removeAttr("disabled"); } - $(".commonCell").mouseenter(function(){ + $(".commonCell").mouseenter(function () { if (g_isFocusCell === false) TdFocus($(this)); }); - $(".commonCell").mouseleave(function(){ + $(".commonCell").mouseleave(function () { if (g_isFocusCell === false) TdUnFocus(); }); var oldRate = 0; - $(".commonCell").focusin(function(){ + $(".commonCell").focusin(function () { g_isFocusCell = true; TdFocus($(this)); TdInfo($(this)); - if ($(this).children("input").val() !== "") - { + if ($(this).children("input").val() !== "") { oldRate = $(this).children("input").val(); } else oldRate = -1; }); - $(".commonCell").focusout(function(){ + $(".commonCell").focusout(function () { g_isFocusCell = false; Rating($(this), oldRate); - + TdUnFocus(); UnsetTdInfo($(this)); controlRowVisualization($(this).parent()); @@ -381,12 +396,15 @@ $(function() { return null; } - $(".commonCell").keydown(function(e){ + $(".commonCell").keydown(function (e) { var row = g_row; var col = g_col; var direction; switch (e.keyCode) { + case 27: + cancelFlag = true; // esc case 13: // enter + case 40: // down arrow direction = Direction.Down; break; case 38: // up arrow @@ -395,9 +413,6 @@ $(function() { case 39: // right arrow direction = Direction.Right; break; - case 40: // down arrow - direction = Direction.Down; - break; case 37: // left arrow direction = Direction.Left; break; @@ -414,25 +429,96 @@ $(function() { $(this).children("input").blur(); }); - $(".commonCell input").focusin(function(){ + $(".commonCell input").focusin(function () { $(this).select(); }); // При нажатии на элемент commonCell дочерный input получает фокус - $(".commonCell ").click(function(){ + $(".commonCell ").click(function () { $(this).children("input").focus(); - } ); + }); // В inputCredit (где баллы вводить) разрешаем вводить только цифры - $(".commonCell").children("input").keydown(function(event) { + $(".commonCell").children("input").keydown(function (event) { KeyDownOnlyNumber(event); }); // Нажатие на чекбокс "Неявка" - $(".absenceCheck").click(function(event) { - controlRowVisualization($(this).parent().parent()); + $(".absenceCheck").click(function (event) { + // prepare + var option = 'absence'; + var checked = $(this)[0].checked; + if (!checked) + option += '_unset'; + var thisTd = $(this).parent(); + g_col = thisTd.attr('id').substr(8,1); // absence_C + g_row = thisTd.attr('id').substr(10,1); // absence_C_R + + // call + TdInfo(thisTd); + var errCode = setExamPeriodOption($(this), option); + UnsetTdInfo(thisTd); + + // test + if (errCode > 0) + $(this).prop('checked', !checked); // invert check; + controlRowVisualization(thisTd.parent()); + }); + + $(".autoPassCheck").click(function (event) { + // prepare + var option = 'pass'; + var checked = $(this)[0].checked; + if (!checked) + option += '_unset'; + var thisTd = $(this).parent(); + g_col = thisTd.attr('id').substr(9,1); // autopass_C + g_row = thisTd.attr('id').substr(11,1); // autopass_C_R + + // call + TdInfo(thisTd); + var errCode = setExamPeriodOption($(this), option); + UnsetTdInfo(thisTd); + + // test + if (errCode > 0) + $(this).prop('checked', !checked); // invert check; + controlRowVisualization(thisTd.parent()); }); + + function setExamPeriodOption(jThis, option) { + 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, + complete: function (jqXHR, textStatus) { + statusCode = jqXHR.status; + switch (jqXHR.status) { + case 403: + EventInspector_ShowMsg("Сессия истекла", "error"); + window.location.replace(URLdir); + case 200: + data = $.parseJSON(jqXHR.responseText); + if (data.success === true) { + EventInspector_ShowMsg(optionsViewData[option].messageOK, "success"); + statusCode = 0; + } + else + EventInspector_ShowMsg(optionsViewData[option].messageFail, "error"); + break; + default: + EventInspector_ShowMsg(" " + jqXHR.status, "error"); + } + } + }); + jThis.removeAttr("disabled"); + return statusCode; + } + // Фильтр по группе $(".groupSelector").change(function() { var group = $(this).val(); @@ -492,5 +578,3 @@ $(function() { }); - -