Skip to content

Commit

Permalink
fixed parameter values in the reports
Browse files Browse the repository at this point in the history
  • Loading branch information
inlguy committed Dec 2, 2024
1 parent 6b8a4ea commit efdde66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ public void BuildSubGroupings(MaturityGrouping g, int? parentID,
public List<BasicReportData.RequirementControl> GetControls(string applicationMode)
{
var lang = _tokenManager.GetCurrentLanguage();
var rm = new Question.RequirementBusiness(_assessmentUtil, _questionRequirement, _context, _tokenManager);

_questionRequirement.InitializeManager(_assessmentId);

Expand Down Expand Up @@ -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
});
}
}
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -1415,6 +1382,7 @@ public List<QuestionsWithComments> GetQuestionsWithComments()

var results = new List<QuestionsWithComments>();

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))
Expand All @@ -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
};

Expand Down Expand Up @@ -1523,6 +1491,7 @@ public List<QuestionsMarkedForReview> GetQuestionsReviewed()
{

var results = new List<QuestionsMarkedForReview>();
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)
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ public class ControlRow
public string Answer_Text;
public string Comment;
public string Simple_Question;

public int Answer_Id { get; set; }
}
}

0 comments on commit efdde66

Please sign in to comment.