Skip to content
Snippets Groups Projects
Commit c744bf91 authored by PavelBegunkov's avatar PavelBegunkov
Browse files

Fix: incorrect aggregation of groups + delete debug

parent 5766b882
Branches
Tags
No related merge requests found
...@@ -49,26 +49,20 @@ class Controller_Handler_Students extends Controller_Handler ...@@ -49,26 +49,20 @@ class Controller_Handler_Students extends Controller_Handler
public function action_getGroups() { public function action_getGroups() {
$facultyID = $this->post['facultyID']; $facultyID = $this->post['facultyID'];
$gradeID = $this->post['gradeNum']; $gradeID = $this->post['gradeNum'];
$groupsHandled = [];
if (($facultyID && $gradeID) != 0) { if (($facultyID && $gradeID) != 0) {
$groups = Model_Faculty::with($facultyID)->getGroups($gradeID); $groups = Model_Faculty::with($facultyID)->getGroups($gradeID);
$groupsHandled = [];
$i = $j = $id = 0; foreach ($groups as $row)
foreach ($groups as $row) { $groupsHandled[] = [
if ($id != $row['SpecID']) { 'ID' => $row['ID'],
$i++; 'Num' => $row['GroupNum'],
$j = 0; 'SpecName' => is_null($row['SpecName']) ? 'Без специализации' : $row['SpecName'],
$id = $row['SpecID']; 'SpecAbbr' => is_null($row['SpecAbbr']) ? '' : $row['SpecAbbr'],
} ];
$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));
} }
$this->response->body(json_encode($groupsHandled));
} }
private function groupByID($array) private function groupByID($array)
...@@ -97,10 +91,4 @@ class Controller_Handler_Students extends Controller_Handler ...@@ -97,10 +91,4 @@ class Controller_Handler_Students extends Controller_Handler
$this->action_getByGroup(); $this->action_getByGroup();
} }
public function action_debug()
{
echo Debug::vars($group);
}
} }
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