Newer
Older
<?php defined('SYSPATH') || die('No direct script access.');
class Controller_Handler_Discipline extends Controller_Handler_Api
/** @var Model_User_Teacher */
protected $user;
$id = (int) $this->request->post('id');
return Model_Discipline::load($id);
if (!Model_System::loadConfig()->Functional->DisciplineCreation)
throw HTTP_Exception::factory(404);
$this->user->checkAccess(User::RIGHTS_TEACHER);
->semester($this->post['semesterID'])
->faculty ($this->post['facultyID'])
->subject ($this->post['subjectID'])
->grade ($this->post['gradeID'])
->lectures($this->post['lectures'])
->practice($this->post['practice'])
->labs ($this->post['labs'])
->type ($this->post['type'])
->create();
Model_Map::of($discipline)->addModuleBonus($this->user->TeacherID);
public function action_getCompounds() {
$ret = '<option value="0"> -- Нет -- </option>';
$compounds = Model_Grades::getCompoundDisciplinesForGrade($this->post['gradeID']);
foreach($compounds as $cmp){
$cmpID = $cmp['ID'];
$cmpName = $cmp['Name'];
$ret .= "<option value = $cmpID> $cmpName </option>";
}
return $ret;
}
$this->user->checkAccess(User::RIGHTS_TEACHER);
$id = (int) $this->request->post('id');
throw new InvalidArgumentException(Error::ID_IS_INCORRECT);
throw new LogicException('Not implemented yet');
}
# /handler/discipline/clear
public function action_clear() {
$this->user->checkAccess(User::RIGHTS_ADMIN);
$id = (int) $this->request->post('id');
// Model_Discipline::load($id)->clear()->delete();
Владислав Яковлев
committed
if (!Model_System::loadConfig()->Functional->DisciplineCreation)
throw HTTP_Exception::factory(404);
$discipline = $this->loadDisciplineAndAuthorCheck();
throw new LogicException(Error::DISCIPLINE_IS_LOCKED);
if (Model_Rating::count($discipline) > 0)
throw new LogicException(Error::DISCIPLINE_IS_LOCKED);
$discipline->delete();
public function action_delegate() {
// if (!Model_System::loadConfig()->Functional->DisciplineCreation)
// throw HTTP_Exception::factory(404);
$discipline = $this->loadDisciplineAndAuthorCheck();
$teacherID = (int) $this->request->post('teacherID');
$teacher = Model_Teacher::with($teacherID);
$discipline->delegateTo($teacher);
}
public function action_bind() {
$discipline = $this->loadDisciplineAndAuthorCheck();
$teacherID = (int) $this->request->post('teacherID');
$teacher = Model_Teacher::with($teacherID);
$discipline->bind($teacher);
}
public function action_unbind() {
$discipline = $this->loadDisciplineAndAuthorCheck();
$teacherID = (int) $this->request->post('teacherID');
$teacher = Model_Teacher::with($teacherID);
$discipline->unbind($teacher);
}
Владислав Яковлев
committed
public function action_copyStructure() {
$discipline = $this->loadDisciplineAndAuthorCheck();
$teacherID = (int) $this->request->post('teacherID');
$disciplineFromID = (int) $this->request->post('disciplineFromID');
$discipline->copyDisciplineStructureFrom($teacherID, $disciplineFromID);
}
public function action_getSimilarDisciplines() {
$this->loadDisciplineAndAuthorCheck();
$subjectID = (int) $this->request->post('subjectID');
$teacherID = (int) $this->request->post('teacherID');
return json_encode(Model_Teacher::with($teacherID)->getSimilarDisciplines($subjectID));
}
public function action_getDisciplinesForGroup() {
$groupID = $this->request->post('groupID');
$semesterID = User::instance()->SemesterID;
//$students = Model_Students::ofGroup($groupID, $semesterID);
// TODO: refactor after new groups implemented
$disciplines = Model_Group::with($groupID)->getDisciplinesForExport(false, $semesterID);
$disciplines = Arr::groupByUniqueKey('ID', $disciplines);
return json_encode($disciplines);
}
/**
* @return Model_Discipline
*/
private function loadDisciplineAndAuthorCheck() {
$this->user->checkAccess(User::RIGHTS_TEACHER);
$id = (int)$this->request->post('id');
$discipline = Model_Discipline::load($id);
if ($discipline->AuthorID != $this->user->TeacherID)
throw new LogicException(Error::ACCESS_DENIED);