From d51930f4012f68868fcc55adb4e2ad1097df2a1c Mon Sep 17 00:00:00 2001 From: RomanSteinberg <romanofficial@yandex.ru> Date: Mon, 9 Feb 2015 17:40:51 +0300 Subject: [PATCH] FIX: order modules for session page --- db/StoredProcedures.sql | 20 +++++++++++++++++-- .../classes/Controller/Teacher/Rating.php | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/db/StoredProcedures.sql b/db/StoredProcedures.sql index e1315c3b5..c6c3220ba 100644 --- a/db/StoredProcedures.sql +++ b/db/StoredProcedures.sql @@ -2071,10 +2071,26 @@ BEGIN DisciplineID = modules.DisciplineID LEFT JOIN `rating_table` ON submodules.ID = rating_table.SubmoduleID AND StudentID = rating_table.StudentID - ORDER BY modules.OrderNum ASC, + ORDER BY OrderModuleTypesForSession(modules.Type) ASC, submodules.OrderNum ASC; END // +DROP FUNCTION IF EXISTS OrderModuleTypesForSession// +CREATE FUNCTION `OrderModuleTypesForSession` ( IN `ModuleType` INT + ) RETURNS INT(3) + NO SQL +BEGIN + DECLARE Res INT; + SET Res = 0; + IF ModuleType = 'extra' THEN SET Res = 1; + ELSEIF ModuleType = 'exam' THEN SET Res = 2; + ELSEIF ModuleType = 'bonus' THEN SET Res = 3; + ELSE SET Res = 4; + END IF; + + RETURN Res; +END // + DROP PROCEDURE IF EXISTS GetMapForDiscipline// @@ -2139,7 +2155,7 @@ BEGIN INNER JOIN `subjects` ON disciplines.SubjectID = subjects.ID WHERE modules.DisciplineID = DisciplineID AND (modules.Type = 4 OR modules.Type = 2) - ORDER BY modules.OrderNum ASC, + ORDER BY OrderModuleTypesForSession(modules.Type) ASC, submodules.OrderNum ASC; END IF; END // diff --git a/~dev_rating/application/classes/Controller/Teacher/Rating.php b/~dev_rating/application/classes/Controller/Teacher/Rating.php index 630af019b..3842b528e 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Rating.php +++ b/~dev_rating/application/classes/Controller/Teacher/Rating.php @@ -232,7 +232,7 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $twig = Twig::factory("teacher/".$page_type); //TODO: validate twig $id = $this->request->param('id'); $disciplineInfo = $this->getDisciplineInformation($id); - $structureHandled = $this->getStructure($id, $page_type); + $structureHandled = $this->getStructure($id, $page_type); // Студенты и их баллы $students = $this->model_rating->GetStudentsForRating($this->UserInfo['TeacherID'], $id); -- GitLab