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
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);
}
}
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