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

viewbadges

parent eab0259d
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ fname varchar(35),
lname varchar(35),
-- The UK Government Data Standards Catalogue reccomends 35 characters for each the first name and last name
bday date,
dayjoined date ,
dayjoined date DEFAULT now(),
parentsID varchar(40),
groupID varchar(40),
FOREIGN KEY (parentsID) REFERENCES Parents(parentID)
......@@ -82,13 +82,17 @@ CREATE TABLE `Badge`(
DROP TABLE IF EXISTS `BadgeAwarded`;
CREATE TABLE `BadgeAwarded`(
awardedto varchar(40),
evidence varchar(1000),
awardedby varchar(40),
Badgeawarded varchar(40),
dateAwarded date,
isAwarded boolean,
isAwarded int(3),
-- isAwarded is to review applications
-- 2 means not reviewed
-- 1 means successful applications
-- 0 means fail
FOREIGN KEY (awardedto) REFERENCES Students(studentID),
FOREIGN KEY (awardedby) REFERENCES Volunteers(VolunteerID),
FOREIGN KEY (Badgeawarded) REFERENCES Badge(BadgeID)
......@@ -356,7 +360,7 @@ CREATE PROCEDURE addToGroup(
BEGIN
DECLARE toad INT DEFAULT 0;
DECLARE a INT Default 0;
DECLARE x 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
......@@ -368,25 +372,25 @@ select count(distinct volunteerID) *(SELECT ageGroup from Sessions where groupID
(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;
-- toad reprisents how many students the program should add off the WaitList
-- the next loop adds a student to the group from the waitlist equal
-- to the amount of
if toad is not null and toad >0 then
simple_loop : LOOP
SET a=a+1;
select studentID
from waitlist
adding_loop : LOOP
SET x=x+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;
-- test
IF x=toad THEN
LEAVE adding_loop;
END IF;
END LOOP simple_loop;
END LOOP adding_loop;
end if;
-- UPDATE WaitList as wl0,students as stu2
-- SET stu2.groupID=grapeID,wl0.dateRemoved=CURDATE() where stu2.studentID in (@theChosenOnes);
END$$
DELIMITER ;
......@@ -402,6 +406,27 @@ BEGIN
END$$
DELIMITER ;
drop procedure if exists viewBadges;
delimiter $$
CREATE PROCEDURE viewBadges(
IN StudentvID varchar(40))
BEGIN
SELECT if(ba.isAwarded=2,'Pending',(if (isAwarded = 1,'Complete','unsuccessful'))) as status,
(select badgeName from badge where BadgeID=ba.badgeawarded limit 1) as 'name',
(select badgeDesc from badge where BadgeID=ba.badgeawarded limit 1) as 'name',
ba.dateAwarded,
concat((select fname from volunteers where volunteerID=ba.awardedby limit 1), ' ',(select lname from volunteers where volunteerID=ba.awardedby limit 1) ) as 'Awarded by',
ba.evidence
-- group by status
from badgeawarded as ba where awardedto=studentvID group by status;
END$$
DELIMITER ;
drop procedure if exists updateSG;
delimiter $$
CREATE PROCEDURE updateSG(
......@@ -443,7 +468,7 @@ CREATE PROCEDURE StudentBadgeApply(
BEGIN
INSERT INTO BadgeAwarded(awardedto,BadgeAwarded,evidence,isAwarded) values (studentID,BadgeID,badgeEvidence,0);
INSERT INTO BadgeAwarded(awardedto,BadgeAwarded,evidence,isAwarded) values( studentID,BadgeID,badgeEvidence,0);
END$$
DELIMITER ;
......@@ -467,18 +492,21 @@ call applytogroup('b6e14bcdd6a79c8f8cd9fcef3be5f00b', '41');
call applytogroup('031f0ba110c9683bf4cf5d2836b32a95',41);
call updateSG('419fd9859978a9bf79df4ff16c99c5f9',"2020-04-09");
call updateDBS('419fd9859978a9bf79df4ff16c99c5f9',"2021-09-09");
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-02-03',3,'41');
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-02-03',2,'41');
call ReviewSession(md5('2023-02-03'),"it was ok","idk");
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-01-03',3,'41');
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-01-03',2,'41');
call ReviewSession(md5('2023-01-03'),"it was ok","idk");
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2022-11-03',3,'41');
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-04-16',3,'41');
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2022-11-03',2,'41');
call addSession("computer lab",3,'419fd9859978a9bf79df4ff16c99c5f9','2023-04-16',2,'41');
CALL STUDENTATTENDS('562fe5b6c65003a11148594678c42b90','94b21f931d888fefd4da7a07c01dff4a');
call studentattends('313b6d9a06c3a0618f72ec75c082b6a4','94b21f931d888fefd4da7a07c01dff4a');
call viewVolunteer('');
select * from sessions;
select * from waitlist;
call viewCheckExpiries();
call addToGroup('41');
select * from waitlist;
select * from students;
INSERT INTO BadgeAwarded(awardedto,BadgeAwarded,evidence,isAwarded) values( '562fe5b6c65003a11148594678c42b90','fb635b87d668b2bbcc6a0b0a2f6adc32','I did it',2);
call viewBadges('562fe5b6c65003a11148594678c42b90')
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