Skip to content

Commit

Permalink
Merge branch 'develop' into feature/CSET-2929
Browse files Browse the repository at this point in the history
  • Loading branch information
randywoods1 committed Dec 11, 2024
2 parents 5d0bf27 + 50920c2 commit 513b9f7
Show file tree
Hide file tree
Showing 48 changed files with 184 additions and 86 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
////////////////////////////////
////////////////////////////////
//
// Copyright 2024 Battelle Energy Alliance, LLC
//
Expand Down Expand Up @@ -88,7 +88,7 @@ public CmmcScores GetCmmcScores(int assessmentId)
// Level 3
response.Level3Score = GetScoreForLevel(assessmentId, 3);
response.Level3MaxScore = _level3Max;
response.Level3Active = (response.Level2Score == _level2Max);
response.Level3Active = response.Level2Active && (response.Level2Score == _level2Max);


return response;
Expand Down Expand Up @@ -208,7 +208,7 @@ private CmmcScoreModel FilterByLevel(XDocument x, int level)


/// <summary>
/// Calculates a SPRS score based on the question scoring values in MATURITY_EXTRA.
/// Calculates a SPRS score based on the level 2 question scoring values in MATURITY_EXTRA.
/// </summary>
public CmmcScoreModel GetSPRSScore(int assessmentId)
{
Expand All @@ -227,7 +227,7 @@ public CmmcScoreModel GetSPRSScore(int assessmentId)
d.DomainName = goal.Attribute("title").Value;
response.Domains.Add(d);

foreach (var question in goal.Descendants("Question"))
foreach (var question in goal.Descendants("Question").Where(x => x.Attribute("level").Value == "2"))
{
var q = new CmmcQuestion();
q.QuestionId = int.Parse(question.Attribute("questionid").Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ public MaturityResponse GetMaturityQuestions(int assessmentId, bool fill, int gr
var questionQuery = _context.MATURITY_QUESTIONS
.Include(x => x.Maturity_Level)
.Include(x => x.MATURITY_QUESTION_PROPS)
.Include(x => x.MATURITY_EXTRA)
.Where(q =>
targetModelId == q.Maturity_Model_Id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public partial class ANALYTICS_MATURITY_GROUPINGS
[StringLength(200)]
public string Question_Group { get; set; }

public int? Group_Sequence { get; set; }

public int? Global_Sequence { get; set; }

public int? Group_id { get; set; }

[ForeignKey("Maturity_Model_Id")]
[InverseProperty("ANALYTICS_MATURITY_GROUPINGS")]
public virtual MATURITY_MODELS Maturity_Model { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public partial class Analytics_Answers
[StringLength(20)]
public string Question_Type { get; set; }

[Required]
[StringLength(1)]
public string Answer_Text { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public partial class Answer_Components_Default
public int GroupHeadingId { get; set; }

[Required]
[StringLength(150)]
[StringLength(100)]
public string Universal_Sub_Category { get; set; }

public int SubCategoryId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public partial class Answer_Components_Exploded

public int? GroupHeadingId { get; set; }

[StringLength(150)]
[StringLength(100)]
public string Universal_Sub_Category { get; set; }

public int? SubCategoryId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public partial class Answer_Components_Overrides

public int? GroupHeadingId { get; set; }

[StringLength(150)]
[StringLength(100)]
public string Universal_Sub_Category { get; set; }

public int? SubCategoryId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasComment("The Answer Text is used to");
entity.Property(e => e.Comment).HasComment("The Comment is used to");
entity.Property(e => e.Component_Guid).HasComment("The Component Guid is used to");
entity.Property(e => e.Is_Component).HasComputedColumnSql("(CONVERT([bit],case [Question_Type] when 'Component' then (1) else (0) end,(0)))", false);
entity.Property(e => e.Is_Framework).HasComputedColumnSql("(CONVERT([bit],case [Question_Type] when 'Framework' then (1) else (0) end,(0)))", false);
entity.Property(e => e.Is_Maturity).HasComputedColumnSql("(CONVERT([bit],case [Question_Type] when 'Maturity' then (1) else (0) end,(0)))", false);
entity.Property(e => e.Is_Requirement).HasComputedColumnSql("(CONVERT([bit],case [Question_Type] when 'Requirement' then (1) else (0) end,(0)))", false);
entity.Property(e => e.Is_Component).HasComputedColumnSql("(CONVERT([bit],case [Question_Type] when 'Component' then (1) else (0) end))", false);
entity.Property(e => e.Is_Framework).HasComputedColumnSql("(CONVERT([bit],case [Question_Type] when 'Framework' then (1) else (0) end))", false);
entity.Property(e => e.Is_Maturity).HasComputedColumnSql("(CONVERT([bit],case [Question_Type] when 'Maturity' then (1) else (0) end))", false);
entity.Property(e => e.Is_Requirement).HasComputedColumnSql("(CONVERT([bit],case [Question_Type] when 'Requirement' then (1) else (0) end))", false);
entity.Property(e => e.Mark_For_Review).HasComment("The Mark For Review is used to");
entity.Property(e => e.Question_Number).HasComment("The Question Number is used to");
entity.Property(e => e.Question_Or_Requirement_Id).HasComment("The Question Or Requirement Id is used to");
Expand Down Expand Up @@ -1800,6 +1800,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<MATURITY_EXTRA>(entity =>
{
entity.Property(e => e.Maturity_Question_Id).ValueGeneratedNever();

entity.HasOne(d => d.Maturity_Question).WithOne(p => p.MATURITY_EXTRA)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_mat_questions");
});

modelBuilder.Entity<MATURITY_GROUPINGS>(entity =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using CSETWebCore.DataLayer.Model;
using Microsoft.Data.SqlClient;
Expand Down Expand Up @@ -1915,6 +1915,31 @@ public virtual async Task<List<usp_financial_attributesResult>> usp_financial_at
return _;
}

public virtual async Task<List<usp_GenerateSPRSScoreResult>> usp_GenerateSPRSScoreAsync(int? assessment_id, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default)
{
var parameterreturnValue = new SqlParameter
{
ParameterName = "returnValue",
Direction = System.Data.ParameterDirection.Output,
SqlDbType = System.Data.SqlDbType.Int,
};

var sqlParameters = new []
{
new SqlParameter
{
ParameterName = "assessment_id",
Value = assessment_id ?? Convert.DBNull,
SqlDbType = System.Data.SqlDbType.Int,
},
parameterreturnValue,
};
var _ = await _context.SqlQueryAsync<usp_GenerateSPRSScoreResult>("EXEC @returnValue = [dbo].[usp_GenerateSPRSScore] @assessment_id = @assessment_id", sqlParameters, cancellationToken);

returnValue?.SetValue(parameterreturnValue.Value);

return _;
}

public virtual async Task<List<usp_getAnswerComponentOverridesResult>> usp_getAnswerComponentOverridesAsync(int? assessment_id, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public partial interface ICsetwebContextProcedures
Task<int> usp_CopyIntoSet_DeleteAsync(string DestinationSetName, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<usp_countsForLevelsByGroupMaturityModelResult>> usp_countsForLevelsByGroupMaturityModelAsync(int? assessment_id, int? mat_model_id, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<usp_financial_attributesResult>> usp_financial_attributesAsync(int? Assessment_Id, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<usp_GenerateSPRSScoreResult>> usp_GenerateSPRSScoreAsync(int? assessment_id, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<usp_getAnswerComponentOverridesResult>> usp_getAnswerComponentOverridesAsync(int? assessment_id, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<usp_GetAssessmentPieResult>> usp_GetAssessmentPieAsync(int? Assessment_Id, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<usp_getComponentsRankedCategoriesResult>> usp_getComponentsRankedCategoriesAsync(int? assessment_id, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,11 @@ public partial class MATURITY_EXTRA

[StringLength(100)]
public string CMMC2_Title { get; set; }

[StringLength(50)]
public string Answer_Options { get; set; }

[ForeignKey("Maturity_Question_Id")]
[InverseProperty("MATURITY_EXTRA")]
public virtual MATURITY_QUESTIONS Maturity_Question { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public partial class MATURITY_QUESTIONS
[InverseProperty("Mat_Question")]
public virtual ICollection<MATURITY_ANSWER_OPTIONS> MATURITY_ANSWER_OPTIONS { get; set; } = new List<MATURITY_ANSWER_OPTIONS>();

[InverseProperty("Maturity_Question")]
public virtual MATURITY_EXTRA MATURITY_EXTRA { get; set; }

[InverseProperty("Mat_Question")]
public virtual ICollection<MATURITY_QUESTION_PROPS> MATURITY_QUESTION_PROPS { get; set; } = new List<MATURITY_QUESTION_PROPS>();

Expand Down
3 changes: 3 additions & 0 deletions CSETWebApi/CSETWeb_Api/CSETWebCore.DataLayer/Model/Nlogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ public partial class Nlogs

[StringLength(4000)]
public string Message { get; set; }

[StringLength(100)]
public string User { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace CSETWebCore.DataLayer.Model
{
public partial class usp_GenerateSPRSScoreResult
{
public int? SPRS_SCORE { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace CSETWebCore.DataLayer.Model
{
public partial class usp_GetQuestionsResult
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class vQUESTION_HEADINGS
public int Question_Group_Heading_Id { get; set; }

[Required]
[StringLength(150)]
[StringLength(100)]
public string Universal_Sub_Category { get; set; }

[StringLength(1000)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using CSETWebCore.DataLayer.Model;
using CSETWebCore.Model.Question;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSETWebCore.Helpers
{
Expand Down Expand Up @@ -49,6 +45,11 @@ public static QuestionAnswer BuildQuestionAnswer(MATURITY_QUESTIONS myQ, FullAns
SetName = string.Empty
};

if (myQ.MATURITY_EXTRA?.Answer_Options != null)
{
qa.AnswerOptions = myQ.MATURITY_EXTRA?.Answer_Options.Split(',').ToList();
}

return qa;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public class QuestionAnswer
public List<ParameterToken> ParmSubs { get; set; }
public string StdRefId { get; set; }
public string Answer { get; set; }

/// <summary>
/// If a question's potential answer set deviates from the one
/// defined at the MaturityModel level.
/// </summary>
public List<string> AnswerOptions { get; set; }

public string AltAnswerText { get; set; }
public string FreeResponseAnswer { get; set; }
public string Comment { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ public IActionResult GetTargetLevel()
}


/// <summary>
/// TODO: Cannot find this endpoint name in the UI codebase
/// </summary>
/// <param name="mat_model_id"></param>
/// <returns></returns>
[HttpGet]
[Route("api/MaturityModel/GetLevelScoresByGroup")]
public IActionResult GetLevelScoresByGroup(int mat_model_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class MaturityQuestionsAcetComponent implements OnInit, AfterViewInit {
this.groupings = response.groupings;
this.assessSvc.assessment.maturityModel.maturityTargetLevel = response.maturityTargetLevel;
this.assessSvc.assessment.maturityModel.answerOptions = response.answerOptions;
this.filterSvc.answerOptions = response.answerOptions;
this.filterSvc.answerOptions = response.answerOptions.slice();
this.filterSvc.maturityModelId = response.modelId;
this.filterSvc.maturityModelName = response.modelName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class MaturityQuestionsCieComponent implements OnInit, AfterViewInit {
}
this.assessSvc.assessment.maturityModel.maturityTargetLevel = response.maturityTargetLevel;
this.assessSvc.assessment.maturityModel.answerOptions = response.answerOptions;
this.filterSvc.answerOptions = response.answerOptions;
this.filterSvc.answerOptions = response.answerOptions.slice();
this.filterSvc.maturityModelId = response.modelId;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class MaturityQuestionsIseComponent implements OnInit, AfterViewInit {

this.assessSvc.assessment.maturityModel.maturityTargetLevel = response.maturityTargetLevel;
this.assessSvc.assessment.maturityModel.answerOptions = response.answerOptions;
this.filterSvc.answerOptions = response.answerOptions;
this.filterSvc.answerOptions = response.answerOptions.slice();
this.filterSvc.maturityModelId = response.modelId;

// get the selected maturity filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class MaturityQuestionsComponent implements OnInit, AfterViewInit {
this.assessSvc.assessment.maturityModel.maturityTargetLevel = response.maturityTargetLevel;

this.assessSvc.assessment.maturityModel.answerOptions = response.answerOptions;
this.filterSvc.answerOptions = response.answerOptions;
this.filterSvc.answerOptions = response.answerOptions.slice();
this.filterSvc.maturityModelId = response.modelId;
this.filterSvc.maturityModelName = response.modelName;

Expand Down Expand Up @@ -247,7 +247,7 @@ export class MaturityQuestionsComponent implements OnInit, AfterViewInit {
this.assessSvc.assessment.maturityModel.maturityTargetLevel = response.maturityTargetLevel;

this.assessSvc.assessment.maturityModel.answerOptions = response.answerOptions;
this.filterSvc.answerOptions = response.answerOptions;
this.filterSvc.answerOptions = response.answerOptions.slice();
this.filterSvc.maturityModelId = response.modelId;

this.pageTitle = this.questionsAlias + ' - ' + this.modelName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<label class="me-0 ms-2 btn form-check-label btn-mfr"
[class.answer-selected]="q.markForReview === true"
matTooltip="This control requires further review.">
<input name="q_{{ q.questionId }}_F" type="checkbox"
<input name="q_{{ q.questionId }}_F" type="checkbox" class="btn-check"
(keydown)="checkKeyPress($event, q, 'mfr')" (click)="saveMFR(q);" tabindex="0"
[checked]="q.markForReview === true">
<span class="cset-icons-flag-dark fs-base"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<div *ngIf="!q.isParentQuestion">
<!-- build the list of answer choice buttons -->
<div class="btn-group btn-group-toggle answer-group" data-toggle="buttons">
<label *ngFor="let option of answerOptions"
<label *ngFor="let option of q.answerOptions ?? modelAnswerOptions"
class="btn form-check-label d-flex align-items-center" tabindex="0"
[class]="questionsSvc.answerOptionCss(maturityModelName, option)"
[class.answer-selected]="q.answer === option"
Expand Down Expand Up @@ -178,8 +178,8 @@
<label class="me-0 ms-2 btn form-check-label btn-mfr"
[class.answer-selected]="q.markForReview === true"
matTooltip="This control requires further review.">
<input name="q_{{q.questionId}}_F" type="checkbox" (click)="saveMFR(q);" tabindex="0"
checked="{{q.markForReview === true}}">
<input name="q_{{q.questionId}}_F" type="checkbox" (click)="saveMFR(q);" class="btn-check"
tabindex="0" checked="{{q.markForReview === true}}">
<span class="cset-icons-flag-dark fs-base"></span>
</label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class QuestionBlockMaturityComponent implements OnInit {
private _timeoutId: NodeJS.Timeout;

percentAnswered = 0;
answerOptions = [];
modelAnswerOptions = [];

// tokenized placeholder for transloco, made this variable a switch between the different placeholders
altTextPlaceholder = "alt cset";
Expand Down Expand Up @@ -88,7 +88,7 @@ export class QuestionBlockMaturityComponent implements OnInit {
*/
ngOnInit(): void {
if (this.assessSvc.assessment.maturityModel.modelName != null) {
this.answerOptions = this.assessSvc.assessment.maturityModel.answerOptions;
this.modelAnswerOptions = this.assessSvc.assessment.maturityModel.answerOptions;
this.maturityModelId = this.assessSvc.assessment.maturityModel.modelId;
this.maturityModelName = this.assessSvc.assessment.maturityModel.modelName;
}
Expand Down Expand Up @@ -238,12 +238,10 @@ export class QuestionBlockMaturityComponent implements OnInit {
return;
}
if (q.visible) {

totalCount++;
if (q.answer && q.answer !== "U") {
answeredCount++;
}

}
});
this.percentAnswered = (answeredCount / totalCount) * 100;
Expand Down Expand Up @@ -300,7 +298,6 @@ export class QuestionBlockMaturityComponent implements OnInit {
this.storeAnswer(q, newAnswerValue);
}
}

}

checkReviewKeyPress(event: any, q: Question) {
Expand All @@ -310,6 +307,4 @@ export class QuestionBlockMaturityComponent implements OnInit {
}
}
}


}
Loading

0 comments on commit 513b9f7

Please sign in to comment.