From 67b13a917b0f34da00ec7dde263e56312532fc65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=A0=D1=83=D0=B4?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D1=86?= <andrey.rudenets@gmail.com> Date: Tue, 5 Aug 2014 00:49:46 +0400 Subject: [PATCH] =?UTF-8?q?1.=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=B8=D0=BD=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BE=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=BC=D0=B5=D1=82=D0=B5=20=D1=81=D1=82=D1=83=D0=B4?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D1=83=20(=D0=BF=D0=BE=D0=BA=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=BA=D0=B0=D0=B7=D0=B8=D1=81=D1=82=D0=BE)=202.=20=D0=98?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D0=BE=D0=BB=D0=BE=D0=B2=D0=BE=D0=BA=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D1=8B=203.=20=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=8B=20=D1=81=D1=81=D1=8B?= =?UTF-8?q?=D0=BB=D0=BA=D0=BE=D0=B9=20=D0=BD=D0=B0=20=D0=B3=D0=BB=D0=B0?= =?UTF-8?q?=D0=B2=D0=BD=D1=83=D1=8E=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D1=83=204.=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=B8=D0=BD=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BE=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=BC=D0=B5=D1=82=D0=B5=20=D0=BF=D1=80=D0=B5=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8E=20(?= =?UTF-8?q?=D0=BF=D0=BE=D0=BA=D0=B0=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE?= =?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D0=B0=20=D0=B2=20?= =?UTF-8?q?=D0=BD=D0=B5=D1=81=D1=83=D1=89=D0=B5=D1=81=D1=82=D0=B2=D1=83?= =?UTF-8?q?=D1=8E=D1=89=D0=B8=D0=B9=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../classes/Controller/Student/Subject.php | 35 ++++++- .../classes/Controller/Teacher/Index.php | 3 + .../classes/Controller/Teacher/Map.php | 99 +++++++++++-------- application/classes/Model/Student.php | 12 +++ application/classes/Model/Teacher/Map.php | 12 +++ application/views/base.twig | 4 +- application/views/student/subject.twig | 8 +- 7 files changed, 126 insertions(+), 47 deletions(-) diff --git a/application/classes/Controller/Student/Subject.php b/application/classes/Controller/Student/Subject.php index fac3a5f87..149a9fce3 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 a5694e7f2..aaf788af7 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 13b0233bc..ec5ba9442 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 834a4b915..ea86c6096 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 b682c76b9..792bd6ce2 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 707bf4bdc..20c129b91 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 e28f944ca..ece1a1c3f 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"> -- GitLab