Added Goals fields

This commit is contained in:
ivan-pelly
2026-03-15 09:35:58 -07:00
parent 242b1bce27
commit 53d0539d28
66 changed files with 1322 additions and 329 deletions
-8
View File
@@ -1,8 +0,0 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Goal_Delete`(IN p_id_goal CHAR(36))
BEGIN
DELETE FROM goal
WHERE id_goal = p_id_goal;
SELECT ROW_COUNT() AS rows_affected;
END;;
DELIMITER ;
-15
View File
@@ -1,15 +0,0 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Goal_GetAll`()
BEGIN
SELECT
goalId,
goalParentId,
studentId,
description,
category,
baseline,
progressEventCount
FROM v_goal_card
ORDER BY goalId;
END;;
DELIMITER ;
@@ -8,6 +8,10 @@ BEGIN
description,
category,
baseline,
targetCompletionDate,
closeDate,
achieved,
closeNotes,
progressEventCount
FROM v_goal_card
WHERE goalId = p_id_goal
@@ -2,12 +2,16 @@ DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Goal_GetByStudentId`(IN p_id_student CHAR(36))
BEGIN
SELECT
s.`identifier` AS `studentIdentifier`,
s.`identifier` AS `studentIdentifier`,
vc.`goalId`,
vc.`goalParentId`,
vc.`description`,
vc.`category`,
vc.`baseline`,
vc.`targetCompletionDate`,
vc.`closeDate`,
vc.`achieved`,
vc.`closeNotes`,
vc.`progressEventCount`,
vc.`benchmarkCount`
FROM `v_goal_card` vc
+5 -1
View File
@@ -6,7 +6,8 @@ CREATE DEFINER=`root`@`%` PROCEDURE `sp_Goal_Insert`(
IN p_id_user_created CHAR(36),
IN p_description TEXT,
IN p_category VARCHAR(255),
IN p_baseline TEXT
IN p_baseline TEXT,
IN p_target_completion_date DATE
)
BEGIN
INSERT INTO goal
@@ -18,6 +19,7 @@ BEGIN
description,
category,
baseline,
target_completion_date,
created_at,
updated_at
)
@@ -30,6 +32,7 @@ BEGIN
p_description,
p_category,
p_baseline,
p_target_completion_date,
UTC_TIMESTAMP(),
UTC_TIMESTAMP()
);
@@ -41,6 +44,7 @@ BEGIN
description,
category,
baseline,
target_completion_date,
created_at,
updated_at
FROM goal
+9 -1
View File
@@ -6,7 +6,11 @@ CREATE DEFINER=`root`@`%` PROCEDURE `sp_Goal_Update`(
IN p_id_user_created CHAR(36),
IN p_description TEXT,
IN p_category VARCHAR(255),
IN p_baseline TEXT
IN p_baseline TEXT,
IN p_target_completion_date DATE,
IN p_close_date DATE,
IN p_achieved TINYINT(1),
IN p_close_notes TEXT
)
BEGIN
UPDATE goal
@@ -17,6 +21,10 @@ BEGIN
description = COALESCE(p_description, description),
category = COALESCE(p_category, category),
baseline = COALESCE(p_baseline, baseline),
target_completion_date = COALESCE(p_target_completion_date, target_completion_date),
close_date = COALESCE(p_close_date, close_date),
achieved = COALESCE(p_achieved, achieved),
close_notes = COALESCE(p_close_notes, close_notes),
updated_at = UTC_TIMESTAMP()
WHERE id_goal = p_id_goal;
SELECT ROW_COUNT() AS rows_affected;
@@ -0,0 +1,11 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEventBenchmark_GetByEventId`(
IN p_id_progress_event CHAR(36)
)
BEGIN
SELECT
peb.id_benchmark AS benchmarkId
FROM progress_event_benchmark peb
WHERE peb.id_progress_event = p_id_progress_event;
END;;
DELIMITER ;
@@ -1,8 +0,0 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_Delete`(IN p_id_progress_event CHAR(36))
BEGIN
DELETE FROM progress_event
WHERE id_progress_event = p_id_progress_event;
SELECT ROW_COUNT() AS rows_affected;
END;;
DELIMITER ;
@@ -1,16 +0,0 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_GetAll`()
BEGIN
SELECT
id_progress_event,
id_student,
id_goal,
id_user_created,
content,
is_sensitive,
created_at,
updated_at
FROM progress_event
ORDER BY id_progress_event;
END;;
DELIMITER ;
@@ -1,17 +0,0 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_GetById`(IN p_id_progress_event CHAR(36))
BEGIN
SELECT
id_progress_event,
id_student,
id_goal,
id_user_created,
content,
is_sensitive,
created_at,
updated_at
FROM progress_event
WHERE id_progress_event = p_id_progress_event
LIMIT 1;
END;;
DELIMITER ;
@@ -1,42 +0,0 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_Insert`(
IN p_id_progress_event CHAR(36),
IN p_id_goal CHAR(36),
IN p_id_user_created CHAR(36),
IN p_content TEXT,
IN p_is_sensitive TINYINT(1)
)
BEGIN
INSERT INTO progress_event
(
id_progress_event,
id_goal,
id_user_created,
content,
is_sensitive,
created_at,
updated_at
)
VALUES
(
p_id_progress_event,
p_id_goal,
p_id_user_created,
p_content,
p_is_sensitive,
UTC_TIMESTAMP(),
UTC_TIMESTAMP()
);
SELECT
id_progress_event,
id_goal,
id_user_created,
content,
is_sensitive,
created_at,
updated_at
FROM progress_event
WHERE id_progress_event = p_id_progress_event
LIMIT 1;
END;;
DELIMITER ;
@@ -0,0 +1,62 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_Save`(
IN p_id_progress_event CHAR(36),
IN p_id_goal CHAR(36),
IN p_id_user_created CHAR(36),
IN p_content TEXT,
IN p_is_sensitive TINYINT(1),
IN p_is_new TINYINT(1),
IN p_benchmark_ids TEXT
)
BEGIN
-- Insert or update the progress event
IF p_is_new = 1 THEN
INSERT INTO progress_event
(
id_progress_event,
id_goal,
id_user_created,
content,
is_sensitive,
created_at,
updated_at
)
VALUES
(
p_id_progress_event,
p_id_goal,
p_id_user_created,
p_content,
p_is_sensitive,
UTC_TIMESTAMP(),
UTC_TIMESTAMP()
);
ELSE
UPDATE progress_event
SET
content = COALESCE(p_content, content),
updated_at = UTC_TIMESTAMP()
WHERE id_progress_event = p_id_progress_event;
END IF;
-- Sync benchmark associations: remove those not in the list
DELETE FROM progress_event_benchmark
WHERE id_progress_event = p_id_progress_event
AND (p_benchmark_ids IS NULL
OR LENGTH(TRIM(p_benchmark_ids)) = 0
OR FIND_IN_SET(id_benchmark, p_benchmark_ids) = 0);
-- Add associations that are in the list but not yet in the table
IF p_benchmark_ids IS NOT NULL AND LENGTH(TRIM(p_benchmark_ids)) > 0 THEN
INSERT INTO progress_event_benchmark (id_progress_event_benchmark, id_progress_event, id_benchmark, created_at)
SELECT UUID(), p_id_progress_event, b.id_benchmark, UTC_TIMESTAMP()
FROM benchmark b
WHERE FIND_IN_SET(b.id_benchmark, p_benchmark_ids) > 0
AND b.id_benchmark NOT IN (
SELECT peb.id_benchmark
FROM progress_event_benchmark peb
WHERE peb.id_progress_event = p_id_progress_event
);
END IF;
-- Return the progress event ID for the caller
SELECT p_id_progress_event AS progressEventId;
END;;
DELIMITER ;
@@ -1,22 +0,0 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_Update`(
IN p_id_progress_event CHAR(36),
IN p_id_student CHAR(36),
IN p_id_goal CHAR(36),
IN p_id_user_created CHAR(36),
IN p_content TEXT,
IN p_is_sensitive TINYINT(1)
)
BEGIN
UPDATE progress_event
SET
id_student = COALESCE(p_id_student, id_student),
id_goal = COALESCE(p_id_goal, id_goal),
id_user_created = COALESCE(p_id_user_created, id_user_created),
content = COALESCE(p_content, content),
is_sensitive = COALESCE(p_is_sensitive, is_sensitive),
updated_at = UTC_TIMESTAMP()
WHERE id_progress_event = p_id_progress_event;
SELECT ROW_COUNT() AS rows_affected;
END;;
DELIMITER ;
@@ -1,14 +0,0 @@
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Student_GetAll`()
BEGIN
SELECT
studentId,
identifier,
nextIepDate,
lastEntryDate,
goalCount,
progressEventCount
FROM v_student_card
ORDER BY studentId;
END;;
DELIMITER ;
+2 -1
View File
@@ -7,7 +7,8 @@ BEGIN
nextIepDate,
lastEntryDate,
goalCount,
progressEventCount
progressEventCount,
benchmarkCount
FROM v_student_card
WHERE studentId = p_id_student
LIMIT 1;
@@ -4,19 +4,18 @@ CREATE DEFINER=`root`@`%` PROCEDURE `sp_Student_GetWithAssignments`(
IN p_id_user CHAR(36)
)
BEGIN
-- Result set 1: All students in the program (card shape)
SELECT
vc.studentId,
vc.identifier,
vc.nextIepDate,
vc.lastEntryDate,
vc.goalCount,
vc.progressEventCount
vc.progressEventCount,
vc.benchmarkCount
FROM v_student_card vc
INNER JOIN student s ON s.id_student = vc.studentId
WHERE s.id_program = p_id_program
ORDER BY vc.studentId;
-- Result set 2: user_student assignments for the requesting user in this program
SELECT
us.id_user_student,
us.id_user,