Skip to content
Snippets Groups Projects
Commit 6f7dc3dd authored by xamgore's avatar xamgore
Browse files

Code refactoring, improved readability

parent 9eee737d
Branches
Tags
No related merge requests found
...@@ -10,7 +10,7 @@ class Controller_Student_Index extends Controller_UserEnvi { ...@@ -10,7 +10,7 @@ class Controller_Student_Index extends Controller_UserEnvi {
$list = array(); $list = array();
foreach ($disciplines as $row) { foreach ($disciplines as $row) {
$row['Title'] = $row['SubjectName']; $row['Title'] = $row['SubjectName'];
$row['Teachers'] = $this->getTeachersForDiscipline($row['ID']); $row['Teachers'] = self::getTeachersForDiscipline($row['ID']);
$row['Control'] = ($row['ExamType'] == 'exam') ? 'Экзамен' : 'Зачет'; $row['Control'] = ($row['ExamType'] == 'exam') ? 'Экзамен' : 'Зачет';
$row['ColorScheme'] = $colorsList[$this->getColor($row['Rate'], $row['MaxCurrentRate'], $row['ExamRate'])]; $row['ColorScheme'] = $colorsList[$this->getColor($row['Rate'], $row['MaxCurrentRate'], $row['ExamRate'])];
$list[] = $row; $list[] = $row;
...@@ -25,19 +25,21 @@ class Controller_Student_Index extends Controller_UserEnvi { ...@@ -25,19 +25,21 @@ class Controller_Student_Index extends Controller_UserEnvi {
$this->response->body($twig); $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); $teachers = Model_Teachers::ofDiscipline($id);
$teachersHandled = array(); $i = 0;
foreach ($teachers as $teacher) $list = array();
{ foreach ($teachers as $teacher) {
$i++; $name = $teacher['LastName'] . ' ' . UTF8::substr($teacher['FirstName'], 0, 1) . '. ';
$teachersHandled[$i] = $teacher['LastName'].' '.UTF8::substr($teacher['FirstName'], 0, 1).'. '; if (!empty($teacher['SecondName']))
if(!empty($teacher['SecondName'])) $name .= UTF8::substr($teacher['SecondName'], 0, 1) . '.';
{ $list[] = $name;
$teachersHandled[$i] .= UTF8::substr($teacher['SecondName'], 0, 1).'.';
}
} }
return $teachersHandled; return $list;
} }
protected function getColor($rate, $current, $examRate) protected function getColor($rate, $current, $examRate)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment