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

Code refactoring, improved readability

parent 9eee737d
No related merge requests found
......@@ -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)
......
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