diff --git a/~dev_rating/application/classes/Controller/Admin/Accounts.php b/~dev_rating/application/classes/Controller/Admin/Accounts.php index 2f6985dc5502b9df539908b2db438ac0e50c86a1..93cfbbcc0e6a8805bfed7efd38d6c9b187e0fd47 100644 --- a/~dev_rating/application/classes/Controller/Admin/Accounts.php +++ b/~dev_rating/application/classes/Controller/Admin/Accounts.php @@ -16,7 +16,7 @@ class Controller_Admin_Accounts extends Controller_UserEnvi { Cookie::set('fD', 'true'); $twig = Twig::factory('admin/accounts/codes'); $twig->Faculties = Model_Faculties::toArray(); - $twig->Grades = Model_Grades::create()->structured()->asArray(); + $twig->Grades = Model_Grades::toStructuredArray(); $twig->User = $this->UserInfo; $this->response->body($twig); } diff --git a/~dev_rating/application/classes/Controller/Admin/Students.php b/~dev_rating/application/classes/Controller/Admin/Students.php index b6d79ea8740416cf8f63c6b19c97114331cb12c8..44dd6b0a44b750048a089472ea7890e636093513 100644 --- a/~dev_rating/application/classes/Controller/Admin/Students.php +++ b/~dev_rating/application/classes/Controller/Admin/Students.php @@ -7,7 +7,7 @@ class Controller_Admin_Students extends Controller_UserEnvi { // VIEW $twig = Twig::factory('admin/students/index'); $twig->Faculties = Model_Faculties::toArray(); - $twig->Grades = Model_Grades::create()->structured()->asArray(); + $twig->Grades = Model_Grades::toStructuredArray(); $twig->User = $this->UserInfo; $this->response->body($twig); } @@ -16,7 +16,7 @@ class Controller_Admin_Students extends Controller_UserEnvi { { $twig = Twig::factory('admin/students/add'); $twig->Faculties = Model_Faculties::toArray(); - $twig->Grades = Model_Grades::create()->structured()->asArray(); + $twig->Grades = Model_Grades::toStructuredArray(); $twig->User = $this->UserInfo; $this->response->body($twig); } diff --git a/~dev_rating/application/classes/Controller/DeanOffice/Index.php b/~dev_rating/application/classes/Controller/DeanOffice/Index.php index efeee6903b31093ed842bcb8d650eb2cda729f92..10ce82756272a3c934b984349387192509fdceab 100644 --- a/~dev_rating/application/classes/Controller/DeanOffice/Index.php +++ b/~dev_rating/application/classes/Controller/DeanOffice/Index.php @@ -13,7 +13,7 @@ class Controller_DeanOffice_Index extends Controller_UserEnvi { $twig = Twig::factory('dean_office/index'); $model = new Model_Teacher_Map; - $twig->GradesList = Model_Grades::create()->common()->asArray(); + $twig->GradesList = Model_Grades::toArray(); $twig->User = $this->UserInfo; $this->response->body($twig); diff --git a/~dev_rating/application/classes/Controller/Teacher/Discipline.php b/~dev_rating/application/classes/Controller/Teacher/Discipline.php index bb7b97a72334efdda034655b07746277c6c8b07a..951564bef94dd11b2e3654997179425f442af5f1 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Discipline.php +++ b/~dev_rating/application/classes/Controller/Teacher/Discipline.php @@ -9,7 +9,7 @@ class Controller_Teacher_Discipline extends Controller_UserEnvi { $twig->User = $this->UserInfo; $twig->FacultiesList = Model_Faculties::toArray(); $twig->SubjectsList = Model_Subjects::create()->byFaculty($this->UserInfo['FacultyID'])->asArray(); - $twig->GradesList = Model_Grades::create()->common()->asArray(); + $twig->GradesList = Model_Grades::toArray(); $this->response->body($twig); } @@ -25,7 +25,7 @@ class Controller_Teacher_Discipline extends Controller_UserEnvi { //$twig->FacultiesList = Model_Faculties::create()->common()->asArray(); $twig->Discipline = $this->GetDisciplineInfo($db, $id); $twig->SubjectsList = Model_Subjects::create()->byFaculty($this->UserInfo['FacultyID'])->asArray(); - $twig->GradesList = Model_Grades::create()->common()->asArray(); + $twig->GradesList = Model_Grades::toArray(); $this->response->body($twig); } @@ -66,7 +66,7 @@ class Controller_Teacher_Discipline extends Controller_UserEnvi { $twig->User = $this->UserInfo; $twig->Discipline = $this->GetDisciplineInfo($db, $id); - $twig->GradesList = Model_Grades::create()->common()->asArray(); + $twig->GradesList = Model_Grades::toArray(); $twig->Groups = Model_Groups::create()->ordByGroups($twig->Discipline['GradeID'], $twig->Discipline['FacultyID'])->asArray(); $students = $db->getStudentsForDiscipline($id); diff --git a/~dev_rating/application/classes/Model/Grades.php b/~dev_rating/application/classes/Model/Grades.php index ba0f1adccb8f7ff87efb3298979d0149479cc96f..d1a6adc2d9c1eddf108d8ca4e7a2e0f491937e79 100644 --- a/~dev_rating/application/classes/Model/Grades.php +++ b/~dev_rating/application/classes/Model/Grades.php @@ -2,17 +2,13 @@ class Model_Grades extends Model { - public static function create() { - return new self(); - } - - public function getGrades() { + public static function getGrades() { $sql = "CALL `GetGrades`();"; return DB::query(Database::SELECT, $sql)->execute(); } - public function common() { - $grades = $this->GetGrades(); + public static function toArray() { + $grades = self::GetGrades(); $list = array(); foreach ($grades as $row) { @@ -23,7 +19,7 @@ class Model_Grades extends Model $list[] = $row; } - return new DataArray_Result($list); + return $list; } public static function getDegreeTitle($degree) { @@ -39,8 +35,9 @@ class Model_Grades extends Model } } - public function structured() { - $grades = $this->common()->asArray(); + /** @return array an array with elements, grouped by grades. */ + public static function toStructuredArray() { + $grades = self::toArray(); $list = array(); $degree = 'null'; $i = 0; @@ -55,6 +52,6 @@ class Model_Grades extends Model $list[$i]['Grades'][] = $row; } - return new DataArray_Result($list); + return $list; } }