From e2c1b05341b815c220d50fc47fb9b5b876cf4019 Mon Sep 17 00:00:00 2001 From: xamgore <xamgore@ya.ru> Date: Mon, 15 Jun 2015 21:15:56 +0300 Subject: [PATCH] Fixed missing methods --- .../Controller/Handler/AdmStudents.php | 3 +-- .../Controller/Handler/AdmTeachers.php | 3 +-- .../classes/Controller/Handler/Coursework.php | 21 +++++++++++++------ .../classes/Controller/Handler/Map.php | 18 +++------------- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/~dev_rating/application/classes/Controller/Handler/AdmStudents.php b/~dev_rating/application/classes/Controller/Handler/AdmStudents.php index 39ab21049..4008b9183 100644 --- a/~dev_rating/application/classes/Controller/Handler/AdmStudents.php +++ b/~dev_rating/application/classes/Controller/Handler/AdmStudents.php @@ -46,8 +46,7 @@ class Controller_Handler_AdmStudents extends Controller_Handler } if ($this->post->check()) { - $code = Account::instance() - ->createStudent( + $code = Model_Account::createStudent( $this->post['lastName'], $this->post['firstName'], $this->post['secondName'], $this->post['gradeNum'], $this->post['groupNum'], $this->post['facultyID'] ); diff --git a/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php b/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php index 319dbc497..8519e3c5d 100644 --- a/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php +++ b/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php @@ -34,8 +34,7 @@ class Controller_Handler_AdmTeachers extends Controller_Handler { } if($this->post->check()) { - $code = Account::instance() - ->createTeacher( + $code = Model_Account::createTeacher( $this->post['lastName'], $this->post['firstName'], $this->post['secondName'], diff --git a/~dev_rating/application/classes/Controller/Handler/Coursework.php b/~dev_rating/application/classes/Controller/Handler/Coursework.php index 590259bdf..71738cb78 100644 --- a/~dev_rating/application/classes/Controller/Handler/Coursework.php +++ b/~dev_rating/application/classes/Controller/Handler/Coursework.php @@ -2,17 +2,22 @@ class Controller_Handler_Coursework extends Controller_Handler_Map { + /** @var Model_User_Teacher */ + protected $user; + public function before() { parent::before(); $this->user->checkAccess(User::RIGHTS_TEACHER); } + const SCIENTIFIC_COURSEWORK_ID = 346; // todo: remove this from database + public function action_add() { $data['success'] = false; $subject =& $this->post['subjectID']; - $subject = ($this->post['type'] == 'scientific') ? 346 : (int) $subject; + $subject = ($this->post['type'] == 'scientific') ? self::SCIENTIFIC_COURSEWORK_ID : (int) $subject; $this->post ->rule('type', 'matches', [':validation', 'scientific', 'disciplinary']) @@ -22,7 +27,7 @@ class Controller_Handler_Coursework extends Controller_Handler_Map { ->rule('facultyID', 'digit'); if ($subject > 0 && $this->post->check()) { - $discipline['id'] = Model_CourseWork::create([ + $id = Model_CourseWork::create([ 'faculty' => $this->post['facultyID'], 'grade' => $this->post['grade'], 'teacher' => $this->user->TeacherID, @@ -31,11 +36,15 @@ class Controller_Handler_Coursework extends Controller_Handler_Map { 'subject' => $subject, ]); - if ($discipline['id']) { + if ($id) { + $discipline = Model_Discipline::load($id); + // Attach all teachers of the department to coursework - if ($this->post['type'] == 'scientific') - foreach (Model_Teachers::getTeachersByDepartment($this->user->DepID) as $teacher) - Model_Map::bindTeacher($this->user->TeacherID, $teacher['ID'], $discipline['id']); + if ($this->post['type'] == 'scientific') { + $teachers = Model_Teachers::getTeachersByDepartment($this->user->DepID); + foreach ($teachers as $teacher) + $discipline->bind(Model_Teacher::with($teacher['ID'])); + } $module = Model_Map::addModule($this->user->TeacherID, $discipline['id'], 'Курсовая работа')[0]['Num']; Model_Map::addSubmodule($this->user->TeacherID, $module, 100, 'Отчёт', '', 'LandmarkControl'); diff --git a/~dev_rating/application/classes/Controller/Handler/Map.php b/~dev_rating/application/classes/Controller/Handler/Map.php index 5235102e7..021b14179 100644 --- a/~dev_rating/application/classes/Controller/Handler/Map.php +++ b/~dev_rating/application/classes/Controller/Handler/Map.php @@ -5,6 +5,9 @@ class Controller_Handler_Map extends Controller_Handler { /** @var Model_Map */ protected $model; + /** @var Model_User_Teacher */ + protected $user; + public function before() { parent::before(); @@ -405,21 +408,6 @@ class Controller_Handler_Map extends Controller_Handler { } $this->response->body(json_encode($searchResult)); } - - // Отсоединить преподавателя - public function action_UnbindTeacher() { - $data['success'] = false; - $this->post -> rule('BindingTeacher', 'not_empty') - -> rule('BindingTeacher', 'digit') - -> rule('DisciplineID', 'not_empty') - -> rule('DisciplineID', 'digit'); - if($this->post->check()) { - $result = $this->model->UnbindTeacher($this->user->TeacherID, $this->post['BindingTeacher'], $this->post['DisciplineID']); - if ($result[0]['Num'] == 0) - $data['success'] = true; - } - $this->response->body(json_encode($data)); - } // Получаем список кафедр public function action_GetDepartments() { -- GitLab