diff --git a/~dev_rating/application/classes/Controller/Handler/Rating.php b/~dev_rating/application/classes/Controller/Handler/Rating.php index cfa3d9842e97ffdb257026d21355c38462862232..b5cbb6bfb466988527be4f4203980e4dfcaa4316 100644 --- a/~dev_rating/application/classes/Controller/Handler/Rating.php +++ b/~dev_rating/application/classes/Controller/Handler/Rating.php @@ -27,4 +27,21 @@ class Controller_Handler_Rating extends Controller_Handler { $this->response->body(json_encode($data)); } + public function action_SelectGroup(){ + $data['success'] = false; + $this->post -> rule('disciplineID', 'digit') + -> rule('disciplineID', 'not_empty') + -> rule('groupSelected', 'digit') + -> rule('groupSelected', 'not_empty'); + if($this->post->check()) { + //$SGID = Cookie::get('SGID', null); + + $SG_ar[$this->post->offsetGet('disciplineID')] = $this->post->offsetGet('groupSelected'); + + Cookie::set('SGID', json_encode($SG_ar), '3600'); // Пока час + $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 b389f4dcf78f8620dd93fea697caebd1781bc7e0..ea228858b113618c3ba8f3f313f6085bb8fc2020 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Rating.php +++ b/~dev_rating/application/classes/Controller/Teacher/Rating.php @@ -2,6 +2,21 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { + private function GetSGID($id) + { + # $id = disciplineID + $SG_json = json_decode(Cookie::get('SGID', null)); + if ($SG_json !== null) + { + var_dump($SG_json, $id); + + + if (array_key_exists($id, $SG_json)) + return $SG_json[$id]; + else return 0; + } + } + public function action_edit() { $twig = Twig::factory('teacher/rating'); @@ -93,6 +108,8 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $twig->tableRate = $studentsHandled; $twig->groups = $groups; + $twig->studyGroupID = $this->GetSGID($id); + $this->response->body($twig); } } diff --git a/~dev_rating/application/views/teacher/rating.twig b/~dev_rating/application/views/teacher/rating.twig index 0fdafa168741be7c203cd8ce50f0249177185abd..c3eb7b6fd3fb906ad626b9aab80105a1cad656c8 100644 --- a/~dev_rating/application/views/teacher/rating.twig +++ b/~dev_rating/application/views/teacher/rating.twig @@ -84,4 +84,7 @@ <span id="maxRate">Максимальный балл: <b></b></span> </div> </div> + <div class="hidden_div"> + {{ studyGroupID }} + </div> {% endblock %} \ No newline at end of file diff --git a/~dev_rating/media/js/rating.js b/~dev_rating/media/js/rating.js index 6c8621cd08be8d54c4eb1d145fe1458abc4ff3b4..613305b7ff5fbc738fe60c4f5f9cb1560e0aa73d 100644 --- a/~dev_rating/media/js/rating.js +++ b/~dev_rating/media/js/rating.js @@ -1,7 +1,7 @@ var $ = jQuery; $(function() { - var g_col; - var g_row; + var g_col; + var g_row; var g_isFocusCell = false; // Стоит фокус или нет var g_oldRateCell = null; var g_submoduleID = null; @@ -12,6 +12,8 @@ $(function() { 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]; // Скрываем все остальные группы // 0 - показать все @@ -36,15 +38,15 @@ $(function() { // Ставим подстветку function TdFocus(jThis){ - g_col = parseInt(jThis.attr('id')); - g_row = parseInt(jThis.parent('tr').attr('id')); + g_col = parseInt(jThis.attr('id')); + g_row = parseInt(jThis.parent('tr').attr('id')); g_oldRateCell = jThis.children("input").val(); $(".RatingTableSubmodulesHeadMaxRate .col_" + g_col).css("background-color", "#f1f1f1"); $("td#" + g_col + ".rateCell").each(function(){ $(this).children('input').css("background-color", "#f1f1f1"); }); $("tr#" + g_row + " .rateCell").each(function(){ - $(this).children('input').css("background-color", "#f1f1f1"); + $(this).children('input').css("background-color", "#f1f1f1"); }); $("tr#" + g_row + " .student").css("background-color", "#f1f1f1"); $("tr#" + g_row + " .RateResult").css("background-color", "#f1f1f1"); @@ -53,12 +55,12 @@ $(function() { // Убираем подстветку function TdUnFocus(){ - $(".RatingTableSubmodulesHeadMaxRate .col_" + g_col).css("background-color", "#fff"); + $(".RatingTableSubmodulesHeadMaxRate .col_" + g_col).css("background-color", "#fff"); $("td#" + g_col + ".rateCell").each(function(){ - $(this).children('input').css("background-color", "#fff"); + $(this).children('input').css("background-color", "#fff"); }); $("tr#" + g_row + " .rateCell").each(function(){ - $(this).children('input').css("background-color", "#fff"); + $(this).children('input').css("background-color", "#fff"); }); $("tr#" + g_row + " .student").css("background-color", "#fff"); $("tr#" + g_row + " .RateResult").css("background-color", "#fff"); @@ -80,7 +82,7 @@ $(function() { 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){ @@ -189,14 +191,14 @@ $(function() { col = col - 1; 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(); - } - } + 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(){ @@ -215,11 +217,26 @@ $(function() { - + // Фильтр по группе $(".groupSelector").change(function() { - var val = parseInt($(this).val()); + var val = parseInt($(this).val()); // StudyGroupID if (val >= 0) + { filterGroups(val); + $.post( + URLdir + "handler/rating/SelectGroup", + { + "disciplineID": g_disciplineID, + "groupSelected": val + }, + function(data){ + data = $.parseJSON(data); + if(data.success === true) { + + } + } + ); + } });