diff --git a/~dev_rating/application/classes/Controller/Handler/AdmStudents.php b/~dev_rating/application/classes/Controller/Handler/AdmStudents.php index 39ab21049e029ed4f88b97acf1ae05fedeccb918..4008b9183d34779ee8030ae37dccfc0c09fa914b 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 319dbc49723b14c4cd3f05c65e924c1f6095dc07..8519e3c5d4eace746f14e3da3a14b009b9b65a3a 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 590259bdfd22fb32b6849cb946ec5bf2f116fa5d..71738cb788786a072ee594f61533d83c3674d339 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 5235102e7c540a4409c5632c25cb5d1090745f41..021b14179b1e2fc3ef56927c5da0cd2879d1a709 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() {