Skip to content
Snippets Groups Projects
Commit e957653b authored by Steinberg R.B. (and Co)'s avatar Steinberg R.B. (and Co)
Browse files

Merge branch 'develop' of http://itlab.mmcs.sfedu.ru/git/grade-rating into develop

parents 9b82ee97 289a4ef2
Branches
Tags
No related merge requests found
......@@ -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
......
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
......@@ -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();
}
}
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