Skip to content
Snippets Groups Projects
Commit 770b1db6 authored by Anton's avatar Anton
Browse files

fix rating

parent 835d3c45
Branches
Tags
No related merge requests found
......@@ -10,6 +10,7 @@ class Controller_Handler_Rating extends Controller_Handler {
public function action_setRate()
{
$data['success'] = false;
$this->post -> rule('student', 'not_empty')
-> rule('student', 'digit')
-> rule('submodule', 'not_empty')
......@@ -17,15 +18,17 @@ class Controller_Handler_Rating extends Controller_Handler {
-> rule('rate', 'digit')
-> rule('rate', 'range', array(':value', 0, 100));
if($this->post->check()) {
$this->model->setRate($this->user['TeacherID'], $this->post->offsetGet('student'), $this->post->offsetGet('submodule'), $this->post->offsetGet('rate'));
$this->response->body(json_encode('Ok, setRate!'));
$result = $this->model->setRate($this->user['TeacherID'], $this->post->offsetGet('student'), $this->post->offsetGet('submodule'), $this->post->offsetGet('rate'));
var_dump($this->post);
if ($result[0]['Num'] == 0)
$data['success'] = true;
}
else
$this->response->body(json_encode('Error, setRate'));
$this->response->body(json_encode($data));
}
public function action_changeRate()
{
$data['success'] = false;
$this->post -> rule('student', 'not_empty')
-> rule('student', 'digit')
-> rule('submodule', 'not_empty')
......@@ -33,11 +36,11 @@ class Controller_Handler_Rating extends Controller_Handler {
-> rule('rate', 'digit')
-> rule('rate', 'range', array(':value', 0, 100));
if($this->post->check()) {
$this->model->changeRate($this->user['TeacherID'], $this->post->offsetGet('student'), $this->post->offsetGet('submodule'), $this->post->offsetGet('rate'));
$this->response->body(json_encode('Ok, changeRate!'));
$result = $this->model->changeRate($this->user['TeacherID'], $this->post->offsetGet('student'), $this->post->offsetGet('submodule'), $this->post->offsetGet('rate'));
if ($result[0]['Num'] == 0)
$data['success'] = true;
}
else
$this->response->body(json_encode('Error, changeRate'));
$this->response->body(json_encode($data));
}
}
\ No newline at end of file
......@@ -47,52 +47,28 @@ class Controller_Teacher_Rating extends Controller_UserEnvi {
$twig->headerRate = $disciplineHandled;
// Студенты и баллы
$students = $db->GetStudentsForDiscipline($this->UserInfo['TeacherID'], $id);
$students = $db->GetStudentsForRating($this->UserInfo['TeacherID'], $id);
$studentsHandled = array();
$i = 0; $MigrantsCount = 0;
$i = 0;
foreach($students as $row) {
if ($row['isAttached'] == '0') {
// Не Мигранты
$i++;
$studentsHandled[$i]['StudentID'] = $row['StudentID'];
$studentsHandled[$i]['LastName'] = $row['StudentLast'];
$studentsHandled[$i]['FirstName'] = $row['StudentFirst'];
$studentsHandled[$i]['SecondName'] = $row['StudentSecond'];
$studentsHandled[$i]['Grade'] = $row['Grade'];
$studentsHandled[$i]['GroupNum'] = $row['GroupNum'];
$rate = $db->getMapForStudent($row['StudentID'], $id);
$j = 0;
foreach($rate as $r) {
$j += 1;
$studentsHandled[$i][$j]['SubmoduleID'] = $r['SubmoduleID'];
$studentsHandled[$i][$j]['Rate'] = $r['Rate'];
}
$studentsHandled[$i]['RateCount'] = $j;
}
else {
// Мигранты
$MigrantsCount++;
$MigrantsHandled[$MigrantsCount]['StudentID'] = $row['StudentID'];
$MigrantsHandled[$MigrantsCount]['StudentID'] = $row['StudentID'];
$MigrantsHandled[$MigrantsCount]['LastName'] = $row['StudentLast'];
$MigrantsHandled[$MigrantsCount]['FirstName'] = $row['StudentFirst'];
$MigrantsHandled[$MigrantsCount]['SecondName'] = $row['StudentSecond'];
$MigrantsHandled[$MigrantsCount]['Grade'] = $row['Grade'];
$MigrantsHandled[$MigrantsCount]['GroupNum'] = $row['GroupNum'];
$rate = $db->getMapForStudent($row['StudentID'], $id);
$j = 0;
foreach($rate as $r) {
$j += 1;
$MigrantsHandled[$MigrantsCount][$j]['SubmoduleID'] = $r['SubmoduleID'];
$MigrantsHandled[$MigrantsCount][$j]['Rate'] = $r['Rate'];
}
$MigrantsHandled[$MigrantsCount]['RateCount'] = $j;
$i++;
$studentsHandled[$i]['StudentID'] = $row['StudentID'];
$studentsHandled[$i]['LastName'] = $row['LastName'];
$studentsHandled[$i]['FirstName'] = $row['FirstName'];
$studentsHandled[$i]['SecondName'] = $row['SecondName'];
$studentsHandled[$i]['Grade'] = $row['Grade'];
$studentsHandled[$i]['GroupNum'] = $row['GroupNum'];
$rate = $db->getMapForStudent($row['StudentID'], $id);
$j = 0;
foreach($rate as $r) {
$j += 1;
$studentsHandled[$i][$j]['SubmoduleID'] = $r['SubmoduleID'];
$studentsHandled[$i][$j]['Rate'] = $r['Rate'];
}
$studentsHandled[$i]['RateCount'] = $j;
}
$twig->tableRate = $studentsHandled;
if (isset($MigrantsHandled))
$twig->migrantsRate = $MigrantsHandled;
$this->response->body($twig);
}
......
......@@ -7,6 +7,12 @@ class Model_Teacher_Rating extends Model
$sql = "CALL `getStudentsForDiscipline`('$teacherID', '$disciplineID'); ";
return DB::query(Database::SELECT, $sql)->execute();
}
public function GetStudentsForRating($teacherID, $disciplineID)
{
$sql = "CALL `GetStudentsForRating`('$teacherID', '$disciplineID'); ";
return DB::query(Database::SELECT, $sql)->execute();
}
public function getMapForDiscipline($teacherID, $disciplineID)
{
......
......@@ -4,6 +4,9 @@
{% block media %} {# head -> css, js #}
{{ HTML.script('media/js/functions.js')|raw }}
{{ HTML.script('media/js/event_inspector/event_inspector.js')|raw }}
{{ HTML.style('media/js/event_inspector/event_inspector.css')|raw }}
{{ HTML.style('media/css/setRate.css')|raw }}
{{ HTML.script('media/js/setRate.js')|raw }}
{% endblock %}
......@@ -14,7 +17,7 @@
<p style="font-size: 15px; margin-left: 2.5%">Обратить внимание, что пустая клетка эквивалентна нулю</p>
<table class="studentsRate" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="title" width="150px">Модуль/номер</td>
<td class="title" width="150px">Модуль</td>
{% for i in 1..headerRate.ModulesCount %}
<td class="subject" colspan="{{headerRate[i].SubmodulesCount}}">{{ headerRate[i].ModuleTitle }}</td>
{% endfor %}
......@@ -46,26 +49,5 @@
{% endfor %}
</tr>
{% endfor %}
{% set GroupNum = 0 %}
{% for student in migrantsRate %}
{% if loop.first == 1 %}
<tr>
<td class="group" colspan="{{ CellCount + 1 }}">Мигранты</td>
</tr>
{% endif %}
{% set row = row + 1 %}
{% if student.GroupNum != GroupNum %}
{% set GroupNum = student.GroupNum %}
<tr>
<td class="group" colspan="{{ CellCount + 1 }}">{{ student.GroupNum }} группа</td>
</tr>
{% endif %}
<tr>
<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 {% if student[i].Rate > 0 %}edit{% endif %}"><input value="{{ student[i].Rate }}"></td>
{% endfor %}
</tr>
{% endfor %}
</table>
{% endblock %}
\ No newline at end of file
......@@ -18,7 +18,7 @@ $(function() {
if(data.success === true) {
$('.AddDiscipline').hide();
EventInspector_ShowMsg('Ок, AddDiscipline', 'success');
setTimeout('location.replace("/~dev_rating/map/'+data.DisciplineID+'")',5000);
setTimeout('location.replace("/~dev_rating/map/'+data.DisciplineID+'")',1000);
} else EventInspector_ShowMsg('Error, AddDiscipline', 'error');
}
);
......
......@@ -52,20 +52,28 @@ $(function() {
if (edit) {
$.post('/~dev_rating/handler/rating/changeRate', {'student': StudentID, 'submodule': SubmoduleID, 'rate': NewRate },
function(data){
alert(data);
data = $.parseJSON(data);
if(data.success === true)
EventInspector_ShowMsg('Балл изменен', 'success');
else EventInspector_ShowMsg('Не удалось изменить балл', 'error');
}
);
}
else {
$.post('/~dev_rating/handler/rating/setRate', {'student': StudentID, 'submodule': SubmoduleID, 'rate': NewRate },
function(data){
alert(data);
data = $.parseJSON(data);
if(data.success === true)
EventInspector_ShowMsg('Балл добавлен', 'success');
else EventInspector_ShowMsg('Не удалось добавить балл', 'error');
}
);
}
}
else
alert('Текущий балл превышает максимальный для данного модуля.');
else {
thisObj.children('input').val('0');
EventInspector_ShowMsg('Текущий балл превышает максимальный для данного модуля', 'error');
}
}
$('.rateCell').mouseenter(function(){
......@@ -97,6 +105,11 @@ $(function() {
tdUnFocus($(this));
});
// При нажатие на элемент rateCell дочерный input получает фокус
$('.rateCell ').click(function(){
$(this).children('input').focus();
} );
// В inputCredit (где баллы вводить) разрешаем вводить только цифры
$('.rateCell').children('input').keydown(function(event) {
KeyDownOnlyNumber(event);
......
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