Updates to see others' students

This commit is contained in:
ivan-pelly
2026-04-08 07:56:04 -07:00
parent 0a8d2ebb59
commit 59de3bb2e5
15 changed files with 278 additions and 53 deletions
@@ -1,7 +1,8 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Student_GetWithAssignments`(
IN p_id_program CHAR(36),
IN p_id_user CHAR(36)
IN p_id_user CHAR(36),
IN p_scope VARCHAR(10)
)
BEGIN
SELECT
@@ -17,14 +18,29 @@ BEGIN
INNER JOIN student s ON s.id_student = vc.studentId
WHERE s.id_program = p_id_program
ORDER BY vc.studentId;
SELECT
us.id_user_student,
us.id_user,
us.id_student,
us.is_primary
FROM user_student us
INNER JOIN student s ON s.id_student = us.id_student
WHERE us.id_user = p_id_user
AND s.id_program = p_id_program;
IF p_scope = 'all' THEN
SELECT
us.id_user_student,
us.id_user,
us.id_student,
us.is_primary,
u.name AS ownerName
FROM user_student us
INNER JOIN student s ON s.id_student = us.id_student
INNER JOIN `user` u ON u.id_user = us.id_user
WHERE s.id_program = p_id_program;
ELSE
SELECT
us.id_user_student,
us.id_user,
us.id_student,
us.is_primary,
NULL AS ownerName
FROM user_student us
INNER JOIN student s ON s.id_student = us.id_student
WHERE us.id_user = p_id_user
AND s.id_program = p_id_program;
END IF;
END;;
DELIMITER ;