diff --git a/db/Structure.sql b/db/Structure.sql index 91cd7209e4121d8a5f300e5074c2301f0dce3024..85f05a4cd2d326edc16522cd7f7a6186e1ac93b4 100644 --- a/db/Structure.sql +++ b/db/Structure.sql @@ -548,7 +548,9 @@ INSERT INTO `page_access` (`ID`, `Pagename`, `Bitmask`) VALUES (23, 'handler:Map', 6), (24, 'handler:Rating', 6), (25, 'handler:Settings', 7), -(26, 'teacher:exam', 6); +(26, 'teacher:exam', 6), +(27, 'dean_office:index', 7); +-- TODO: restrict dean's INSERT INTO `general_settings` (`ID`, `Val`, `ValS`) VALUES diff --git a/db/fix.sql b/db/fix.sql index 1e7ae43aecc97782fa9cbf82ac36910c64ffddc5..f392e5ba9733c658ddaaddf6e3dd86db82b7da6a 100644 --- a/db/fix.sql +++ b/db/fix.sql @@ -1,237 +1,7 @@ DELIMITER // - - - -DROP FUNCTION IF EXISTS AddSubmodule// -CREATE FUNCTION `AddSubmodule` ( `TeacherID` INT, - `ModuleID` INT, - `MaxRate` INT, - `Name` VARCHAR(200) charset utf8, - `Description` VARCHAR(200) charset utf8, - `ControlType` VARCHAR(30) charset utf8 - ) RETURNS int(11) - NO SQL -BEGIN - DECLARE checker INT; - - - SET checker = 0; - SELECT MAX(submodules.OrderNum) - INTO checker - FROM `submodules` - WHERE ModuleID = submodules.ModuleID - LIMIT 1; - IF checker IS NULL THEN - SET checker = 0; - END IF; - SET checker = checker + 1; - - IF Description = "" THEN - INSERT INTO `submodules` - ( submodules.ModuleID, submodules.MaxRate, submodules.OrderNum, submodules.Name, submodules.Description, submodules.Type ) - VALUES ( ModuleID, MaxRate, checker, Name, NULL, ControlType); - ELSE - INSERT INTO `submodules` - ( submodules.ModuleID, submodules.MaxRate, submodules.OrderNum, submodules.Name, submodules.Description, submodules.Type ) - VALUES ( ModuleID, MaxRate, checker, Name, Description, ControlType); - END IF; - - RETURN ( SELECT submodules.ID - FROM `submodules` - WHERE submodules.ModuleID = ModuleID AND - submodules.OrderNum = checker - LIMIT 1 - ); -END // - -DROP FUNCTION IF EXISTS AddModuleExtra// -CREATE FUNCTION `AddModuleExtra` ( `TeacherID` INT, - `DisciplineID` INT - ) RETURNS int(11) - NO SQL -BEGIN - DECLARE checker, vModule, vType, vGap INT; - IF NOT InternalIsTeacherAuthor(TeacherID,DisciplineID) - THEN - RETURN -1; - END IF; - - SET vType = -1; - SET checker = -1; - SELECT modules.ID - INTO checker - FROM `modules` - WHERE DisciplineID = modules.DisciplineID AND - modules.Type = 4 - LIMIT 1; - IF checker > 0 THEN - RETURN -2; - END IF; - - - INSERT INTO `modules` - ( modules.Name, modules.OrderNum, modules.DisciplineID, modules.Type ) - VALUES ( 'Добор баллов' , 2900666 , DisciplineID, 4 ); - - SET vModule = -1; - SELECT modules.ID, disciplines.ExamType - INTO vModule, vType - FROM `modules` - INNER JOIN `disciplines` ON disciplines.ID = modules.DisciplineID - WHERE DisciplineID = modules.DisciplineID AND - modules.Type = 4 - LIMIT 1; - IF vModule <= 0 THEN - RETURN -1; - END IF; - - SET vGap = -1; - IF vType = 1 THEN - SET vGap = 6; - END IF; - IF vType = 2 THEN - SET vGap = 30; - SET checker = AddSubmodule(TeacherID, vModule, vGap, '', NULL, 'LandmarkControl'); - END IF; - - SET checker = AddSubmodule(TeacherID, vModule, vGap, '', NULL, 'LandmarkControl'); - RETURN vModule; -END // - - -DROP FUNCTION IF EXISTS AddModule// -CREATE FUNCTION `AddModule` ( `TeacherID` INT, - `DisciplineID` INT, - `Name` VARCHAR(200) charset utf8 - ) RETURNS int(11) - NO SQL -BEGIN - DECLARE checker INT; - - IF NOT InternalIsTeacherAuthor(TeacherID,DisciplineID) - THEN - RETURN -1; - END IF; - - SET checker = 0; - SELECT MAX(modules.OrderNum) - INTO checker - FROM `modules` - WHERE DisciplineID = modules.DisciplineID AND - modules.Type != 1 - LIMIT 1; - IF checker IS NULL THEN - SET checker = 0; - END IF; - SET checker = checker + 1; - - - INSERT INTO `modules` - ( modules.Name, modules.OrderNum, modules.DisciplineID ) - VALUES ( Name , checker , DisciplineID ); - - - RETURN ( SELECT modules.ID - FROM `modules` - WHERE DisciplineID = modules.DisciplineID AND - checker = modules.OrderNum - LIMIT 1 - ); -END // - -ALTER TABLE `modules` CHANGE `Type` `Type` enum('regular','exam', 'bonus', 'extra') NOT NULL DEFAULT 'regular'// - - -DELETE FROM `rating_table` -WHERE rating_table.SubmoduleID IN - ( - SELECT submodules.ID - FROM `submodules` - INNER JOIN `modules` ON modules.ID = submodules.ModuleID - WHERE modules.Type = 2 - )// - - - -INSERT INTO `page_access` (`ID`, `Pagename`, `Bitmask`) VALUES (NULL, 'teacher:exam', '6')// - -ALTER TABLE `specializations` ADD `Code` varchar(12) NULL// - - --- SELECT modules.ID, AddSubmodule(disciplines.AuthorID, modules.ID, 40, '', NULL, 'LandmarkControl') AS '1' --- FROM `modules` --- INNER JOIN `disciplines` ON disciplines.ID = modules.DisciplineID --- WHERE modules.Type = 2 // - - - - -DROP PROCEDURE IF EXISTS fix_modules// -CREATE PROCEDURE fix_modules() -BEGIN - DECLARE checker INT; - DECLARE vid INT; - DECLARE vname INT; - -- this flag will be set to true when cursor reaches end of table - DECLARE exit_loop BOOLEAN; - -- Declare the cursor - DECLARE employee_cursor CURSOR FOR - SELECT modules.ID AS 'ID', disciplines.AuthorID - FROM `modules` - INNER JOIN `disciplines` ON disciplines.ID = modules.DisciplineID - WHERE modules.Type = 2; - - -- set exit_loop flag to true if there are no more rows - DECLARE CONTINUE HANDLER FOR NOT FOUND SET exit_loop = TRUE; - -- open the cursor - OPEN employee_cursor; - -- start looping - employee_loop: LOOP - -- read the name from next row into the variables - FETCH employee_cursor INTO vid, vname; - SET checker = AddSubmodule(vname, vid, 40, '', NULL, 'LandmarkControl'); - SET checker = AddSubmodule(vname, vid, 40, '', NULL, 'LandmarkControl'); - IF exit_loop THEN - CLOSE employee_cursor; - LEAVE employee_loop; - END IF; - END LOOP employee_loop; -END // - - DROP PROCEDURE IF EXISTS fix_modules2// - CREATE PROCEDURE fix_modules2() -BEGIN - DECLARE checker INT; - DECLARE vid INT; - DECLARE vname INT; - -- this flag will be set to true when cursor reaches end of table - DECLARE exit_loop BOOLEAN; - -- Declare the cursor - DECLARE employee_cursor CURSOR FOR - SELECT disciplines.ID AS 'ID', disciplines.AuthorID - FROM `disciplines`; - - -- set exit_loop flag to true if there are no more rows - DECLARE CONTINUE HANDLER FOR NOT FOUND SET exit_loop = TRUE; - -- open the cursor - OPEN employee_cursor; - -- start looping - employee_loop: LOOP - -- read the name from next row into the variables - FETCH employee_cursor INTO vid, vname; - SET checker = AddModuleExtra(vname, vid); - IF exit_loop THEN - CLOSE employee_cursor; - LEAVE employee_loop; - END IF; - END LOOP employee_loop; -END // - - - CALL fix_modules()// - CALL fix_modules2()// - DROP PROCEDURE IF EXISTS fix_modules// - DROP PROCEDURE IF EXISTS fix_modules2// +INSERT INTO `page_access` (`ID`, `Pagename`, `Bitmask`) VALUES +(27, 'dean_office:index', 7); +-- TODO: restrict dean's DELIMITER ; \ No newline at end of file diff --git a/~dev_rating/application/classes/Model/Teacher/Rating.php b/~dev_rating/application/classes/Model/Teacher/Rating.php index a57687d68f1e2239e9def1887eca760a2ece377e..02c4c36b2db40b96dc9b1b300a8bb7cda53510eb 100644 --- a/~dev_rating/application/classes/Model/Teacher/Rating.php +++ b/~dev_rating/application/classes/Model/Teacher/Rating.php @@ -61,4 +61,10 @@ class Model_Teacher_Rating extends Model return DB::query(Database::SELECT, $sql)->execute(); } + public function getDisciplinesForGroup($groupID) + { + $sql = "CALL `GetDisciplinesForGroup`($groupID)"; + return DB::query(Database::SELECT, $sql)->execute(); + } + }