diff --git a/~dev_rating/application/classes/Controller/Admin/Accounts.php b/~dev_rating/application/classes/Controller/Admin/Accounts.php index 2f2d809c27194b977dacb9225c087cd545e4d58b..3646f83414bb57d42d124eecd984d356f7f23424 100644 --- a/~dev_rating/application/classes/Controller/Admin/Accounts.php +++ b/~dev_rating/application/classes/Controller/Admin/Accounts.php @@ -10,7 +10,7 @@ class Controller_Admin_Accounts extends Controller_Environment_Admin Cookie::set('fD', 'true'); $this->twig->set([ 'Faculties' => Model_Faculties::load(), - 'Grades' => Model_Grades::toStructuredArray(), + 'Grades' => Model_Grades::groupByDegree(), ])->set_filename('admin/accounts/codes'); } } diff --git a/~dev_rating/application/classes/Controller/Admin/Students.php b/~dev_rating/application/classes/Controller/Admin/Students.php index b7cfcb695c91bc646b5286ce4f00169b5d8aee66..563ecf59b947fc4ed8f616cd10d235836b9153a0 100644 --- a/~dev_rating/application/classes/Controller/Admin/Students.php +++ b/~dev_rating/application/classes/Controller/Admin/Students.php @@ -5,14 +5,14 @@ class Controller_Admin_Students extends Controller_Environment_Admin public function action_index() { $this->twig->set([ 'Faculties' => Model_Faculties::load(), - 'Grades' => Model_Grades::toStructuredArray(), + 'Grades' => Model_Grades::groupByDegree(), ])->set_filename('admin/students/index'); } public function action_add() { $this->twig->set([ 'Faculties' => Model_Faculties::load(), - 'Grades' => Model_Grades::toStructuredArray(), + 'Grades' => Model_Grades::groupByDegree(), ])->set_filename('admin/students/add'); } diff --git a/~dev_rating/application/classes/Controller/DeanOffice/Students.php b/~dev_rating/application/classes/Controller/DeanOffice/Students.php index 6321ab847de71627ed6d99693870a237637f3d50..8007072c91b0a157786e02908f2986bd31fd927b 100644 --- a/~dev_rating/application/classes/Controller/DeanOffice/Students.php +++ b/~dev_rating/application/classes/Controller/DeanOffice/Students.php @@ -6,7 +6,7 @@ class Controller_DeanOffice_Students extends Controller_Environment_DeanOffice public function action_index() { $this->twig->set([ 'Faculties' => Model_Faculties::load(), - 'Grades' => Model_Grades::toStructuredArray(), + 'Grades' => Model_Grades::groupByDegree(), ])->set_filename(static::DEAN . '/students/index'); } diff --git a/~dev_rating/application/classes/Model/Grades.php b/~dev_rating/application/classes/Model/Grades.php index c46125cc3ee8c2ffed60dfe9da89f74c03f67959..94d528cf9a0069777aafa3b865790be3a1d6b2ff 100644 --- a/~dev_rating/application/classes/Model/Grades.php +++ b/~dev_rating/application/classes/Model/Grades.php @@ -35,21 +35,13 @@ class Model_Grades extends Model } } - /** @return array an array with elements, grouped by grades. */ - public static function toStructuredArray() { - $grades = self::toArray(); + /** @return array */ + public static function groupByDegree() { $list = []; - $degree = 'null'; - $i = 0; - foreach ($grades as $row) { - if ($degree != $row['Degree']) { - $degree = $row['Degree']; - $i++; - } - - $list[$i]['Title'] = RusLang::tr($row['Degree']); - $list[$i]['Grades'][] = $row; + foreach (self::getGrades() as $row) { + $degree = $row['Degree']; + $list[$degree][] = $row; } return $list; diff --git a/~dev_rating/application/views/admin/accounts/codes.twig b/~dev_rating/application/views/admin/accounts/codes.twig index 3aff72706fa8b7a35af1266c697546a919111b41..04b2b049e73767afaebcf442f5a9886752020476 100644 --- a/~dev_rating/application/views/admin/accounts/codes.twig +++ b/~dev_rating/application/views/admin/accounts/codes.twig @@ -48,12 +48,12 @@ <div class="step_body"> <select id="gradeSelect"> <option value="0">— Курс —</option> - {% for Degree in Grades %} - <optgroup label="{{ Degree.Title }}"> - {% for Grade in Degree.Grades %} - <option value="{{ Grade.ID }}">{{ Grade.Num }} курс</option> - {% endfor %} - </optgroup> + {% for Title, Degree in Grades %} + <optgroup label="{{ Rus[Title] }}"> + {% for Grade in Degree %} + <option value="{{ Grade.ID }}">{{ Grade.Num }} курс</option> + {% endfor %} + </optgroup> {% endfor %} </select> </div> diff --git a/~dev_rating/application/views/admin/students/add.twig b/~dev_rating/application/views/admin/students/add.twig index 40a1b2a852c6800e3907aa8bea743a4f7bbad812..2362fc0c32827a64bb1ae95eaf985d94b6933120 100644 --- a/~dev_rating/application/views/admin/students/add.twig +++ b/~dev_rating/application/views/admin/students/add.twig @@ -44,12 +44,12 @@ </select> <select id="gradeSelect"> <option value="0">— Курс —</option> - {% for Degree in Grades %} - <optgroup label="{{ Degree.Title }}"> - {% for Grade in Degree.Grades %} - <option value="{{ Grade.ID }}">{{ Grade.Num }} курс</option> - {% endfor %} - </optgroup> + {% for Title, Degree in Grades %} + <optgroup label="{{ Rus[Title] }}"> + {% for Grade in Degree %} + <option value="{{ Grade.ID }}">{{ Grade.Num }} курс</option> + {% endfor %} + </optgroup> {% endfor %} </select> <select id="groupSelect"> diff --git a/~dev_rating/application/views/admin/students/index.twig b/~dev_rating/application/views/admin/students/index.twig index 3de43e198dfa18989c49fb3f28a8f51f6619e7bd..62e35b9b8e25f520a7cbfd1f8dbbb2c2ae1b6e56 100644 --- a/~dev_rating/application/views/admin/students/index.twig +++ b/~dev_rating/application/views/admin/students/index.twig @@ -35,12 +35,12 @@ <div class='filter'> <select id="gradeSelect"> <option value="0">— Курс —</option> - {% for Degree in Grades %} - <optgroup label="{{ Degree.Title }}"> - {% for Grade in Degree.Grades %} - <option value="{{ Grade.ID }}">{{ Grade.Num }} курс</option> - {% endfor %} - </optgroup> + {% for Title, Degree in Grades %} + <optgroup label="{{ Rus[Title] }}"> + {% for Grade in Degree %} + <option value="{{ Grade.ID }}">{{ Grade.Num }} курс</option> + {% endfor %} + </optgroup> {% endfor %} </select> </div> diff --git a/~dev_rating/application/views/dean_office/students/index.twig b/~dev_rating/application/views/dean_office/students/index.twig index e778ec44a69731fdc6b18bb4507f1f1a179d535e..faf58bdcdd66859fcbb3175e28771f671c547c4e 100644 --- a/~dev_rating/application/views/dean_office/students/index.twig +++ b/~dev_rating/application/views/dean_office/students/index.twig @@ -25,9 +25,9 @@ <div class='filter'> <select id="gradeSelect"> <option value="0">— Курс —</option> - {% for Degree in Grades %} - <optgroup label="{{ Degree.Title }}"> - {% for Grade in Degree.Grades %} + {% for Title, Degree in Grades %} + <optgroup label="{{ Rus[Title] }}"> + {% for Grade in Degree %} <option value="{{ Grade.ID }}">{{ Grade.Num }} курс</option> {% endfor %} </optgroup>