Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed parameter values in the reports #4265

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ public string ResolveParameters(int reqId, int ansId, string requirementText)
List<ParameterToken> tokens = this.GetTokensForRequirement(reqId, ansId);
foreach (ParameterToken t in tokens)
{
requirementText = requirementText.Replace(t.Token, t.Substitution);
requirementText = requirementText.Replace(t.Token, "<br><i>" +t.Substitution +"</i>");
}

requirementText = requirementText.Replace("\r\n", "<br/>").Replace("\r", "<br/>").Replace("\n", "<br/>");
Expand Down
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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading