Skip to content
Snippets Groups Projects
Commit e2c1b053 authored by xamgore's avatar xamgore
Browse files

Fixed missing methods

parent 1c102490
Branches
No related merge requests found
...@@ -46,8 +46,7 @@ class Controller_Handler_AdmStudents extends Controller_Handler ...@@ -46,8 +46,7 @@ class Controller_Handler_AdmStudents extends Controller_Handler
} }
if ($this->post->check()) { if ($this->post->check()) {
$code = Account::instance() $code = Model_Account::createStudent(
->createStudent(
$this->post['lastName'], $this->post['firstName'], $this->post['secondName'], $this->post['lastName'], $this->post['firstName'], $this->post['secondName'],
$this->post['gradeNum'], $this->post['groupNum'], $this->post['facultyID'] $this->post['gradeNum'], $this->post['groupNum'], $this->post['facultyID']
); );
......
...@@ -34,8 +34,7 @@ class Controller_Handler_AdmTeachers extends Controller_Handler { ...@@ -34,8 +34,7 @@ class Controller_Handler_AdmTeachers extends Controller_Handler {
} }
if($this->post->check()) if($this->post->check())
{ {
$code = Account::instance() $code = Model_Account::createTeacher(
->createTeacher(
$this->post['lastName'], $this->post['lastName'],
$this->post['firstName'], $this->post['firstName'],
$this->post['secondName'], $this->post['secondName'],
......
...@@ -2,17 +2,22 @@ ...@@ -2,17 +2,22 @@
class Controller_Handler_Coursework extends Controller_Handler_Map { class Controller_Handler_Coursework extends Controller_Handler_Map {
/** @var Model_User_Teacher */
protected $user;
public function before() { public function before() {
parent::before(); parent::before();
$this->user->checkAccess(User::RIGHTS_TEACHER); $this->user->checkAccess(User::RIGHTS_TEACHER);
} }
const SCIENTIFIC_COURSEWORK_ID = 346; // todo: remove this from database
public function action_add() { public function action_add() {
$data['success'] = false; $data['success'] = false;
$subject =& $this->post['subjectID']; $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 $this->post
->rule('type', 'matches', [':validation', 'scientific', 'disciplinary']) ->rule('type', 'matches', [':validation', 'scientific', 'disciplinary'])
...@@ -22,7 +27,7 @@ class Controller_Handler_Coursework extends Controller_Handler_Map { ...@@ -22,7 +27,7 @@ class Controller_Handler_Coursework extends Controller_Handler_Map {
->rule('facultyID', 'digit'); ->rule('facultyID', 'digit');
if ($subject > 0 && $this->post->check()) { if ($subject > 0 && $this->post->check()) {
$discipline['id'] = Model_CourseWork::create([ $id = Model_CourseWork::create([
'faculty' => $this->post['facultyID'], 'faculty' => $this->post['facultyID'],
'grade' => $this->post['grade'], 'grade' => $this->post['grade'],
'teacher' => $this->user->TeacherID, 'teacher' => $this->user->TeacherID,
...@@ -31,11 +36,15 @@ class Controller_Handler_Coursework extends Controller_Handler_Map { ...@@ -31,11 +36,15 @@ class Controller_Handler_Coursework extends Controller_Handler_Map {
'subject' => $subject, 'subject' => $subject,
]); ]);
if ($discipline['id']) { if ($id) {
$discipline = Model_Discipline::load($id);
// Attach all teachers of the department to coursework // Attach all teachers of the department to coursework
if ($this->post['type'] == 'scientific') if ($this->post['type'] == 'scientific') {
foreach (Model_Teachers::getTeachersByDepartment($this->user->DepID) as $teacher) $teachers = Model_Teachers::getTeachersByDepartment($this->user->DepID);
Model_Map::bindTeacher($this->user->TeacherID, $teacher['ID'], $discipline['id']); foreach ($teachers as $teacher)
$discipline->bind(Model_Teacher::with($teacher['ID']));
}
$module = Model_Map::addModule($this->user->TeacherID, $discipline['id'], 'Курсовая работа')[0]['Num']; $module = Model_Map::addModule($this->user->TeacherID, $discipline['id'], 'Курсовая работа')[0]['Num'];
Model_Map::addSubmodule($this->user->TeacherID, $module, 100, 'Отчёт', '', 'LandmarkControl'); Model_Map::addSubmodule($this->user->TeacherID, $module, 100, 'Отчёт', '', 'LandmarkControl');
......
...@@ -5,6 +5,9 @@ class Controller_Handler_Map extends Controller_Handler { ...@@ -5,6 +5,9 @@ class Controller_Handler_Map extends Controller_Handler {
/** @var Model_Map */ /** @var Model_Map */
protected $model; protected $model;
/** @var Model_User_Teacher */
protected $user;
public function before() { public function before() {
parent::before(); parent::before();
...@@ -405,21 +408,6 @@ class Controller_Handler_Map extends Controller_Handler { ...@@ -405,21 +408,6 @@ class Controller_Handler_Map extends Controller_Handler {
} }
$this->response->body(json_encode($searchResult)); $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() { public function action_GetDepartments() {
......
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