-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3442 from cisagov/feature/CSET-2320
Refactored icon and answer configuration to support IMR
- Loading branch information
Showing
50 changed files
with
1,958 additions
and
289 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/ReportsCmuController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
//////////////////////////////// | ||
// | ||
// Copyright 2023 Battelle Energy Alliance, LLC | ||
// | ||
// | ||
//////////////////////////////// | ||
using CSETWebCore.DataLayer.Model; | ||
using CSETWebCore.Helpers.ReportWidgets; | ||
using CSETWebCore.Interfaces.AdminTab; | ||
using CSETWebCore.Interfaces.Assessment; | ||
using CSETWebCore.Interfaces.Crr; | ||
using CSETWebCore.Interfaces.Demographic; | ||
using CSETWebCore.Interfaces.Helpers; | ||
using CSETWebCore.Interfaces.Reports; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Xml.Linq; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
|
||
namespace CSETWebCore.Api.Controllers | ||
{ | ||
/// <summary> | ||
/// Common API intended to supply report content for EDM, CRR and IMR. | ||
/// </summary> | ||
public class ReportsCmuController : Controller | ||
{ | ||
private readonly ITokenManager _token; | ||
private readonly ICrrScoringHelper _crr; | ||
private readonly IAssessmentBusiness _assessment; | ||
private readonly IDemographicBusiness _demographic; | ||
private readonly IAssessmentUtil _assessmentUtil; | ||
private readonly IAdminTabBusiness _adminTabBusiness; | ||
private readonly IReportsDataBusiness _report; | ||
private readonly CSETContext _context; | ||
|
||
public ReportsCmuController(ITokenManager token, ICrrScoringHelper crr, IAssessmentBusiness assessment, | ||
IDemographicBusiness demographic, IReportsDataBusiness report, | ||
IAssessmentUtil assessmentUtil, IAdminTabBusiness admin, CSETContext context) | ||
{ | ||
_token = token; | ||
_crr = crr; | ||
_assessment = assessment; | ||
_demographic = demographic; | ||
_report = report; | ||
_assessmentUtil = assessmentUtil; | ||
_adminTabBusiness = admin; | ||
_context = context; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Gets the charts for Mil1 Performance and returns them in a list of raw HTML strings. | ||
/// </summary> | ||
/// <returns></returns> | ||
[HttpGet] | ||
[Route("api/report/cmu/goalperformance")] | ||
public IActionResult GetGoalPerformance() | ||
{ | ||
var assessmentId = _token.AssessmentForUser(); | ||
_crr.InstantiateScoringHelper(assessmentId); | ||
var XDocument = _crr.XDoc; | ||
|
||
List<string> scoreBarCharts = new List<string>(); | ||
List<object> stackedBarCharts = new List<object>(); | ||
|
||
foreach (XElement domain in XDocument.Root.Elements()) | ||
{ | ||
var domainScores = _crr.MIL1DomainAnswerDistrib(domain.Attribute("abbreviation").Value); | ||
var barChartInput = new BarChartInput() { Height = 50, Width = 75 }; | ||
barChartInput.IncludePercentFirstBar = true; | ||
barChartInput.AnswerCounts = new List<int> { domainScores.Green, domainScores.Yellow, domainScores.Red }; | ||
scoreBarCharts.Add(new ScoreBarChart(barChartInput).ToString()); | ||
|
||
var goals = domain.Descendants("Mil").FirstOrDefault().Descendants("Goal"); | ||
|
||
foreach (XElement goal in goals) | ||
{ | ||
var goalScores = _crr.GoalAnswerDistrib(domain.Attribute("abbreviation").Value, | ||
goal.Attribute("abbreviation").Value); | ||
var stackedBarChartInput = new BarChartInput() { Height = 10, Width = 265 }; | ||
stackedBarChartInput.AnswerCounts = new List<int> { goalScores.Green, goalScores.Yellow, goalScores.Red }; | ||
|
||
stackedBarCharts.Add(new { Title = goal.Attribute("title").Value, Chart = new ScoreStackedBarChart(stackedBarChartInput).ToString() }); | ||
} | ||
} | ||
|
||
return Ok(new { ScoreBarCharts = scoreBarCharts, StackedBarCharts = stackedBarCharts }); | ||
} | ||
|
||
|
||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.