From 957fef488a85c50ab21f7f95e4277bac524f58b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A8=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=D0=B2?= <solidovic@gmail.com> Date: Sun, 19 Oct 2014 14:43:19 +0400 Subject: [PATCH] ... --- .../classes/Controller/Teacher/Discipline.php | 47 +++++++++++++++++- .../application/classes/DataArr/Students.php | 48 +------------------ .../application/classes/Model/Teacher/Map.php | 7 +++ .../teacher/discipline/EditStudents.twig | 1 + 4 files changed, 54 insertions(+), 49 deletions(-) diff --git a/~dev_rating/application/classes/Controller/Teacher/Discipline.php b/~dev_rating/application/classes/Controller/Teacher/Discipline.php index c9f6ee4c1..cb6ca4a51 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Discipline.php +++ b/~dev_rating/application/classes/Controller/Teacher/Discipline.php @@ -66,10 +66,53 @@ class Controller_Teacher_Discipline extends Controller_UserEnvi { $twig->User = $this->UserInfo; $twig->Discipline = $this->GetDisciplineInfo($db, $id); - $twig->Students = DataArray::factory('Students')->forDiscipline($this->UserInfo['TeacherID'], $id)->asArray(); $twig->GradesList = DataArray::factory('Grades')->common()->asArray(); $twig->StudyGroups = DataArray::factory('StudyGroups')->ordByGroups($twig->Discipline['GradeID'], $twig->Discipline['FacultyID'])->asArray(); - + + $students = $db->getStudentsForDiscipline($this->UserInfo['TeacherID'], $id); + $stdHandled = array(); + $attachStdHandled = array(); + $groupID = 0; $i = 0; $k = 0; + foreach($students as $row) { + if ($row['Type'] == 'attach'){ + $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'] = DataArray::factory('Students')->getDegreeTitle($row['Degree']); + $stdHandled[$i]['StdCount']; + } + $j = $stdHandled[$i]['StdCount'] += 1; + $stdHandled[$i][$j]['StudentID'] = $row['StudentID']; + $stdHandled[$i][$j]['LastName'] = $row['LastName']; + $stdHandled[$i][$j]['FirstName'] = $row['FirstName']; + $stdHandled[$i][$j]['SecondName'] = $row['SecondName']; + $stdHandled[$i][$j]['Type'] = $row['Type']; + } + + } + $twig->Students = $stdHandled; + $twig->AttachStudents = $attachStdHandled; + $this->response->body($twig); } diff --git a/~dev_rating/application/classes/DataArr/Students.php b/~dev_rating/application/classes/DataArr/Students.php index 364fd9323..c7af5bbdd 100644 --- a/~dev_rating/application/classes/DataArr/Students.php +++ b/~dev_rating/application/classes/DataArr/Students.php @@ -31,7 +31,7 @@ class DataArr_Students { return new DataArray_Result($this->generateArray($students)); } - protected function getDegreeTitle($degree) + public function getDegreeTitle($degree) { switch($degree) { @@ -72,52 +72,6 @@ class DataArr_Students { return $studentsHandled; } - public function forDiscipline($TeacherID, $DisciplineID) - { - $students = $this->model->getStudentsForDiscipline($TeacherID, $DisciplineID); - $stdHandled = array(); - $detachStdHandled = array(); - $groupID = 0; $i = 0; $k = 0; - foreach($students as $row) { - if ($row['Type'] == 'detach'){ - $k++; - $detachStdHandled['StdCount'] += 1; - $detachStdHandled[$k]['StudentID'] = $row['StudentID']; - $detachStdHandled[$k]['LastName'] = $row['LastName']; - $detachStdHandled[$k]['FirstName'] = $row['FirstName']; - $detachStdHandled[$k]['SecondName'] = $row['SecondName']; - $detachStdHandled[$k]['StudentID'] = $row['StudentID']; - $detachStdHandled[$k]['GroupID'] = $row['GroupID']; - $detachStdHandled[$k]['GradeID'] = $row['GradeID']; - $detachStdHandled[$k]['GradeNum'] = $row['GradeNum']; - $detachStdHandled[$k]['GroupNum'] = $row['GroupNum']; - $detachStdHandled[$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'] = $this->getDegreeTitle($row['Degree']); - $stdHandled[$i]['StdCount']; - } - $j = $stdHandled[$i]['StdCount'] += 1; - $stdHandled[$i][$j]['StudentID'] = $row['StudentID']; - $stdHandled[$i][$j]['LastName'] = $row['LastName']; - $stdHandled[$i][$j]['FirstName'] = $row['FirstName']; - $stdHandled[$i][$j]['SecondName'] = $row['SecondName']; - $stdHandled[$i][$j]['Type'] = $row['Type']; - } - - } - return new DataArray_Result($this->generateArray($students)); - } - public function NotAttendingDiscipline($GradeID, $GroupN, $FacultyID, $Last, $First, $Second, $DisciplineID) { $students = $this->model->getStudentsNotAttendingDiscipline($GradeID, $GroupN, $FacultyID, $Last, $First, $Second, $DisciplineID); diff --git a/~dev_rating/application/classes/Model/Teacher/Map.php b/~dev_rating/application/classes/Model/Teacher/Map.php index 67cd3dfc6..44b7fd8c9 100644 --- a/~dev_rating/application/classes/Model/Teacher/Map.php +++ b/~dev_rating/application/classes/Model/Teacher/Map.php @@ -4,6 +4,13 @@ class Model_Teacher_Map extends Model { + public function getStudentsForDiscipline($teacherID, $disciplineID) + { + $sql = "CALL `getStudentsForDiscipline`('$teacherID', '$disciplineID'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + + public function addModuleBonus($teacherID, $disciplineID) { $sql = "SELECT `AddModuleBonus`('$teacherID', '$disciplineID') AS `Num`;"; diff --git a/~dev_rating/application/views/teacher/discipline/EditStudents.twig b/~dev_rating/application/views/teacher/discipline/EditStudents.twig index 26a6f580a..e65d575b6 100644 --- a/~dev_rating/application/views/teacher/discipline/EditStudents.twig +++ b/~dev_rating/application/views/teacher/discipline/EditStudents.twig @@ -20,6 +20,7 @@ {% import 'teacher/discipline/EditStudents' as idx %} {% block map_content %} + <div class="StudentsList"> <input type="hidden" class="HiddenInputFacultyID" value="{{ Discipline.FacultyID }}"> <div class="AttachedStudentsList"> -- GitLab