diff --git a/~dev_rating/application/classes/Controller/Student/Index.php b/~dev_rating/application/classes/Controller/Student/Index.php index d7e5c353c1fbd5fa39bee9cad4f4ec196bc5bb58..015c3c89dc8386e55741a133d0304db50a0449e4 100644 --- a/~dev_rating/application/classes/Controller/Student/Index.php +++ b/~dev_rating/application/classes/Controller/Student/Index.php @@ -2,41 +2,29 @@ class Controller_Student_Index extends Controller_UserEnvi { - public function action_index() - { + public function action_index() { $student_id = $this->UserInfo['StudentID']; $disciplines = Model_Disciplines::ofStudent($student_id); - - $i = 0; $colorsList = array('Undefined', 'ECTS-F', 'ECTS-FX', 'ECTS-E', 'ECTS-D', 'ECTS-C', 'ECTS-B', 'ECTS-A'); - foreach($disciplines as $row) - { - $i++; - $disciplinesHandled[$i]['ID'] = $row['ID']; - if($row['ExamType'] == 'exam') - { - $disciplinesHandled[$i]['Control'] = 'Ркзамен'; - } - elseif($row['ExamType'] == 'credit') - { - $disciplinesHandled[$i]['Control'] = 'Зачет'; - } - $disciplinesHandled[$i]['Teachers'] = $this->getTeachersForDiscipline($row['ID']); - $disciplinesHandled[$i]['Title'] = $row['SubjectName']; - $disciplinesHandled[$i]['Rate'] = $row['Rate']; - $disciplinesHandled[$i]['MaxCurrentRate'] = $row['MaxCurrentRate']; - $disciplinesHandled[$i]['ColorScheme'] = $colorsList[$this->getColor($row['Rate'], $row['MaxCurrentRate'], $row['ExamRate'])]; + + $list = array(); + foreach ($disciplines as $row) { + $row['Title'] = $row['SubjectName']; + $row['Teachers'] = $this->getTeachersForDiscipline($row['ID']); + $row['Control'] = ($row['ExamType'] == 'exam') ? 'Ркзамен' : 'Зачет'; + $row['ColorScheme'] = $colorsList[$this->getColor($row['Rate'], $row['MaxCurrentRate'], $row['ExamRate'])]; + $list[] = $row; } $twig = Twig::factory('student/index'); - if ($i != 0) - $twig->disciplines = $disciplinesHandled; + if (count($disciplines) > 0) + $twig->disciplines = $list; $twig->User = $this->UserInfo; $twig->Semester = $this->SemesterInfo; $twig->SemesterList = Model_Semesters::create()->getList(); $this->response->body($twig); } - + protected function getTeachersForDiscipline($id) { $teachers = Model_Teachers::ofDiscipline($id); $teachersHandled = array(); $i = 0; @@ -50,7 +38,7 @@ class Controller_Student_Index extends Controller_UserEnvi { } } return $teachersHandled; - } + } protected function getColor($rate, $current, $examRate) {