Skip to content
Snippets Groups Projects
Commit eab0259d authored by Finlay White's avatar Finlay White :speech_balloon:
Browse files

removal working

parent 98e9968f
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,7 @@ fname varchar(35), ...@@ -21,7 +21,7 @@ fname varchar(35),
lname varchar(35), lname varchar(35),
-- The UK Government Data Standards Catalogue reccomends 35 characters for each the first name and last name -- The UK Government Data Standards Catalogue reccomends 35 characters for each the first name and last name
bday date, bday date,
dayjoined date DEFAULT CURDATE() , dayjoined date ,
parentsID varchar(40), parentsID varchar(40),
groupID varchar(40), groupID varchar(40),
FOREIGN KEY (parentsID) REFERENCES Parents(parentID) FOREIGN KEY (parentsID) REFERENCES Parents(parentID)
...@@ -72,12 +72,11 @@ CREATE TABLE `Badge`( ...@@ -72,12 +72,11 @@ CREATE TABLE `Badge`(
CREATE TABLE `WaitList`( CREATE TABLE `WaitList`(
studentID varchar(40) unique, studentID varchar(40) unique,
SessionID varchar(40), groupID varchar(40),
dateJoined date, dateJoined date,
dateRemoved date, dateRemoved date,
ageGroup int(1), ageGroup int(1),
FOREIGN KEY (studentID) REFERENCES Students(studentID), FOREIGN KEY (studentID) REFERENCES Students(studentID));
FOREIGN KEY (SessionID) REFERENCES Sessions(SessionID));
...@@ -226,16 +225,15 @@ drop procedure if exists `applyToGroup`; ...@@ -226,16 +225,15 @@ drop procedure if exists `applyToGroup`;
delimiter $$ delimiter $$
CREATE PROCEDURE applyToGroup( CREATE PROCEDURE applyToGroup(
IN studentID varchar(40), IN studentID varchar(40),
IN SessionID varchar(255), IN groupID varchar(40))
IN ageGroup int(1))
BEGIN BEGIN
DECLARE EXIT HANDLER FOR 1062 DECLARE EXIT HANDLER FOR 1062
BEGIN BEGIN
SELECT 'This student is already on a wait list' as ERROR ; SELECT 'This student is already on a wait list' as ERROR ;
END; END;
INSERT INTO WaitList(StudentID,SessionID,dateJoined,ageGroup) values INSERT INTO WaitList(StudentID,groupID,dateJoined) values
(StudentID,SessionID,CURDATE(),ageGroup); (StudentID,groupID,CURDATE());
END$$ END$$
DELIMITER ; DELIMITER ;
...@@ -357,19 +355,38 @@ CREATE PROCEDURE addToGroup( ...@@ -357,19 +355,38 @@ CREATE PROCEDURE addToGroup(
IN grapeID varchar(40)) IN grapeID varchar(40))
BEGIN BEGIN
select count(distinct volunteerID) into @noOfVols from volunteerattendance as v0 DECLARE toad INT DEFAULT 0;
DECLARE a INT Default 0;
select count(distinct volunteerID) *(SELECT ageGroup from Sessions where groupID=grapeID limit 1) into @maxstu from volunteerattendance as v0
where grapeID in (select groupID from Sessions as s0 where grapeID in (select groupID from Sessions as s0
where v0.sessionID = s0.sessionID And where v0.sessionID = s0.sessionID And
date_add(s0.OccuredOn, interval 14 day) > CURDATE() = 1) ; date_add(s0.OccuredOn, interval 7 day) > CURDATE() = 1) ;
select count(*)*(SELECT ageGroup from Sessions where groupID=grapeID limit 1)
from students as stu0 where grapeID in
(select groupID from sessions as s2 where stu0.studentID in
(select studentID from StudentAttendance as att0 where stu0.studentID=att0.StudentID));
-- select @noOfStus;
-- UPDATE WaitList as wl0,students as stu2 select count(*) into @currentStu
from students as stu0 where grapeID in
(select groupID from sessions as s2 where stu0.studentID in
(select studentID from StudentAttendance as att0 where stu0.studentID=att0.StudentID));
set toad = @maxstu - @currentStu;
if toad is not null and toad >0 then
simple_loop : LOOP
SET a=a+1;
select studentID
from waitlist
where (dateRemoved is null)
order by dateJoined asc limit 1 into @theChosenOnes;
UPDATE WaitList as wl0,students as stu2
SET stu2.groupID=grapeID,wl0.dateRemoved=CURDATE() where wl0.studentID = @theChosenOnes;
IF a=toad THEN
LEAVE simple_loop;
END IF;
END LOOP simple_loop;
end if;
-- UPDATE WaitList as wl0,students as stu2
-- SET stu2.groupID=grapeID,wl0.dateRemoved=CURDATE() where stu2.studentID in (@theChosenOnes);
-- UPDATE student set groupID =groupID where true;
END$$ END$$
DELIMITER ; DELIMITER ;
...@@ -438,20 +455,30 @@ call addParent("jeff","Jones","email@realemail.com","veryStrongPassw0rd",0235825 ...@@ -438,20 +455,30 @@ call addParent("jeff","Jones","email@realemail.com","veryStrongPassw0rd",0235825
call addStudent("bobby","jones",'2012-2-11','8e301d6e513165a9c0b6b9a2b10c8305',"EXTRASTRONGPASSWORD"); call addStudent("bobby","jones",'2012-2-11','8e301d6e513165a9c0b6b9a2b10c8305',"EXTRASTRONGPASSWORD");
call addBadge("real badge","this is a totally real badge"); call addBadge("real badge","this is a totally real badge");
call addStudent("timothy","jones",'2002-2-11','8e301d6e513165a9c0b6b9a2b10c8305',"EXTREMELYSTRONGPASSWORD"); call addStudent("timothy","jones",'2002-2-11','8e301d6e513165a9c0b6b9a2b10c8305',"EXTREMELYSTRONGPASSWORD");
call addStudent("samantha","jones",'2012-2-11','8e301d6e513165a9c0b6b9a2b10c8305','superSTRONGPASSWORD');
call addStudent("tom","jones",'2012-2-11','8e301d6e513165a9c0b6b9a2b10c8305','superSTRONGPASSWORD');
call viewstudent('');
select * from students;
call addVolunteer("timothy","jones",'bob@bbc.co.uk','8e301d6e513165a9c0b6b9a2b10c8305',"0777008913"); call addVolunteer("timothy","jones",'bob@bbc.co.uk','8e301d6e513165a9c0b6b9a2b10c8305',"0777008913");
call applytogroup('b6e14bcdd6a79c8f8cd9fcef3be5f00b', '41');
call applytogroup('031f0ba110c9683bf4cf5d2836b32a95',41);
call updateSG('419fd9859978a9bf79df4ff16c99c5f9',"2020-04-09"); call updateSG('419fd9859978a9bf79df4ff16c99c5f9',"2020-04-09");
call updateDBS('419fd9859978a9bf79df4ff16c99c5f9',"2021-09-09"); call updateDBS('419fd9859978a9bf79df4ff16c99c5f9',"2021-09-09");
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-02-03',8,'41'); call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-02-03',3,'41');
call ReviewSession(md5('2023-02-03'),"it was ok","idk"); call ReviewSession(md5('2023-02-03'),"it was ok","idk");
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-01-03',8,'41');
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-01-03',3,'41');
call ReviewSession(md5('2023-01-03'),"it was ok","idk"); call ReviewSession(md5('2023-01-03'),"it was ok","idk");
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2022-11-03',8,'41'); call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2022-11-03',3,'41');
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-04-16',8,'41'); call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-04-16',3,'41');
CALL STUDENTATTENDS('562fe5b6c65003a11148594678c42b90','94b21f931d888fefd4da7a07c01dff4a'); CALL STUDENTATTENDS('562fe5b6c65003a11148594678c42b90','94b21f931d888fefd4da7a07c01dff4a');
call studentattends('313b6d9a06c3a0618f72ec75c082b6a4','94b21f931d888fefd4da7a07c01dff4a'); call studentattends('313b6d9a06c3a0618f72ec75c082b6a4','94b21f931d888fefd4da7a07c01dff4a');
call viewVolunteer(''); call viewVolunteer('');
select * from sessions; select * from sessions;
select * from students; select * from waitlist;
call viewCheckExpiries(); call viewCheckExpiries();
call addToGroup('41'); call addToGroup('41');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment