diff --git a/application/classes/Controller/Student/Subject.php b/application/classes/Controller/Student/Subject.php index fac3a5f87d855c8a82c1675f020a498b467ed78f..149a9fce3e326cfb33e296d4c9497ac1c2af1b49 100644 --- a/application/classes/Controller/Student/Subject.php +++ b/application/classes/Controller/Student/Subject.php @@ -9,8 +9,41 @@ class Controller_Student_Subject extends Controller_UserEnvi { $db = new Model_Student; $id = $this->request->param('id'); $discipline = $db->getDisciplineMap($this->UserInfo['StudentID'], $id); - if(count($discipline) == 0) + + if($discipline->count() == 0) throw HTTP_Exception::factory(404, "Предмет СЃ ID $id РЅРµ найден!"); + + $info = $db->getDisciplineInfoByID($id)->offsetGet(0); + $teachers = $db->getTeachersForDiscipline($id); + + $subject['Title'] = $info['SubjectName']; + + if($info['ExamType'] == 'exam') + { + $subject['Control'] = 'Ркзамен'; + } + elseif($info['ExamType'] == 'credit') + { + $subject['Control'] = 'Зачет'; + } + + $subject['LectureHours'] = $info['LectionCount']; + $subject['SeminarHours'] = $info['PracticeCount']; + + $teachersHandled = array(); $i = 0; + foreach ($teachers as $row) { + $teachersHandled[$i] = $row['LastName'].' '.$row['FirstName'].''; + if(!empty($row['TeacherSecond'])) + { + $teachersHandled[$i] .= ' '.$row['SecondName']; + } + $i++; + } + + $subject['Teachers'] = implode(', ', $teachersHandled); + + $twig->Subject = $subject; + $disciplineHandled = array(); $rate = 0; $maxRate = 0; $i = 0; $id = 0; foreach($discipline as $row) diff --git a/application/classes/Controller/Teacher/Index.php b/application/classes/Controller/Teacher/Index.php index a5694e7f22deedbb0f6055857952ec0b286ad3af..aaf788af789b84504015735603237d2a5cf6a8fb 100644 --- a/application/classes/Controller/Teacher/Index.php +++ b/application/classes/Controller/Teacher/Index.php @@ -5,6 +5,9 @@ class Controller_Teacher_Index extends Controller_UserEnvi { public function action_index() { $twig = Twig::factory('teacher/index'); + + // ??? + $twig->User = $this->UserInfo; $this->response->body($twig); } diff --git a/application/classes/Controller/Teacher/Map.php b/application/classes/Controller/Teacher/Map.php index 13b0233bc9482cc348ccdd4f55cb6bcb9de618c3..ec5ba94425c8b3141485ac2a62985771555856c0 100644 --- a/application/classes/Controller/Teacher/Map.php +++ b/application/classes/Controller/Teacher/Map.php @@ -5,15 +5,45 @@ class Controller_Teacher_Map extends Controller_UserEnvi { public function action_show() { $twig = Twig::factory('teacher/map/show'); + $id = $this->request->param('id'); + $db = new Model_Teacher_Map; + $map = $db->getMapForDiscipline($this->UserInfo['TeacherID'], $id); + if($map->count() == 0) + throw HTTP_Exception::factory(404, "Учебная карта дисциплины СЃ ID $id РЅРµ найдена!"); + + $twig->User = $this->UserInfo; + $twig->Map = $this->getMapInfo($map); + $twig->Subject = $this->getSubjectInfo($db, $id); + $this->response->body($twig); + } + + public function action_create() + { + $twig = Twig::factory('teacher/map/construct'); $twig->User = $this->UserInfo; $id = $this->request->param('id'); + + $this->response->body($twig); + } + + public function action_edit() + { + $twig = Twig::factory('teacher/map/construct'); + $id = $this->request->param('id'); $db = new Model_Teacher_Map; - $map = $db->getMapForDiscipline($this->UserInfo['TeacherID'], $id); + $map = $db->getDisciplineMap($this->UserInfo['TeacherID'], $id); if($map->count() == 0) throw HTTP_Exception::factory(404, "Учебная карта дисциплины СЃ ID $id РЅРµ найдена!"); + $twig->User = $this->UserInfo; + $twig->Map = $this->getMapInfo($map); + $twig->Subject = $this->getSubjectInfo($db, $id); + $this->response->body($twig); + } + + private function getMapInfo($map) { $mapHandled = array(); $maxRate = 0; $i = 0; $module = 0; @@ -38,57 +68,40 @@ class Controller_Teacher_Map extends Controller_UserEnvi { $maxRate += $row['MaxRate']; } $mapHandled['ModulesCount'] = $i; - $mapHandled['MaxRate'] = (int) $maxRate; - - $this->map = $mapHandled; + $mapHandled['MaxRate'] = (int) $maxRate; - //$this->response->body($twig); - $this->response->body('<pre>'.print_r($mapHandled, true).'</pre>'); + return $mapHandled; } - public function action_create() + public function getSubjectInfo($db, $id) { - $twig = Twig::factory('teacher/map/construct'); - $twig->User = $this->UserInfo; - $id = $this->request->param('id'); + $info = $db->getDisciplineInfoByID($id)->offsetGet(0); + $teachers = $db->getTeachersForDiscipline($id); - $this->response->body($twig); - } - - public function action_edit() - { - $twig = Twig::factory('teacher/map/construct'); - $twig->User = $this->UserInfo; - $id = $this->request->param('id'); - $db = new Model_Teacher_Map; - $discipline = $db->getDisciplineMap($this->UserInfo['TeacherID'], $id); - if($discipline->count() == 0) - throw HTTP_Exception::factory(404, "Учебная карта дисциплины СЃ ID $id РЅРµ найдена!"); - $disciplineHandled = array(); - $maxRate = 0; $i = 0; $module = 0; - foreach($discipline as $row) + $subject['Title'] = $info['SubjectName']; + if($info['ExamType'] == 'exam') { - if($row['ModuleID'] != $module) - { - $i++; - $module = $row['ModuleID']; - } - if(!isset($disciplineHandled[$i]['SubmodulesCount'])) + $subject['Control'] = 'Ркзамен'; + } + elseif($info['ExamType'] == 'credit') + { + $subject['Control'] = 'Зачет'; + } + + $subject['LectureHours'] = $info['LectionCount']; + $subject['SeminarHours'] = $info['PracticeCount']; + + $teachersHandled = array(); $i = 0; + + foreach ($teachers as $row) { + $teachersHandled[$i] = $row['LastName'].' '.$row['FirstName'].''; + if(!empty($row['TeacherSecond'])) { - $disciplineHandled[$i]['SubmodulesCount'] = 0; - $disciplineHandled[$i]['MaxRate'] = 0; + $teachersHandled[$i] .= ' '.$row['SecondName']; } - $j = $disciplineHandled[$i]['SubmodulesCount'] += 1; - $disciplineHandled[$i]['MaxRate'] += (int) $row['MaxRate']; - $disciplineHandled[$i]['ModuleTitle'] = $row['ModuleName']; - $disciplineHandled[$i][$j]['Title'] = $row['SubModuleName']; - $disciplineHandled[$i][$j]['Description'] = $row['SubmoduleDescription']; - $disciplineHandled[$i][$j]['MaxRate'] = (int) $row['MaxRate']; - $maxRate += $row['MaxRate']; + $i++; } - $disciplineHandled['ModulesCount'] = $i; - $disciplineHandled['MaxRate'] = (int) $maxRate; - $this->response->body($twig); + $subject['Teachers'] = implode(', ', $teachersHandled); } } \ No newline at end of file diff --git a/application/classes/Model/Student.php b/application/classes/Model/Student.php index 834a4b91562c79e62bd754d4953becfc24c2f1fe..ea86c6096936dea9dac0f73a0c667fcc06236167 100644 --- a/application/classes/Model/Student.php +++ b/application/classes/Model/Student.php @@ -13,4 +13,16 @@ class Model_Student extends Model $sql = "CALL `GetSubjectMapForStudent`('$student_id', '$subject_id'); "; return DB::query(Database::SELECT, $sql)->execute(); } + + public function getDisciplineInfoByID($discipline_id) + { + $sql = "CALL `GetDisciplineInfoByID`('$discipline_id'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + + public function getTeachersForDiscipline($discipline_id) + { + $sql = "CALL `GetTeachersForDiscipline`('$discipline_id'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } } diff --git a/application/classes/Model/Teacher/Map.php b/application/classes/Model/Teacher/Map.php index b682c76b921107e464dc7e3def16f96b80470cab..792bd6ce2ecabd92d850d0a507b2f3a23543204b 100644 --- a/application/classes/Model/Teacher/Map.php +++ b/application/classes/Model/Teacher/Map.php @@ -31,4 +31,16 @@ class Model_Teacher_Map extends Model $sql = "SELECT `ChangeSubmodule`('$teacherID', '$submoduleID', '$maxRate', '$order', '$title', '$description') AS `Num`;"; return DB::query(Database::SELECT, $sql)->execute(); } + + public function getDisciplineInfoByID($discipline_id) + { + $sql = "CALL `GetDisciplineInfoByID`('$discipline_id'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + + public function getTeachersForDiscipline($discipline_id) + { + $sql = "CALL `GetTeachersForDiscipline`('$discipline_id'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } } diff --git a/application/views/base.twig b/application/views/base.twig index 707bf4bdc1ffd78120b0167e15c404509abb9b1c..20c129b919fa24a3f7ea62fb4e086b929a4de92f 100644 --- a/application/views/base.twig +++ b/application/views/base.twig @@ -1,7 +1,7 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <title>{% block title %}{% endblock %}</title> + <title>{% block title %}{% endblock %} | {{ System.Title }}</title> {{ HTML.style('media/css/base.css')|raw }} {{ HTML.script('media/js/jquery-1.11.1.min.js')|raw }} {% block media %}{% endblock %} @@ -12,7 +12,7 @@ <div class="header_wrapper"> <div class="header"> <div class="top_logo"> - {{ System.Title }} + {{ HTML.anchor('/', System.Title, {'title': 'Перейти РЅР° главную'})|raw }} </div> <div class="top_name_faculty"> {{ User.FacultyName }} diff --git a/application/views/student/subject.twig b/application/views/student/subject.twig index e28f944ca667cbfbc4cfecdf8f0669a65629e155..ece1a1c3f7ad5f6e100164a3025ec9a0e6415d38 100644 --- a/application/views/student/subject.twig +++ b/application/views/student/subject.twig @@ -21,9 +21,15 @@ {% endmacro %} {% import 'student/subject' as mod %} - +{% block title %}{{ Subject.Title|default('Предмет') }}{% endblock %} {% block main_top_title %} {{ Subject.Title|default('Предмет') }} {% endblock %} {% block main_content %} +<div class='main_teachers'> + <b>Преподаватели:</b> {{ Subject.Teachers }}<br> + <b>Форма промежуточной аттестации:</b> {{ Subject.Control }}<br> + <b>Всего {{ Subject.LectureHours + Subject.SeminarHours }} С‡.</b>, РІ том числе + <b>{{ Subject.LectureHours }} С‡.</b> лекций Рё <b>{{ Subject.SeminarHours }} С‡.</b> практики +</div> <div class="main_modules"> {% for i in range(1, discipline.ModulesCount) %} <table border="0" cellspacing="0" class="module_table">