From bee418ce334a3cb7c995772aacfe3471ca681830 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A8=D0=B0=D0=BB=D0=B8?=
 =?UTF-8?q?=D0=BC=D0=BE=D0=B2?= <solidovic@gmail.com>
Date: Thu, 27 Nov 2014 16:55:09 +0300
Subject: [PATCH] =?UTF-8?q?=D1=8D=D1=84=D1=84=D0=B5=D0=BA=D1=82=20=D0=BF?=
 =?UTF-8?q?=D0=B0=D0=BC=D1=8F=D1=82=D0=B8.=20=D0=B5=D1=89=D0=B5=20=D0=BD?=
 =?UTF-8?q?=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../classes/Controller/Handler/Rating.php     | 17 ++++++
 .../classes/Controller/Teacher/Rating.php     | 17 ++++++
 .../application/views/teacher/rating.twig     |  3 +
 ~dev_rating/media/js/rating.js                | 55 ++++++++++++-------
 4 files changed, 73 insertions(+), 19 deletions(-)

diff --git a/~dev_rating/application/classes/Controller/Handler/Rating.php b/~dev_rating/application/classes/Controller/Handler/Rating.php
index cfa3d9842..b5cbb6bfb 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 b389f4dcf..ea228858b 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 0fdafa168..c3eb7b6fd 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 6c8621cd0..613305b7f 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) {
+
+                    }
+                }
+            );
+        }
     });
 
 
-- 
GitLab