Skip to content

Commit

Permalink
Merge pull request #3461 from cisagov/feature/tsa-sd
Browse files Browse the repository at this point in the history
Feature/tsa sd
  • Loading branch information
randywoods authored Aug 18, 2023
2 parents 43a31f1 + 04cf5cc commit cc108e5
Show file tree
Hide file tree
Showing 19 changed files with 5,616 additions and 4,248 deletions.
Binary file modified .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,26 @@ public HorizBarChart GetDeficiencyChartData()
return null;
}

public HorizBarChart GetDeficiencyChartDataSd()
{
HorizBarChart hChart = new HorizBarChart();
var info = _context.INFORMATION.Where(x => x.Id == _assessmentId).FirstOrDefault();
if (info != null)
{
int maturityModel = (int)MaturityModel.SD;
var groupings = _context.MATURITY_GROUPINGS.Where(x => x.Maturity_Model_Id == maturityModel).ToList();
var ordered = groupings.OrderBy(x => x.Sequence);
var currentScore = new ChartDataSet();
hChart.ReportTitle = "Ranked Deficiency Report";
currentScore.Label = "Current";
foreach (var group in groupings)
{
hChart.Labels.Add(group.Sequence + ". " + group.Title);
}
}

return null;
}

/// <summary>
/// Builds a list of horizontal bar chart section scoring data.
Expand Down
36 changes: 36 additions & 0 deletions CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/CisScoring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,42 @@ public CisScoring(NestedQuestions model)
QuestionsModel = model;
}

/// <summary>
/// Calculates the SD Score for grouping
/// </summary>
/// <returns></returns>
public Score CalculateGroupingScoreSD()
{
if (QuestionsModel.Groupings.FirstOrDefault()?.Questions != null)
{
FlattenQuestions(QuestionsModel.Groupings.FirstOrDefault()?.Questions);
if (allWeights.Any())
{
var grouped = allWeights.GroupBy(q => q.QuestionText).Select(r => new GroupedQuestions
{
QuestionText = r.Key,
OptionQuestions = r.ToList()
});
var sumGroupWeights = from g in grouped
select new RollupOptions
{
Type = g.OptionQuestions.FirstOrDefault().Type,
Weight = 1
};
var sumAllWeights = (decimal)sumGroupWeights.Sum(x => x.Weight);
var totalGroupWeights = from g in grouped
select new RollupOptions()
{
Type = g.OptionQuestions.FirstOrDefault().Type,
Weight = 1
};
var sumTotalWeights = (decimal)totalGroupWeights.Sum(x => x?.Weight);
decimal total = sumAllWeights != 0 ? sumTotalWeights / sumAllWeights : 0;
}
}

return null;
}

/// <summary>
/// Calculates the CIS score for a grouping/section.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ public enum MaturityModel
CMMC2=6,
VADR=7,
CIS=8,
SD=14
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public UserAccountSecurityManager(
/// <param name="sendEmail">Indicates if the temp password email should be sent immediately</param>
/// <returns></returns>
public bool CreateUser(CreateUser info, bool sendEmail)
{
{
try
{
// Create the USER and USER_DETAIL_INFORMATION records for this new user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using CSETWebCore.Api.Interfaces;
using NLog;
using CSETWebCore.Model.Nested;
using DocumentFormat.OpenXml.Office2013.Excel;
using J2N.Numerics;

namespace CSETWebCore.Api.Controllers
Expand Down Expand Up @@ -651,7 +652,80 @@ public IActionResult GetDeficiencyList()
return Ok();
}
}


[HttpGet]
[Route("api/getMaturityDeficiencyListSd")]
public IActionResult GetDeficiencyListSd()
{
int assessmentId = _tokenManager.AssessmentForUser();

var biz = new NestedStructure(assessmentId, 0, _context);
List<Grouping> filteredGroupings = new List<Grouping>();

foreach (var b in biz.MyModel.Groupings)
{
bool includeGrouping = false;
var questions = new List<Question>();
foreach (var q in b.Questions)
{
bool includeQ = false;
var question = new Question();
if (q.AnswerText == "U")
{
if (q.Options.Any(x => x.OptionType.ToLower() == "radio"))
{
includeQ = true;
question = new Question()
{
QuestionType = q.QuestionType,
DisplayNumber = q.DisplayNumber,
QuestionText = q.QuestionText,
MarkForReview = q.MarkForReview,
AnswerText = "U"
};
}
}

if (q.AnswerText == "S")
{
if (q.Options.Any(x =>
x.Selected && x.OptionText == "No" && x.OptionType.ToLower() == "radio"))
{
includeQ = true;
question = new Question()
{
QuestionType = q.QuestionType,
DisplayNumber = q.DisplayNumber,
QuestionText = q.QuestionText,
MarkForReview = q.MarkForReview,
AnswerText = "N"
};
}
}

if (includeQ)
{
includeGrouping = true;
questions.Add(question);
}
}

if (includeGrouping)
{
includeGrouping = false;
filteredGroupings.Add( new Grouping
{
Title = b.Title,
Questions = questions
});
questions = new List<Question>();
}
}


return Ok(filteredGroupings);
}

/// <summary>
/// get all comments and marked for review
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,5 @@ public IActionResult GetGoalPerformance()

return Ok(new { ScoreBarCharts = scoreBarCharts, StackedBarCharts = stackedBarCharts });
}


public IActionResult Index()
{
return View();
}
}
}
Loading

0 comments on commit cc108e5

Please sign in to comment.