diff --git a/~dev_rating/application/classes/Controller/Handler/Rating.php b/~dev_rating/application/classes/Controller/Handler/Rating.php index 8611b15c7a92fe734f0ef317e9cf213c9d1b2b68..e3db2673ecf63a80b514469ea9e19904eb6ed572 100644 --- a/~dev_rating/application/classes/Controller/Handler/Rating.php +++ b/~dev_rating/application/classes/Controller/Handler/Rating.php @@ -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 diff --git a/~dev_rating/application/classes/Controller/Teacher/Rating.php b/~dev_rating/application/classes/Controller/Teacher/Rating.php index a30d7ea2a38e8e5e023a2e81844c6d8685f40723..f8522373e864c3aec505913fe2fdc0a4df320a7c 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Rating.php +++ b/~dev_rating/application/classes/Controller/Teacher/Rating.php @@ -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); } diff --git a/~dev_rating/application/classes/Model/Teacher/Rating.php b/~dev_rating/application/classes/Model/Teacher/Rating.php index dfe334ba8a0cd36f5e154439281c3a78d4589970..53d6170e30028ecb7710cad3855ab4b6cece409a 100644 --- a/~dev_rating/application/classes/Model/Teacher/Rating.php +++ b/~dev_rating/application/classes/Model/Teacher/Rating.php @@ -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) { diff --git a/~dev_rating/application/views/teacher/setRate.twig b/~dev_rating/application/views/teacher/setRate.twig index 59663696e7de5f2942a213802ff08356ad04d651..593ebcabe4e9dcea09ea8dc296a0c7ec26aedd8e 100644 --- a/~dev_rating/application/views/teacher/setRate.twig +++ b/~dev_rating/application/views/teacher/setRate.twig @@ -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 diff --git a/~dev_rating/media/js/construct/create.js b/~dev_rating/media/js/construct/create.js index 7f122b4cb26751277dc83270a5df7180dc0d35cb..5644574d5041734ee18e3df9586521f104e01fff 100644 --- a/~dev_rating/media/js/construct/create.js +++ b/~dev_rating/media/js/construct/create.js @@ -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'); } ); diff --git a/~dev_rating/media/js/setRate.js b/~dev_rating/media/js/setRate.js index 49e37497f125a4b00bbfb9fc51e1765a956b12f2..482ddea140e70ba1fb94258ad945a2fcce2407c3 100644 --- a/~dev_rating/media/js/setRate.js +++ b/~dev_rating/media/js/setRate.js @@ -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);