diff --git a/~dev_rating/application/classes/Controller/Handler/Students.php b/~dev_rating/application/classes/Controller/Handler/Students.php index 68b5dbf9247fdd1b29cab679cc46f1db06b9f892..70204e7fe7d162899255522cb693896e6c5b8f8b 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); - } }