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

Fixed missing methods

parent 1c102490
Branches
Tags
No related merge requests found
......@@ -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']
);
......
......@@ -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'],
......
......@@ -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');
......
......@@ -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() {
......
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