-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ran ProcViewSerializer to put latest procs into source control
- Loading branch information
1 parent
f1976ef
commit 7efa341
Showing
25 changed files
with
633 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Database Scripts/Stored Procedures/Acet_GetActionItemsForReport.proc.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- ============================================= | ||
-- Author: mrwinston | ||
-- Create date: 11/4/2022 | ||
-- Description: loads in the Action_Items for ACET ISE's MERIT and Examination reports | ||
-- ============================================= | ||
CREATE PROCEDURE [dbo].[Acet_GetActionItemsForReport] | ||
@Assessment_Id int, | ||
@Exam_Level int, | ||
@Additional_Exam_Level int | ||
AS | ||
BEGIN | ||
SELECT a.Parent_Question_Id, a.Mat_Question_Id,a.Finding_Id,a.Question_Title,a.answer_text,Regulatory_Citation, isnull(b.action_items_override,a.Action_Items) as Action_Items, a.Maturity_Level_Id | ||
FROM (select m.mat_question_id,m.Question_Title, m.Parent_Question_Id,i.Action_Items, Regulatory_Citation, a.Answer_Text,m.Maturity_Level_Id, mf.Finding_Id | ||
from [MATURITY_QUESTIONS] AS [m] | ||
join [ANSWER] [a] on m.Mat_Question_Id = a.Question_Or_Requirement_Id and a.Question_Type = 'Maturity' and Assessment_Id = @Assessment_Id | ||
join (select a1.Question_Or_Requirement_Id,f1.Finding_Id,f1.Auto_Generated from ANSWER a1 join FINDING f1 on a1.Answer_Id=f1.Answer_Id where Assessment_Id = @Assessment_Id and a1.Question_Type = 'Maturity') mf on m.Parent_Question_Id = mf.Question_Or_Re | ||
quirement_Id | ||
INNER JOIN [ISE_ACTIONS] AS [i] ON [m].[Mat_Question_Id] = [i].[Mat_Question_Id] | ||
where a.Answer_Text = 'N' or Auto_Generated = 0 | ||
) a | ||
|
||
left join (select a.Assessment_Id,a.Question_Or_Requirement_Id,f.Finding_Id,i0.Action_Items_Override,i0.Mat_Question_Id | ||
from [ANSWER] [a] | ||
JOIN [FINDING] AS [f] ON [a].[Answer_Id] = [f].[Answer_Id] | ||
LEFT JOIN [ISE_ACTIONS_FINDINGS] AS [i0] ON f.Finding_Id = i0.Finding_Id | ||
WHERE [a].[Assessment_Id] = @Assessment_Id and a.Question_Type = 'Maturity' | ||
) b on a.Parent_Question_Id = b.Question_Or_Requirement_Id and a.Mat_Question_Id = b.Mat_Question_Id and a.Finding_Id = b.Finding_Id | ||
|
||
where a.Maturity_Level_Id = @Exam_Level or a.Maturity_Level_Id = @Additional_Exam_Level | ||
order by a.Mat_Question_Id | ||
|
||
END |
29 changes: 29 additions & 0 deletions
29
Database Scripts/Stored Procedures/GetAnswerDistribGroupings.proc.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- ============================================= | ||
-- Author: Randy Woods | ||
-- Create date: 15 November 2022 | ||
-- Description: Tallies answer counts for all maturity groupings | ||
-- at the top level. | ||
-- TODO: What if we want to target the children of a | ||
-- specific grouping? g.Parent_Id = X | ||
-- ============================================= | ||
CREATE PROCEDURE [dbo].[GetAnswerDistribGroupings] | ||
@assessmentId int | ||
AS | ||
BEGIN | ||
SET NOCOUNT ON; | ||
exec FillEmptyMaturityQuestionsForAnalysis @assessmentId | ||
|
||
declare @maturityModelId int = (select model_id from AVAILABLE_MATURITY_MODELS where Assessment_Id = @assessmentId) | ||
|
||
select [grouping_id], [title], [answer_text], count(answer_text) as [answer_count] | ||
from ( | ||
select g.grouping_id, g.title, g.sequence, a.Answer_Text | ||
from maturity_groupings g | ||
left join maturity_questions q on q.grouping_id = g.Grouping_Id | ||
left join ANSWER a on a.Question_Or_Requirement_Id = q.Mat_Question_Id | ||
where a.Assessment_Id = @assessmentId and g.Parent_Id is null and | ||
g.maturitY_model_id = @maturityModelId | ||
) N | ||
group by n.answer_text, n.grouping_id, n.title, n.Sequence | ||
order by n.Sequence | ||
END |
42 changes: 42 additions & 0 deletions
42
Database Scripts/Stored Procedures/GetAnswerDistribMaturity.proc.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- ============================================= | ||
-- Author: Randy Woods | ||
-- Create date: 11 November 2022 | ||
-- Description: Get a generic answer distribution for an assessment | ||
-- without having to worry about which answers it supports. | ||
-- ============================================= | ||
CREATE PROCEDURE [dbo].[GetAnswerDistribMaturity] | ||
@assessment_id int | ||
AS | ||
BEGIN | ||
-- SET NOCOUNT ON added to prevent extra result sets from | ||
-- interfering with SELECT statements. | ||
SET NOCOUNT ON; | ||
|
||
-- build list of answer options supported by the assessment's model | ||
declare @ao varchar(20) | ||
select @ao = answer_options | ||
from maturity_models mm | ||
left join AVAILABLE_MATURITY_MODELS amm on mm.Maturity_Model_Id = amm.model_id | ||
where amm.Assessment_Id = @assessment_id | ||
|
||
select * into #ao from STRING_SPLIT(@ao, ',') | ||
insert into #ao (value) values ('U') | ||
update #ao set value = TRIM(value) | ||
|
||
|
||
select a.Answer_Full_Name, a.Answer_Text, | ||
isnull(m.qc,0) as [qc], | ||
isnull(m.Total,0) as [Total], | ||
IsNull(Cast(IsNull(Round((Cast((qc) as float)/(IsNull(NullIf(Total,0),1)))*100, 2), 0) as float),0) as [Percent] | ||
from | ||
(select * from ANSWER_LOOKUP where Answer_Text in (select value from #ao)) a left join ( | ||
SELECT a.Answer_Text, isnull(count(question_or_requirement_id),0) qc , SUM(count(Question_Or_Requirement_Id)) OVER(PARTITION BY assessment_id) AS Total | ||
FROM Answer_Maturity a | ||
join MATURITY_LEVELS l on a.Maturity_Level_Id = l.Maturity_Level_Id | ||
where a.Assessment_Id = @assessment_id and Is_Maturity = 1 | ||
group by a.Assessment_Id, a.Answer_Text) | ||
m on a.Answer_Text = m.Answer_Text | ||
LEFT JOIN ANSWER_ORDER o on a.Answer_Text = o.answer_text | ||
order by o.answer_order | ||
|
||
END |
19 changes: 19 additions & 0 deletions
19
Database Scripts/Stored Procedures/GetChildrenAnswers.proc.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- ============================================= | ||
-- Author: <Author,,Name> | ||
-- Create date: <Create Date,,> | ||
-- Description: <Description,,> | ||
-- ============================================= | ||
CREATE PROCEDURE [dbo].[GetChildrenAnswers] | ||
@Parent_Id int, | ||
@Assess_Id int | ||
|
||
AS | ||
BEGIN | ||
SET NOCOUNT ON; | ||
SELECT [Mat_Question_Id], [Question_Title], [Question_Text], | ||
[Answer_Text], [Maturity_Level_Id], [Parent_Question_Id], | ||
[Ranking], [Grouping_Id] FROM MATURITY_QUESTIONS | ||
JOIN ANSWER | ||
ON MATURITY_QUESTIONS.Mat_Question_Id = ANSWER.Question_Or_Requirement_Id | ||
WHERE ([Parent_Question_Id] = @Parent_Id) AND ([Assessment_Id] = @Assess_Id) | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Database Scripts/Stored Procedures/IseAnswerDistribution.proc.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
-- ============================================= | ||
-- Author: mrwinston | ||
-- Create date: 10/10/2022 | ||
-- Description: Gets all the AnswerText values, excluding parent questions | ||
-- ============================================= | ||
CREATE PROCEDURE [dbo].[IseAnswerDistribution] | ||
@Assessment_Id int, | ||
@targetLevel int | ||
AS | ||
BEGIN | ||
|
||
SET NOCOUNT ON; | ||
|
||
exec FillEmptyMaturityQuestionsForAnalysis @assessment_id | ||
|
||
declare @model_id int | ||
select @model_id = (select model_id from AVAILABLE_MATURITY_MODELS where assessment_id = @Assessment_id and selected = 1) | ||
|
||
|
||
select a.Answer_Text, count(*) as [Count] from maturity_questions q | ||
left join answer a on a.Question_Or_Requirement_Id = q.Mat_Question_Id | ||
left join maturity_levels l on q.Maturity_Level_Id = l.Maturity_Level_Id | ||
where a.Question_Type = 'Maturity' and q.Maturity_Model_Id = @model_id | ||
and l.Maturity_Level_Id = @targetLevel | ||
and a.Assessment_Id = @assessment_id | ||
and q.Parent_Question_Id IS NOT NULL | ||
and q.Maturity_Level_Id != 19 | ||
group by Answer_Text | ||
|
||
|
||
END |
Oops, something went wrong.