diff --git a/~dev_rating/application/classes/Controller/Student/Index.php b/~dev_rating/application/classes/Controller/Student/Index.php index fc68cf6cd776cd3ba35138e9e72de8eca8294af9..30843a96ba0fd8a17ef200f19ab999960b2cd441 100644 --- a/~dev_rating/application/classes/Controller/Student/Index.php +++ b/~dev_rating/application/classes/Controller/Student/Index.php @@ -1,5 +1,5 @@ <?php defined('SYSPATH') or die('No direct script access.'); - + class Controller_Student_Index extends Controller_Environment_Student { public function action_index() { @@ -12,10 +12,15 @@ class Controller_Student_Index extends Controller_Environment_Student $marks[$dis->ID] = Model_Subject::getECTSMark($dis->Rate, $dis->MaxCurrentRate, $exam = NULL); } + $teachers = $student->getTeachers(); + foreach ($teachers as $disID => &$list) { + $list = Controller_Teacher_Index::getShortListOfTeachers($list); + } + $this->twig->set([ 'Marks' => $marks, 'Disciplines' => $disciplines, - 'Teachers' => $student->getTeachers(), + 'Teachers' => $teachers, 'SemesterList' => Model_Semesters::loadAll(), ])->set_filename(static::STUDENT . 'index'); } @@ -24,4 +29,4 @@ class Controller_Student_Index extends Controller_Environment_Student $this->twig->set_filename('settings'); } } - + diff --git a/~dev_rating/application/classes/Controller/Teacher/Index.php b/~dev_rating/application/classes/Controller/Teacher/Index.php index 5d5465f83fb67849ffd5fa43f67720fcc98414a9..d6e7c9d7a725789057c50b986dee3762f31734ea 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Index.php +++ b/~dev_rating/application/classes/Controller/Teacher/Index.php @@ -29,8 +29,10 @@ class Controller_Teacher_Index extends Controller_Environment_Teacher $scientific = $dis->Subtype == Model_CourseWork::SCIENTIFIC; // todo: Pavel will write an optimized query - if (!$scientific && !$teachers[$dis->ID]) - $teachers[$dis->ID] = $dis->getTeachers(); + if (!$scientific && !$teachers[$dis->ID]) { + $list = $dis->getTeachers()->groupByUniqueKey('ID'); + $teachers[$dis->ID] = $this->getShortListOfTeachers($list, $dis->AuthorID, $this->user->TeacherID); + } if (isset($dis->GroupNum) && $dis->GroupNum) $groups[$dis->ID][] = $dis->GroupNum . ' гр.'; } @@ -42,8 +44,20 @@ class Controller_Teacher_Index extends Controller_Environment_Teacher 'SemesterList' => Model_Semesters::loadAll(), ])->set_filename('teacher/index'); } - + + public static function getShortListOfTeachers(&$teachers, $authorID = null, $vipID = null) { + $short = []; + + // place vip & author at the beginning + foreach ($teachers as $id => &$teacher) { + if ($id == $authorID || $id == $vipID) + $short += [$id => $teacher]; + } + + return $short + Arr::shuffle_assoc($teachers); + } + public function action_settings() { $this->twig->set_filename('settings'); } -} \ No newline at end of file +} diff --git a/~dev_rating/application/views/student/index.twig b/~dev_rating/application/views/student/index.twig index 5161d05f89808fb4db67715a44a4705575a72630..00c00a732779225cf42da034225143b994cc6d93 100644 --- a/~dev_rating/application/views/student/index.twig +++ b/~dev_rating/application/views/student/index.twig @@ -26,11 +26,13 @@ {% elseif Discipline.Subtype == 'scientific_coursework' %} Науч. рук. {% else %} - {% for teacher in Teachers[Discipline.ID] %} - {{ Text.abbreviateName(teacher) }}<br> + {% for teacher in Teachers[Discipline.ID] |slice(0, 4) |sortbyfield('LastName') %} + <div>{{ Text.abbreviateName(teacher) }}</div> {% else %} — {% endfor %} + + {% endif %} </td> diff --git a/~dev_rating/application/views/teacher/index.twig b/~dev_rating/application/views/teacher/index.twig index d1de4d91d9a909ebf8178b442a6563cd0da72d7b..5483d30e62d1e56016e870155ce98ef8a898a305 100644 --- a/~dev_rating/application/views/teacher/index.twig +++ b/~dev_rating/application/views/teacher/index.twig @@ -21,7 +21,7 @@ {% if Discipline.Subtype == 'scientific_coursework' %} Сотрудники кафедры {% else %} - {% for teacher in Teachers[Discipline.ID] | slice(0, 7) %} + {% for teacher in Teachers[Discipline.ID] |slice(0, 4) |sortbyfield('LastName') %} <div>{{ Text.abbreviateName(teacher) }}</div> {% else %} — @@ -140,4 +140,4 @@ <h2 style="text-align: center;">В настоящий момент Вы не подписаны ни на одну из существующих дисциплин.</h2> {% endfor %} </div> -{% endblock %} \ No newline at end of file +{% endblock %}