diff --git a/~dev_rating/application/classes/Controller/Student/Index.php b/~dev_rating/application/classes/Controller/Student/Index.php index 015c3c89dc8386e55741a133d0304db50a0449e4..6e9b4575c8e92e4fcf08ddd2be071a590b424b4a 100644 --- a/~dev_rating/application/classes/Controller/Student/Index.php +++ b/~dev_rating/application/classes/Controller/Student/Index.php @@ -10,7 +10,7 @@ class Controller_Student_Index extends Controller_UserEnvi { $list = array(); foreach ($disciplines as $row) { $row['Title'] = $row['SubjectName']; - $row['Teachers'] = $this->getTeachersForDiscipline($row['ID']); + $row['Teachers'] = self::getTeachersForDiscipline($row['ID']); $row['Control'] = ($row['ExamType'] == 'exam') ? 'Ркзамен' : 'Зачет'; $row['ColorScheme'] = $colorsList[$this->getColor($row['Rate'], $row['MaxCurrentRate'], $row['ExamRate'])]; $list[] = $row; @@ -25,19 +25,21 @@ class Controller_Student_Index extends Controller_UserEnvi { $this->response->body($twig); } - protected function getTeachersForDiscipline($id) { + /** + * @param $id int discipline id + * @return array list of short-form names + */ + private static function getTeachersForDiscipline($id) { $teachers = Model_Teachers::ofDiscipline($id); - $teachersHandled = array(); $i = 0; - foreach ($teachers as $teacher) - { - $i++; - $teachersHandled[$i] = $teacher['LastName'].' '.UTF8::substr($teacher['FirstName'], 0, 1).'. '; - if(!empty($teacher['SecondName'])) - { - $teachersHandled[$i] .= UTF8::substr($teacher['SecondName'], 0, 1).'.'; - } + + $list = array(); + foreach ($teachers as $teacher) { + $name = $teacher['LastName'] . ' ' . UTF8::substr($teacher['FirstName'], 0, 1) . '. '; + if (!empty($teacher['SecondName'])) + $name .= UTF8::substr($teacher['SecondName'], 0, 1) . '.'; + $list[] = $name; } - return $teachersHandled; + return $list; } protected function getColor($rate, $current, $examRate)