Skip to content
Snippets Groups Projects
Commit f552aa01 authored by xamgore's avatar xamgore
Browse files

Reduced inner conditions

parent 898c14e6
Branches
Tags
No related merge requests found
......@@ -88,67 +88,45 @@ class Controller_Teacher_Discipline extends Controller_UserEnvironment {
$twig->GradesList = Model_Grades::toArray();
$twig->GroupsList = Model_Faculty::with($discipline->facultyID)->getGroups($discipline->gradeID);
$students = Model_Students::ofDiscipline($id);
$stdHandled = array();
$attachStdHandled = array();
$groupID = 0;
$i = 0;
$k = 0;
$n = 0;
$j = 0;
foreach($students as $row) {
if ($row['AttachType'] == 'attach'){
if ($row['GroupID'] != $groupID) {
$groupID = $row['GroupID'];
$k++;
$n = 0;
$attachStdHandled[$k]['GroupID'] = $row['GroupID'];
$attachStdHandled[$k]['GradeID'] = $row['GradeID'];
$attachStdHandled[$k]['GradeNum'] = $row['GradeNum'];
$attachStdHandled[$k]['GroupNum'] = $row['GroupNum'];
$attachStdHandled[$k]['Degree'] = Model_Grades::getDegreeTitle($row['Degree']);
}
$n++;
$attachStdHandled[$k]['students'][$n]['ID'] = $row['ID'];
$attachStdHandled[$k]['students'][$n]['LastName'] = $row['LastName'];
$attachStdHandled[$k]['students'][$n]['FirstName'] = $row['FirstName'];
$attachStdHandled[$k]['students'][$n]['SecondName'] = $row['SecondName'];
$attachStdHandled[$k]['students'][$n]['AttachType'] = $row['AttachType'];
// $k++;
// $attachStdHandled['StdCount'] += 1;
// $attachStdHandled[$k]['StudentID'] = $row['StudentID'];
// $attachStdHandled[$k]['LastName'] = $row['LastName'];
// $attachStdHandled[$k]['FirstName'] = $row['FirstName'];
// $attachStdHandled[$k]['SecondName'] = $row['SecondName'];
// $attachStdHandled[$k]['StudentID'] = $row['StudentID'];
// $attachStdHandled[$k]['GroupID'] = $row['GroupID'];
// $attachStdHandled[$k]['GradeID'] = $row['GradeID'];
// $attachStdHandled[$k]['GradeNum'] = $row['GradeNum'];
// $attachStdHandled[$k]['GroupNum'] = $row['GroupNum'];
// $attachStdHandled[$k]['Degree'] = $row['Degree'];
}
else
{
if ($row['GroupID'] != $groupID) {
$groupID = $row['GroupID'];
$i++;
$j = 0;
$stdHandled[$i]['GroupID'] = $row['GroupID'];
$stdHandled[$i]['GradeID'] = $row['GradeID'];
$stdHandled[$i]['GradeNum'] = $row['GradeNum'];
$stdHandled[$i]['GroupNum'] = $row['GroupNum'];
$stdHandled[$i]['Degree'] = Model_Grades::getDegreeTitle($row['Degree']);
$groupID = $i = $k = $n = $j = 0;
$students = Model_Students::ofDiscipline($id);
foreach ($students as $row) {
if ($row['GroupID'] != $groupID) {
$groupID = $row['GroupID'];
$title = [
'GroupID' => $row['GroupID'],
'GradeID' => $row['GradeID'],
'GradeNum' => $row['GradeNum'],
'GroupNum' => $row['GroupNum'],
'Degree' => Model_Grades::getDegreeTitle($row['Degree']),
];
if ($row['AttachType'] == 'attach') {
$attachStdHandled[++$k] = $title;
} else {
$stdHandled[++$i] = $title;
}
$j++;
$stdHandled[$i]['students'][$j]['ID'] = $row['ID'];
$stdHandled[$i]['students'][$j]['LastName'] = $row['LastName'];
$stdHandled[$i]['students'][$j]['FirstName'] = $row['FirstName'];
$stdHandled[$i]['students'][$j]['SecondName'] = $row['SecondName'];
$stdHandled[$i]['students'][$j]['AttachType'] = $row['AttachType'];
}
$list = [
'LastName' => $row['LastName'],
'FirstName' => $row['FirstName'],
'SecondName' => $row['SecondName'],
'AttachType' => $row['AttachType'],
'ID' => $row['ID'],
];
if ($row['AttachType'] == 'attach') {
$attachStdHandled[$k]['students'][] = $list;
} else {
$stdHandled[$i]['students'][] = $list;
}
}
$twig->Groups = $stdHandled;
$twig->GroupsAttached = $attachStdHandled;
......
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