From baa5911c23cdf85f3f5714ed94d1a5f1465de519 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: Sun, 21 Dec 2014 21:03:06 +0300
Subject: [PATCH] unique id.

---
 .../classes/Controller/Teacher/Rating.php     |  2 +-
 .../application/views/teacher/exam.twig       | 32 ++++----
 .../application/views/teacher/rating.twig     | 21 +++--
 ~dev_rating/media/css/rating.css              | 36 +++++----
 ~dev_rating/media/js/rating.js                | 76 ++++++++++---------
 5 files changed, 91 insertions(+), 76 deletions(-)

diff --git a/~dev_rating/application/classes/Controller/Teacher/Rating.php b/~dev_rating/application/classes/Controller/Teacher/Rating.php
index 080c81302..4d56a5d16 100644
--- a/~dev_rating/application/classes/Controller/Teacher/Rating.php
+++ b/~dev_rating/application/classes/Controller/Teacher/Rating.php
@@ -285,7 +285,7 @@ class Controller_Teacher_Rating extends Controller_UserEnvi {
         }
 
         //echo Debug::vars($structureHandled);
-//    echo Debug::vars($rateHandled);	
+        //echo Debug::vars($rateHandled);	
         $twig->rateTable = $rateHandled;
         $twig->groups = $groupsHandled;
 
diff --git a/~dev_rating/application/views/teacher/exam.twig b/~dev_rating/application/views/teacher/exam.twig
index 0191e3b83..a895fedfd 100644
--- a/~dev_rating/application/views/teacher/exam.twig
+++ b/~dev_rating/application/views/teacher/exam.twig
@@ -81,39 +81,39 @@
 		</tr>
 		{% set row = 0 %}
 		{% for group in rateTable %}
-			<tr class="group {{ group.GroupID }}">
-				<td colspan="{{ CellCount + 3 }}">
+			<tr id="group_{{ group.GroupID }}" class="group_{{ group.GroupID }}">
+				<td class="group" colspan="{{ CellCount + 3 }}">
 					{% if group.isAttached == 1 %} {{ group.GradeTitle }} {% endif %}{{ group.GroupNum }} РіСЂСѓРїРїР°.
-					<span class="downloadExcelStatement" id="{{ group.GroupID }}">Скачать ведомость</span>
+					<span class="downloadExcelStatement" id="group_{{ group.GroupID }}">Скачать ведомость</span>
 				</td>
 			</tr>
