Skip to content
Snippets Groups Projects
Commit e7408f36 authored by Антон Шалимов's avatar Антон Шалимов
Browse files

update rating

parent e2730346
Branches
Tags
No related merge requests found
......@@ -83,8 +83,6 @@ class Controller_Teacher_Rating extends Controller_UserEnvi {
}
$twig->tableRate = $studentsHandled;
echo debug::vars($studentsHandled);
$this->response->body($twig);
}
}
......@@ -55,11 +55,11 @@
<td class="group" colspan="{{ CellCount + 2 }}">{% if student.isAttached == 1 %} {{ student.GradeTitle }}, {% endif %}{{ student.GroupNum }} группа</td>
</tr>
{% endif %}
<tr>
<td class="row_{{ row }} student" id="{{ student.ID }}">{{ student.Last }} {{ student.First }}</td>
<tr id="{{ row }}">
<td class="student" id="{{ student.ID }}">{{ student.Last }} {{ student.First }}</td>
{% for i in 1..CellCount %}
{% set RateResult = RateResult + student[i].Rate %}
<td class="row_{{ row }} col_{{ i }} rateCell"><input type="text" value="{{ student[i].Rate }}"></td>
<td id="{{ i }}" class="rateCell"><input type="text" value="{{ student[i].Rate }}"></td>
{% endfor %}
<td class="row_{{ row }} col_{{ i + 1 }} RateResult">{{ RateResult }}</td>
</tr>
......
......@@ -41,13 +41,13 @@ td {
font-size: 13px;
color: #363636
}
td .tdInfo {
div.tdInfo {
margin-top: -80px;
margin-left: -150px;
padding: 5px 10px;
position: absolute;
background: #fff;
width: 200px;
height: 40px;
border: 1px solid #ccc;
line-height: 140%;
}
......
var $ = jQuery;
$(function() {
var g_tdClass = [];
var g_col;
var g_row;
var g_isFocusCell = false; // Стоит фокус или нет
var g_oldRateCell = null;
var g_submoduleID = null;
......@@ -9,42 +10,39 @@ $(function() {
var g_stdName = "";
// Ставим подстветку
function TdFocus(jThis, thisClass){
g_tdClass = thisClass.split(" ");
function TdFocus(jThis){
g_col = parseInt(jThis.attr('id'));
g_row = parseInt(jThis.parent('tr').attr('id'));
g_oldRateCell = jThis.children("input").val();
$("."+g_tdClass[0]).each(function(){
$("td#" + g_col + ".rateCell").each(function(){
$(this).css("background-color", "#f1f1f1");
});
$("."+g_tdClass[1]).each(function(){
$("tr#" + g_row + " .rateCell").each(function(){
$(this).css("background-color", "#f1f1f1");
});
}
// Убираем подстветку
function TdUnFocus(){
g_oldRateCell = null;
$("."+g_tdClass[0]).each(function(){
$("td#" + g_col + ".rateCell").each(function(){
$(this).css("background-color", "#fff");
});
$("."+g_tdClass[1]).each(function(){
$("tr#" + g_row + " .rateCell").each(function(){
$(this).css("background-color", "#fff");
});
}
function TdInfo(jThis) {
// Получаем подмодуль
var reg = /col_\d+/;
var tmp1 = ""+reg.exec(jThis.attr("class"));
g_submoduleID = parseInt($(".RatingTableSubmodulesHeadMaxRate ."+tmp1+":first").attr("id"));
g_submoduleTitle = $(".RatingTableSubmodulesHead ."+tmp1+":first").text();
g_submoduleID = parseInt($(".RatingTableSubmodulesHeadMaxRate .col_"+g_col+":first").attr("id"));
g_submoduleTitle = $(".RatingTableSubmodulesHead .col_"+g_col+":first").text();
// Получаем студента
reg = /row_\d+/;
var tmp2 = ""+reg.exec(jThis.attr("class"));
g_studentID = parseInt($("."+tmp2+":first").attr("id"));
g_stdName = $("."+tmp2+":first").text();
g_studentID = parseInt(jThis.siblings('.student').attr("id"));
g_stdName = jThis.siblings('.student').text();
jThis.append("<td class='tdInfo'>"+g_submoduleTitle+"<br>"+g_stdName+"</td>");
if (parseInt(jThis.children('.tdInfo').length) <= 0)
jThis.append("<div class='tdInfo'>"+g_submoduleTitle+"<br>"+g_stdName+"</div>");
}
function UnsetTdInfo(jThis){
......@@ -65,8 +63,6 @@ $(function() {
if (newRate <= maxRate)
{
alert(maxRate);
alert(g_studentID+' '+g_submoduleID+' '+newRate);
$.post(
URLdir + "handler/rating/setRate",
{
......@@ -97,7 +93,7 @@ $(function() {
$(".rateCell").mouseenter(function(){
if (g_isFocusCell === false)
TdFocus($(this), $(this).attr("class"));
TdFocus($(this));
});
$(".rateCell").mouseleave(function(){
......@@ -109,7 +105,7 @@ $(function() {
$(".rateCell").focusin(function(){
TdInfo($(this));
g_isFocusCell = true;
TdFocus($(this), $(this).attr("class"));
TdFocus($(this));
if ($(this).children("input").val() !== "")
oldRate = $(this).children("input").val();
else oldRate = 0;
......@@ -129,52 +125,41 @@ $(function() {
$(".rateCell").keyup(function(e){
var jThis = $(this);
// Получаем подмодуль
var reg = /col_\d+/;
var col = ""+reg.exec(jThis.attr("class"));
col = col.replace("col_", "");
col = parseInt(col);
// Получаем студента
reg = /row_\d+/;
var row = ""+reg.exec(jThis.attr("class"));
row = row.replace("row_", "");
row = parseInt(row);
TdUnFocus();
// При нажатие Enter (переход к оцениванию след. студента, т.е. ниже)
if(e.keyCode==13)
{
row = row + 1;
$(".row_" + row + ".col_" + col + ".rateCell").children("input").focus();
g_row = g_row + 1;
$("tr#" + g_row + " td#" + g_col + ".rateCell").children("input").focus();
}
// Стрелка вверх
if(e.keyCode==38)
{
row = row - 1;
$(".row_" + row + ".col_" + col + ".rateCell").children("input").focus();
g_row = g_row - 1;
$("tr#" + g_row + " td#" + g_col + ".rateCell").children("input").focus();
}
// Стрелка вправо
if(e.keyCode==39)
{
col = col + 1;
$(".row_" + row + ".col_" + col + ".rateCell").children("input").focus();
g_col = g_col + 1;
$("tr#" + g_row + " td#" + g_col + ".rateCell").children("input").focus();
}
// Стрелка вниз
if(e.keyCode==40)
{
row = row + 1;
$(".row_" + row + ".col_" + col + ".rateCell").children("input").focus();
g_row = g_row + 1;
$("tr#" + g_row + " td#" + g_col + ".rateCell").children("input").focus();
}
// Стрелка влево
if(e.keyCode==37)
{
col = col - 1;
$(".row_" + row + ".col_" + col + ".rateCell").children("input").focus();
g_col = g_col - 1;
$("tr#" + g_row + " td#" + g_col + ".rateCell").children("input").focus();
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment