Skip to content
Snippets Groups Projects
Commit 5d5e002c authored by Anton's avatar Anton
Browse files

Реализована возможность добавления и редактирования оценок

parent b675d2b6
No related merge requests found
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Handler_Rating extends Controller {
protected $AcModel, $post;
public function before() {
parent::before();
$this->AcModel = new Model_Account;
$this->post = Validation::factory(Arr::map('trim', $_POST));
if(!$this->request->is_ajax() || !Auth::isLoggedIn())
throw HTTP_Exception::factory (403, 'no access');
}
public function action_setRate()
{
$user = Auth::getData();
$this->post -> rule('student', 'not_empty')
-> rule('student', 'digit')
-> rule('submodule', 'not_empty')
-> rule('submodule', 'digit')
-> rule('rate', 'digit')
-> rule('rate', 'range', array(':value', 0, 100));
if($this->post->check()) {
$AccInfo = $this->AcModel->getPersonalInfoByID($user['ID'])->offsetGet(0);
$TModel = new Model_Teacher_Rating;
$TModel->setRate($AccInfo['TeacherID'], $this->post->offsetGet('student'), $this->post->offsetGet('submodule'), $this->post->offsetGet('rate'));
$this->response->body(json_encode('Ok, setRate!'));
}
else
$this->response->body(json_encode('Error, setRate'));
}
public function action_changeRate()
{
$user = Auth::getData();
$this->post -> rule('student', 'not_empty')
-> rule('student', 'digit')
-> rule('submodule', 'not_empty')
-> rule('submodule', 'digit')
-> rule('rate', 'digit')
-> rule('rate', 'range', array(':value', 0, 100));
if($this->post->check()) {
$AccInfo = $this->AcModel->getPersonalInfoByID($user['ID'])->offsetGet(0);
$TModel = new Model_Teacher_Rating;
$TModel->changeRate($AccInfo['TeacherID'], $this->post->offsetGet('student'), $this->post->offsetGet('submodule'), $this->post->offsetGet('rate'));
$this->response->body(json_encode('Ok, changeRate!'));
}
else
$this->response->body(json_encode('Error, changeRate'));
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@
{% block main_top_title %}Выставление баллов{% endblock %}
{% block main_content %}
<h2 style="margin-left: 2.5%; font-weight: normal; color: #3399CC;">{{ headerRate.SubjectName }}</h2>
<table class="studentsRate" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="title" width="150px">Модуль/номер</td>
......@@ -22,7 +23,7 @@
{% set CellCount = CellCount + headerRate[i].SubmodulesCount %}
{% for j in 1..headerRate[i].SubmodulesCount %}
{% set col = col + 1 %}
<td class="subject col_{{ col }}">{{ headerRate[i][j].Title }}</td>
<td class="subject col_{{ col }}" id="{{ headerRate[i][j].SubmoduleID }}">{{ headerRate[i][j].Title }}</td>
{% endfor %}
{% endfor %}
</tr>
......@@ -30,55 +31,11 @@
{% for student in tableRate %}
{% set row = row + 1 %}
<tr>
<td class="row_{{ row }} student">{{ student.LastName }} {{ student.FirstName }}</td>
<td class="row_{{ row }} student" id="{{ student.StudentID }}">{{ student.LastName }} {{ student.FirstName }}</td>
{% for i in 1..CellCount %}
<td class="row_{{ row }} col_{{ i }} rateCell"><input value="{{ student[i].Rate }}"></td>
<td class="row_{{ row }} col_{{ i }} rateCell {% if student[i].Rate > 0 %}edit{% endif %}"><input value="{{ student[i].Rate }}"></td>
{% endfor %}
</tr>
{% endfor %}
</table>
<table class="studentsRate" style="display: none" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="title">Модуль/номер</td>
<td class="subject" colspan="2">Модуль 1</td>
<td class="subject" colspan="3">Модуль 2</td>
<td class="subject">Модуль 3</td>
</tr>
<tr>
<td class="title">Мероприятие</td>
<td class="subject col_1">Контрольная робота</td>
<td class="subject col_2">Домашние задания</td>
<td class="subject col_3">Тест</td>
<td class="subject col_4">Контрольная работа</td>
<td class="subject col_5">Домашняя работа</td>
<td class="subject col_6">Индивидуальное задание</td>
</tr>
<tr>
<td class="row_1 student">Смирнов К.К.</td>
<td class="row_1 col_1 rateCell"><input value=""></td>
<td class="row_1 col_2 rateCell"><input value=""></td>
<td class="row_1 col_3 rateCell"><input value=""></td>
<td class="row_1 col_4 rateCell"><input value=""></td>
<td class="row_1 col_5 rateCell"><input value=""></td>
<td class="row_1 col_6 rateCell"><input value=""></td>
</tr>
<tr>
<td class="row_2 student">Смирнов К.К.</td>
<td class="row_2 col_1 rateCell"><input value=""></td>
<td class="row_2 col_2 rateCell"><input value=""></td>
<td class="row_2 col_3 rateCell"><input value=""></td>
<td class="row_2 col_4 rateCell"><input value=""></td>
<td class="row_2 col_5 rateCell"><input value=""></td>
<td class="row_2 col_6 rateCell"><input value=""></td>
</tr>
<tr>
<td class="row_3 student">Смирнов К.К.</td>
<td class="row_3 col_1 rateCell"><input value=""></td>
<td class="row_3 col_2 rateCell"><input value=""></td>
<td class="row_3 col_3 rateCell"><input value=""></td>
<td class="row_3 col_4 rateCell"><input value=""></td>
<td class="row_3 col_5 rateCell"><input value=""></td>
<td class="row_3 col_6 rateCell"><input value=""></td>
</tr>
</table>
{% endblock %}
\ No newline at end of file
......@@ -54,7 +54,8 @@ div {
/*------------------------------------MAIN--------------------------------------------*/
.main {
width: 1000px;
max-width: 1000px;
min-width: 600px;
margin: 35px auto;
border-radius: 5px;
background-color: #ffffff;
......
var $ = jQuery;
$(function() {
var tdClass = new Array();;
var isFocusCell = false; // ��
var isFocusCell = false; //
// ������������ ������ � ������� ������
//
function tdFocus(thisObj, thisClass){
tdClass = thisClass.split(' ');
$('.'+tdClass[0]).each(function(){
......@@ -14,7 +14,7 @@ $(function() {
});
}
// ������� ��������� ������ � ��������
//
function tdUnFocus(thisObj){
$('.'+tdClass[0]).each(function(){
$(this).css('background-color', '#fff');
......@@ -24,6 +24,41 @@ $(function() {
});
}
function Rating($this) {
// Получаем подмодуль
var reg = /col_\d+/;
var col = ''+reg.exec($this.attr('class'));
col = $('.'+col+':first').attr('id');
// Получаем студента
var reg = /row_\d+/;
var row = ''+reg.exec($this.attr('class'));
row = $('.'+row+':first').attr('id');
alert(col+' '+row+' '+$this.children('input').val());
var edit = false; // Типа говорим, что балл нужно добавить, а не изменить
if (-1 < $this.attr('class').indexOf('edit'))
edit = true; // Типа изменить балл
if (edit) {
alert('changeRate');
$.post('/~dev_rating/handler/rating/changeRate', {'student': row, 'submodule': col, 'rate': $this.children('input').val() },
function(data){
alert(data);
}
);
}
else {
alert('setRate');
$.post('/~dev_rating/handler/rating/setRate', {'student': row, 'submodule': col, 'rate': $this.children('input').val() },
function(data){
alert(data);
}
);
}
}
$('.rateCell').mouseenter(function(){
if (isFocusCell == false)
tdFocus($(this), $(this).attr('class'));
......@@ -42,5 +77,26 @@ $(function() {
$('.rateCell').focusout(function(){
isFocusCell = false;
tdUnFocus($(this));
Rating($(this));
});
// В inputCredit (где баллы вводить) разрешаем вводить только цифры
$('.rateCell').children('input').keydown(function(event) {
// Разрешаем: backspace, delete, tab и escape
if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 ||
// Разрешаем: Ctrl+A
(event.keyCode == 65 && event.ctrlKey === true) ||
// Разрешаем: home, end, влево, вправо
(event.keyCode >= 35 && event.keyCode <= 39)) {
// Ничего не делаем
return;
}
else {
// Убеждаемся, что это цифра, и останавливаем событие keypress
if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
event.preventDefault();
}
}
});
});
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment