From efdde666e805f6ad558f938f214ff1c841950f78 Mon Sep 17 00:00:00 2001 From: Barry Hansen <5023364+inlguy@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:46:57 -0700 Subject: [PATCH 1/2] fixed parameter values in the reports --- .../Reports/ReportsDataBusiness.cs | 49 ++++--------------- .../CSETWebCore.Model/Reports/ControlRow.cs | 2 + 2 files changed, 11 insertions(+), 40 deletions(-) diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Reports/ReportsDataBusiness.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Reports/ReportsDataBusiness.cs index 2466ccc2f2..bd04e89d69 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Reports/ReportsDataBusiness.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Reports/ReportsDataBusiness.cs @@ -897,6 +897,7 @@ public void BuildSubGroupings(MaturityGrouping g, int? parentID, public List GetControls(string applicationMode) { var lang = _tokenManager.GetCurrentLanguage(); + var rm = new Question.RequirementBusiness(_assessmentUtil, _questionRequirement, _context, _tokenManager); _questionRequirement.InitializeManager(_assessmentId); @@ -968,7 +969,8 @@ join a in _context.Answer_Requirements on r.Requirement_Id equals a.Question_Or_ Simple_Question = q.qu.Simple_Question, Standard_Category = q.r.Standard_Category, Standard_Sub_Category = q.r.Standard_Sub_Category, - Standard_Level = q.rl.Standard_Level + Standard_Level = q.rl.Standard_Level, + Answer_Id = q.a.Answer_Id }); } } @@ -1000,44 +1002,9 @@ join a in _context.Answer_Requirements on r.Requirement_Id equals a.Question_Or_ var c = _overlay.GetPropertyValue("STANDARD_CATEGORY", a.Standard_Category.ToLower(), lang); var s = _overlay.GetPropertyValue("STANDARD_CATEGORY", a.Standard_Sub_Category.ToLower(), lang); - // Check for custom parameters - var customParameter = (from pa in _context.PARAMETER_ASSESSMENT - join pr in _context.PARAMETER_REQUIREMENTS - on pa.Parameter_ID equals pr.Parameter_Id - join p in _context.PARAMETERS - on pa.Parameter_ID equals p.Parameter_ID - where pr.Requirement_Id == a.Requirement_Id - where pa.Assessment_ID == _assessmentId - select new - { - pa.Parameter_Value_Assessment, - pa.Assessment_ID, - p.Parameter_Name - }).Distinct().ToList(); - - var QuestionRequirementText = r?.RequirementText ?? a.Requirement_Text; - + // Replace parameter in requirement text if custom parameter is found - if (customParameter != null) - { - // Replace text or escape quickly if parameter is not found in original text - foreach (var param in customParameter) - { - if (QuestionRequirementText.Contains(param.Parameter_Name)) - { - var newText = Regex.Replace(r?.RequirementText ?? a.Requirement_Text, param.Parameter_Name.Replace("[", "\\[").Replace("]", "\\]"), param.Parameter_Value_Assessment); - - if (r?.RequirementText != null) - { - r.RequirementText = newText; - } - else - { - a.Requirement_Text = newText; - } - } - } - } + a.Requirement_Text = rm.ResolveParameters(a.Requirement_Id, a.Answer_Id, a.Requirement_Text); control = new BasicReportData.RequirementControl() { @@ -1415,6 +1382,7 @@ public List GetQuestionsWithComments() var results = new List(); + var rm = new Question.RequirementBusiness(_assessmentUtil, _questionRequirement, _context, _tokenManager); // get any "marked for review" or commented answers that currently apply var relevantAnswers = new RelevantAnswers().GetAnswersForAssessment(_assessmentId, _context) .Where(ans => !string.IsNullOrEmpty(ans.Comment)) @@ -1436,7 +1404,7 @@ join req in _context.NEW_REQUIREMENT on ans.Question_Or_Requirement_ID equals re { Answer = ans.Answer_Text, CategoryAndNumber = req.Standard_Category + " - " + req.Requirement_Title, - Question = req.Requirement_Text, + Question = rm.ResolveParameters(ans.Question_Or_Requirement_ID, ans.Answer_ID, req.Requirement_Text), Comment = ans.Comment }; @@ -1523,6 +1491,7 @@ public List GetQuestionsReviewed() { var results = new List(); + var rm = new Question.RequirementBusiness(_assessmentUtil, _questionRequirement, _context, _tokenManager); // get any "marked for review" or commented answers that currently apply var relevantAnswers = new RelevantAnswers().GetAnswersForAssessment(_assessmentId, _context) @@ -1545,7 +1514,7 @@ join req in _context.NEW_REQUIREMENT on ans.Question_Or_Requirement_ID equals re { Answer = ans.Answer_Text, CategoryAndNumber = req.Standard_Category + " - " + req.Requirement_Title, - Question = req.Requirement_Text + Question = rm.ResolveParameters(ans.Question_Or_Requirement_ID, ans.Answer_ID, req.Requirement_Text) }; return query.ToList(); diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Model/Reports/ControlRow.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Model/Reports/ControlRow.cs index 3cacef1351..d3e1de7d4b 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Model/Reports/ControlRow.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Model/Reports/ControlRow.cs @@ -26,5 +26,7 @@ public class ControlRow public string Answer_Text; public string Comment; public string Simple_Question; + + public int Answer_Id { get; set; } } } From 673fe04638b2cdab803566d14d051a2b1d6df476 Mon Sep 17 00:00:00 2001 From: Barry Hansen <5023364+inlguy@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:53:31 -0700 Subject: [PATCH 2/2] parameter fixes --- .../CSETWebCore.Business/Question/RequirementBusiness.cs | 2 +- .../dialogs/inline-parameter/inline-parameter.component.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/RequirementBusiness.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/RequirementBusiness.cs index 0093150575..3e9a4411f0 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/RequirementBusiness.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/RequirementBusiness.cs @@ -645,7 +645,7 @@ public string ResolveParameters(int reqId, int ansId, string requirementText) List tokens = this.GetTokensForRequirement(reqId, ansId); foreach (ParameterToken t in tokens) { - requirementText = requirementText.Replace(t.Token, t.Substitution); + requirementText = requirementText.Replace(t.Token, "
" +t.Substitution +""); } requirementText = requirementText.Replace("\r\n", "
").Replace("\r", "
").Replace("\n", "
"); diff --git a/CSETWebNg/src/app/dialogs/inline-parameter/inline-parameter.component.ts b/CSETWebNg/src/app/dialogs/inline-parameter/inline-parameter.component.ts index ba9ff88132..7f808fbbec 100644 --- a/CSETWebNg/src/app/dialogs/inline-parameter/inline-parameter.component.ts +++ b/CSETWebNg/src/app/dialogs/inline-parameter/inline-parameter.component.ts @@ -55,6 +55,10 @@ export class InlineParameterComponent implements OnInit { * Push the new value to the API and close the dialog. */ save() { + + if(this.parameterValue.trim()==""){ + this.parameterValue = this.originalValue; + } const answerParm: ParameterForAnswer = { requirementId: this.question.questionId, answerId: this.question.answer_Id,