From c744bf912563fbd3344826f4e0e70fba287f62eb Mon Sep 17 00:00:00 2001 From: PavelBegunkov <asml.silence@gmail.com> Date: Wed, 13 Jul 2016 18:43:09 +0300 Subject: [PATCH] Fix: incorrect aggregation of groups + delete debug --- .../classes/Controller/Handler/Students.php | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/~dev_rating/application/classes/Controller/Handler/Students.php b/~dev_rating/application/classes/Controller/Handler/Students.php index 68b5dbf92..70204e7fe 100644 --- a/~dev_rating/application/classes/Controller/Handler/Students.php +++ b/~dev_rating/application/classes/Controller/Handler/Students.php @@ -49,26 +49,20 @@ class Controller_Handler_Students extends Controller_Handler public function action_getGroups() { $facultyID = $this->post['facultyID']; $gradeID = $this->post['gradeNum']; + + $groupsHandled = []; if (($facultyID && $gradeID) != 0) { $groups = Model_Faculty::with($facultyID)->getGroups($gradeID); - $groupsHandled = []; - $i = $j = $id = 0; - foreach ($groups as $row) { - if ($id != $row['SpecID']) { - $i++; - $j = 0; - $id = $row['SpecID']; - } - $j++; - - $groupsHandled[$i]['SpecName'] = is_null($row['SpecName']) ? 'Без специализации' : $row['SpecName']; - $groupsHandled[$i]['SpecAbbr'] = is_null($row['SpecAbbr']) ? '' : $row['SpecAbbr']; - - $groupsHandled[$i]['ID'] = $row['ID']; - $groupsHandled[$i]['Num'] = $row['GroupNum']; - } - $this->response->body(json_encode($groupsHandled)); + + foreach ($groups as $row) + $groupsHandled[] = [ + 'ID' => $row['ID'], + 'Num' => $row['GroupNum'], + 'SpecName' => is_null($row['SpecName']) ? 'Без специализации' : $row['SpecName'], + 'SpecAbbr' => is_null($row['SpecAbbr']) ? '' : $row['SpecAbbr'], + ]; } + $this->response->body(json_encode($groupsHandled)); } private function groupByID($array) @@ -97,10 +91,4 @@ class Controller_Handler_Students extends Controller_Handler $this->action_getByGroup(); } - - public function action_debug() - { - - echo Debug::vars($group); - } } -- GitLab