-{#
+
 			{% for student in group.Students %}
 				{% set row = row + 1 %}
-				{% set j = 0 %}
-				<tr id="{{ row }}" class="{{ group.GroupID }}">
-					<td class="student staticCell" id="{{ student.ID }}">{{ student.Last }} {{ student.First }}</td>
-					<td class="row_{{ row }} col_{{ i + 1 }} staticCell RateSemesterResult">{{ student.RateSemesterResult }}</td>
+				{% set col = 0 %}
+				<tr id="row_{{ row }}" class="group_{{ group.GroupID }}">
+					<td id="student_{{ student.ID }}" class="studentCell staticCell">{{ student.Last }} {{ student.First }}</td>
+					<td class="semesterRateResultCell staticCell">{{ student.RateSemesterResult }}</td>
 					
 					{% for r in student.Rates %}
-						{% set j = j + 1 %}
+						{% set col = col + 1 %}
 						
 						{% if r.Block == 'True' %}
-							<td id="{{ j }}" class="notChange {% if r.ModuleType == 'exam' %}tryExamCell{% endif %}">
-							
-								<p>{{ r.Rate  }}</p>
+							<td id="col_{{ col }}" class="staticCell {% if r.ModuleType == 'exam' %}attemptCell{% endif %}">
+								{# <input type="text" value="{{ r.Rate  }}" disabled="disabled"> #}
+								{{ r.Rate  }}
 							</td>
 						{% else %}
-							<td id="{{ j }}" class="rateCell {% if r.ModuleType == 'exam' %}tryExamCell{% endif %}">
-							
+							<td id="col_{{ col }}" class="commonCell {% if r.ModuleType == 'exam' %}attemptCell{% endif %}">
 								<input type="text" value="{{ r.Rate  }}">
 							</td>
 						{% endif %}
 					{% endfor %}
-					<td class="row_{{ row }} col_{{ i + 1 }} staticCell RateResult">{{ student.RateResult }}</td>
+
+					<td class="rateResultCell staticCell">{{ student.RateResult }}</td>
 				</tr>
 			{% endfor %}
-#}
+
 		{% endfor %}
 	</table>
 	<div id="tdInfo_wrap">
diff --git a/~dev_rating/application/views/teacher/rating.twig b/~dev_rating/application/views/teacher/rating.twig
index de8630327..8c537bb9b 100644
--- a/~dev_rating/application/views/teacher/rating.twig
+++ b/~dev_rating/application/views/teacher/rating.twig
@@ -33,7 +33,7 @@
 	
 	<table class="studentsRate" border="0" cellspacing="0" cellpadding="0">
 		<tr class="RatingTableModulesHead">
-			<td class="title" width="150px">Модуль</td>
+			<td class="title">Модуль</td>
 			{% for i in 1..headerRate.ModulesCount %}
 				<td class="subject {% if headerRate[i].ModuleType == 'bonus' %} bonus{% endif %}" colspan="{{headerRate[i].SubmodulesCount}}" {% if headerRate[i].ModuleType != 'regular' %} rowspan="2" {% endif %}>
 					{{ headerRate[i].ModuleTitle }}
@@ -41,6 +41,7 @@
 			{% endfor %}
 			<td class="subject" rowspan="3">Итог</td>
 		</tr>
+
 		<tr class="RatingTableSubmodulesHead">
 			{% set CellCount = 0 %}
 			{% set col = 0 %}
@@ -55,6 +56,7 @@
 				{% endif %}
 			{% endfor %}
 		</tr>
+
 		<tr class="RatingTableSubmodulesHeadMaxRate">
 			{% set CellCount = 0 %}
 			{% set col = 0 %}
@@ -73,32 +75,35 @@
 				{% endfor %}
 			{% endfor %}
 		</tr>
+
 		{% set row = 0 %}
 		{% for group in rateTable %}
-			<tr class="group {{ group.GroupID }}">
-				<td colspan="{{ CellCount + 2 }}">{% if group.isAttached == 1 %} {{ group.GradeTitle }} {% endif %}{{ group.GroupNum }} РіСЂСѓРїРїР°</td>
+			<tr id="group_{{ group.GroupID }}" class="group_{{ group.GroupID }}">
+				<td class="group" colspan="{{ CellCount + 2 }}">{% if group.isAttached == 1 %} {{ group.GradeTitle }} {% endif %}{{ group.GroupNum }} РіСЂСѓРїРїР°</td>
 			</tr>
+
 			{% for student in group.Students %}
 				{% set row = row + 1 %}
 				{% set j = 0 %}
-				<tr id="{{ row }}" class="{{ group.GroupID }}">
-					<td class="student staticCell" id="{{ student.ID }}">{{ student.Last }} {{ student.First }}</td>
+				<tr id="row_{{ row }}" class="group_{{ group.GroupID }}">
+					<td id="student_{{ student.ID }}" class="studentCell staticCell">{{ student.Last }} {{ student.First }}</td>
 					{% for i in 1..CellCount %}
 						{% set j = j + 1 %}
 						{% if student.Rates[i].SubmoduleID >= 0 %}
-							<td id="{{ j }}" class="rateCell">
+							<td id="col_{{ j }}" class="commonCell">
 								<input type="text" value="{{ student.Rates[i].Rate }}">
 							</td>
 						{% else %}
 							{% set j = j - 1 %}
-							<td class="rateCell staticCell notChange">
+							<td class="staticCell">
 								<p>{{ student.Rates[i].Rate }}</p>
 							</td>
 						{% endif %}
 					{% endfor %}
-					<td class="row_{{ row }} col_{{ i + 1 }} staticCell RateResult">{{ student.RateResult }}</td>
+					<td class="rateResultCell staticCell">{{ student.RateResult }}</td>
 				</tr>
 			{% endfor %}
+
 		{% endfor %}
 	</table>
 	<div id="tdInfo_wrap">
diff --git a/~dev_rating/media/css/rating.css b/~dev_rating/media/css/rating.css
index a4695a5f7..9fb4feddf 100644
--- a/~dev_rating/media/css/rating.css
+++ b/~dev_rating/media/css/rating.css
@@ -11,6 +11,7 @@
 
 .RatingTableModulesHead { background: #f0f7fd } 
 .RatingTableSubmodulesHead { background: #f0f7fd } /* ffffe0 */
+.RatingTableSubmodulesHeadMaxRate { background: #f0f7fd } 
 
 .title {
 	font-size: 15px;
@@ -24,15 +25,22 @@
 	text-align: center;
 	font-size: 15px;
 	color: #417B9D
-} 
-.student {
+}
+
+.staticCell {
+	text-align: center;
+	color: #888;
+}
+
+.studentCell {
+	min-width: 150px;
 	max-width: 180px;
 	padding: 0 5px;
 	text-align: left;
 	font-size: 13px;
 	color: #417B9D
 }
-.group td {
+td.group {
 	padding: 5px;
 	text-align: center;
 }
@@ -69,9 +77,6 @@
 	color: red;
 }
 
-.RateSemesterResult, .RateResult {
-	text-align: center;
-}
 table {
 	border-top: 1px solid #ccc;
 	border-right: 1px solid #ccc;
@@ -107,17 +112,20 @@ td input {
 	text-align: center;
 	cursor: pointer
 }
-td input:hover{
-	background: #f1f1f1;
-}
-td input:focus{
+	td input:hover{
+		background: #f1f1f1;
+	}
+	td input:focus{
+		background: #fff;
+		outline: none
+	}
+
+/*
+td input[disabled="disabled"] {
 	background: #fff;
-	outline: none
 }
+*/
 
-td.notChange {
-	color: #888;
-}
 
 div#tdInfo_wrap {
 	display: none;
diff --git a/~dev_rating/media/js/rating.js b/~dev_rating/media/js/rating.js
index 0df4da180..102b87a93 100644
--- a/~dev_rating/media/js/rating.js
+++ b/~dev_rating/media/js/rating.js
@@ -15,7 +15,7 @@ $(function() {
     var g_URL = (window.location.href).split("/");
     var g_disciplineID = g_URL[g_URL.length - 1];
 
-    // studyGroupID для фильтра
+    // studyGroupID для фильтра (Эффект памяти)
     var json_settings = $.parseJSON($("#hidden_div").html());
     $("#hidden_div").remove();
     filterGroups(json_settings.studyGroupID);
@@ -34,7 +34,7 @@ $(function() {
             $(".studentsRate tbody")
                 .children(":gt(2)")
                 .each( function() {
-                    if ($(this).hasClass(groupID))
+                    if ($(this).hasClass("group_" + groupID))
                         $(this).show();
                     else
                         $(this).hide();
@@ -44,32 +44,34 @@ $(function() {
 
     // Ставим подстветку
     function TdFocus(jThis){
-        g_col = parseInt(jThis.attr('id'));
-        g_row = parseInt(jThis.parent('tr').attr('id'));
+        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();
-        $(".RatingTableSubmodulesHeadMaxRate .col_" + g_col).css("background-color", "#f1f1f1");
-        $("td#" + g_col + ".rateCell").each(function(){
+        $("td#col_" + g_col + ".commonCell").each(function(){
             $(this).children('input').css("background-color", "#f1f1f1");
         });
-        $("tr#" + g_row + " .rateCell").each(function(){
+        $("tr#row_" + g_row + " .commonCell").each(function(){
             $(this).children('input').css("background-color", "#f1f1f1");
         });
-        $("tr#" + g_row + " .staticCell").each(function(){
+        $("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");
     }
     
     // Убираем подстветку
     function TdUnFocus(){
-        $(".RatingTableSubmodulesHeadMaxRate .col_" + g_col).css("background-color", "#fff");
-        $("td#" + g_col + ".rateCell").each(function(){
+        $("td#col_" + g_col + ".commonCell").each(function(){
             $(this).children('input').css("background-color", "#fff");
         });
-        $("tr#" + g_row + " .rateCell").each(function(){
+        $("tr#row_" + g_row + " .commonCell").each(function(){
             $(this).children('input').css("background-color", "#fff");
         });
-        $("tr#" + g_row + " .staticCell").each(function(){
+        $("tr#row_" + g_row + " .staticCell").each(function(){
             $(this).css("background-color", "#fff");
         });
     }
@@ -83,8 +85,10 @@ $(function() {
         g_submoduleMaxRate = parseInt($(".RatingTableSubmodulesHeadMaxRate #"+g_submoduleID).children("input").val());
 
         // Получаем студента
-        g_studentID = parseInt(jThis.siblings('.student').attr("id"));
-        g_stdName = jThis.siblings('.student').text();
+        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);
@@ -113,14 +117,12 @@ $(function() {
             newRate = parseInt(jThis.children("input").val());
         //var maxRate = parseInt($(".RatingTableSubmodulesHeadMaxRate #"+g_submoduleID).children("input").val());
 
-        var rateResult = parseInt(jThis.siblings(".RateResult").text()) - oldRate + newRate;
+        var rateResult = parseInt(jThis.siblings(".rateResultCell").text()) - oldRate + newRate;
 
-	//todo 
-	//jThis.parent().children(".tryExamCell").each(function(){
-	//    rateResult = rateResult - parseInt(jThis.children("input").val());
-	//});
-	//rateResult = rateResult + parseInt(jThis.parent().children(".tryExamCell").last().children("input").val());
-	//end todo
+		// exams
+		if (jThis.siblings(".semesterRateResultCell ").length > 0)
+			var rateResult = parseInt(jThis.siblings(".semesterRateResultCell").text()) + newRate;
+		//end exams
 
         if (rateResult > 100) {
             jThis.children("input").val(oldRate);
@@ -145,7 +147,7 @@ $(function() {
                        200: function(data) {
                             data = $.parseJSON(data);
                             if(data.success === true) {
-                                jThis.siblings(".RateResult").text(rateResult);
+                                jThis.siblings(".rateResultCell").text(rateResult);
                                 EventInspector_ShowMsg("Балл добавлен/изменен", "success");
                             }
                             else EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error");
@@ -166,18 +168,18 @@ $(function() {
         }
     }
     
-    $(".rateCell").mouseenter(function(){
+    $(".commonCell").mouseenter(function(){
         if (g_isFocusCell === false)
             TdFocus($(this));
     });
     
-    $(".rateCell").mouseleave(function(){
+    $(".commonCell").mouseleave(function(){
         if (g_isFocusCell === false)
             TdUnFocus();
     });
     
     var oldRate = 0;
-    $(".rateCell").focusin(function(){
+    $(".commonCell").focusin(function(){
         g_isFocusCell = true;
         TdFocus($(this));
         TdInfo($(this));
@@ -186,7 +188,7 @@ $(function() {
         else oldRate = 0;
     });
     
-    $(".rateCell").focusout(function(){
+    $(".commonCell").focusout(function(){
         g_isFocusCell = false;
         var newRate = 0;
         if ($(this).children("input").val() !== "")
@@ -197,7 +199,7 @@ $(function() {
         UnsetTdInfo($(this));
     });
     
-    $(".rateCell").keyup(function(e){
+    $(".commonCell").keyup(function(e){
         
         var jThis = $(this);
         var row = g_row;
@@ -224,7 +226,7 @@ $(function() {
             col = col - 1;
 
         if ((e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 ) {
-            var jTempObj = $("tr#" + row + " td#" + col + ".rateCell");
+            var jTempObj = $("tr#row_" + row + " td#col_" + col + ".commonCell");
             if (jTempObj.length > 0) {
                 TdUnFocus();
                 g_row = row;
@@ -234,17 +236,17 @@ $(function() {
         }
     });
     
-    $(".rateCell input").focusin(function(){
+    $(".commonCell input").focusin(function(){
         $(this).select();
     });
     
-    // При нажатие на элемент rateCell дочерный input получает фокус
-    $(".rateCell ").click(function(){
+    // При нажатие на элемент commonCell дочерный input получает фокус
+    $(".commonCell ").click(function(){
         $(this).children("input").focus();
     } );
     
     // В inputCredit (где баллы вводить) разрешаем вводить только цифры
-    $(".rateCell").children("input").keydown(function(event) {
+    $(".commonCell").children("input").keydown(function(event) {
         KeyDownOnlyNumber(event);
     });
 
@@ -252,15 +254,15 @@ $(function() {
 
     // Фильтр по группе
     $(".groupSelector").change(function() {
-        var val = parseInt($(this).val()); // StudyGroupID
-        if (val >= 0)
+        var group = $(this).val(); 
+        if (group >= 0)
         {
-            filterGroups(val);
+            filterGroups(group);
             $.post(
                 URLdir + "handler/rating/SelectGroup",
                 {   
                     "disciplineID": g_disciplineID,
-                    "groupSelected":  val 
+                    "groupSelected":  group 
                 },
                 function(data){
                     data = $.parseJSON(data);
@@ -298,7 +300,7 @@ $(function() {
             data: 
             {
                 "disciplineID": g_disciplineID,
-                "studyGroupID": $(this).attr("id")
+                "studyGroupID": parseInt($(this).attr("id").substr(6))
             },
             successCallback: function () {
 
-- 
GitLab