diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/ACETMaturityBusiness.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/ACETMaturityBusiness.cs
new file mode 100644
index 0000000000..2b57960ccf
--- /dev/null
+++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/ACETMaturityBusiness.cs
@@ -0,0 +1,180 @@
+using CSETWebCore.Business.Acet;
+using CSETWebCore.DataLayer.Manual;
+using CSETWebCore.DataLayer.Model;
+using CSETWebCore.Interfaces.AdminTab;
+using CSETWebCore.Interfaces.Helpers;
+using CSETWebCore.Model.Maturity;
+using CSETWebCore.Model.Question;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CSETWebCore.Business.Maturity
+{
+ public class ACETMaturityBusiness : MaturityBusiness
+ {
+ private CSETContext _context;
+ public ACETMaturityBusiness(CSETContext context, IAssessmentUtil assessmentUtil, IAdminTabBusiness adminTabBusiness) : base(context, assessmentUtil, adminTabBusiness)
+ {
+ this._context = context;
+ }
+
+ public AVAILABLE_MATURITY_MODELS ProcessModelDefaults(int assessmentId, string installationMode)
+ {
+ //if the available maturity model is not selected and the application is CSET
+ //the default is EDM
+ //if the application is ACET the default is ACET
+
+ return base.ProcessModelDefaults(assessmentId, installationMode, 1);
+ }
+
+ // --
+
+ public MaturityResponse GetMaturityQuestions(int assessmentId, string installationMode, bool fill, int groupingId, bool spanishFlag = false)
+ {
+ var response = new MaturityResponse();
+ var myModel = ProcessModelDefaults(assessmentId, installationMode, 1);
+
+ var myModelDefinition = _context.MATURITY_MODELS.Where(x => x.Maturity_Model_Id == myModel.model_id).FirstOrDefault();
+
+ if (myModelDefinition == null)
+ {
+ return response;
+ }
+
+ response.ModelId = myModelDefinition.Maturity_Model_Id;
+ response.ModelName = myModelDefinition.Model_Name;
+
+ if (response.ModelName == "ACET")
+ {
+ response.OverallIRP = GetOverallIrpNumber(assessmentId);
+ response.MaturityTargetLevel = response.OverallIRP;
+ }
+
+ response = base.GetMaturityQuestions(assessmentId, installationMode, fill, groupingId, spanishFlag);
+
+ return response;
+ }
+
+
+
+ ///
+ /// Returns the percentage of maturity questions that have been answered for the
+ /// current maturity level (IRP).
+ ///
+ ///
+ ///
+ public double GetAnswerCompletionRate(int assessmentId)
+ {
+ var irp = GetOverallIrpNumber(assessmentId);
+
+ // get the highest maturity level for the risk level (use the stairstep model)
+ var topMatLevel = GetTopMatLevelForRisk(irp);
+
+ var answerDistribution = _context.AcetAnswerDistribution(assessmentId, topMatLevel).ToList();
+
+ var answeredCount = 0;
+ var totalCount = 0;
+ foreach (var d in answerDistribution)
+ {
+ if (d.Answer_Text != "U")
+ {
+ answeredCount += d.Count;
+ }
+ totalCount += d.Count;
+ }
+
+ return ((double)answeredCount / (double)totalCount) * 100d;
+ }
+
+
+ ///
+ /// Returns the percentage of maturity questions that have been answered for the
+ /// current maturity level (IRP).
+ ///
+ ///
+ ///
+ public double GetIseAnswerCompletionRate(int assessmentId)
+ {
+ var irp = GetOverallIseIrpNumber(assessmentId);
+
+ // get the highest maturity level for the risk level (use the stairstep model)
+ var topMatLevel = GetIseTopMatLevelForRisk(irp);
+
+ var answerDistribution = _context.IseAnswerDistribution(assessmentId, topMatLevel).ToList();
+
+ var answeredCount = 0;
+ var totalCount = 0;
+ foreach (var d in answerDistribution)
+ {
+ if (d.Answer_Text != "U")
+ {
+ answeredCount += d.Count;
+ }
+ totalCount += d.Count;
+ }
+
+ return ((double)answeredCount / (double)totalCount) * 100d;
+ }
+
+
+
+ ///
+ /// Using the 'stairstep' model, determines the highest maturity level
+ /// that corresponds to the specified IRP/risk.
+ ///
+ /// This stairstep model must match the stairstep defined in the UI -- getStairstepRequired(),
+ /// though this method only returns the top level.
+ ///
+ ///
+ ///
+ private int GetTopMatLevelForRisk(int irp)
+ {
+ switch (irp)
+ {
+ case 1:
+ case 2:
+ return 1; // Baseline
+ case 3:
+ return 2; // Evolving
+ case 4:
+ return 3; // Intermediate
+ case 5:
+ return 4; // Advanced
+ }
+
+ return 0;
+ }
+
+
+ ///
+ /// Using the 'stairstep' model, determines the highest maturity level
+ /// that corresponds to the specified IRP/risk.
+ ///
+ /// This stairstep model must match the stairstep defined in the UI -- getStairstepRequired(),
+ /// though this method only returns the top level.
+ ///
+ ///
+ ///
+ private int GetIseTopMatLevelForRisk(int irp)
+ {
+ switch (irp)
+ {
+ case 1:
+ return 1; // SCUEP
+ case 2:
+ return 2; // CORE
+ case 3:
+ return 3; // CORE+
+ }
+
+ return 0;
+ }
+
+
+
+ }
+}
diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/MaturityBusiness.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/MaturityBusiness.cs
index 8e04e8388a..04b839f006 100644
--- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/MaturityBusiness.cs
+++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/MaturityBusiness.cs
@@ -618,11 +618,12 @@ public void PersistMaturityLevel(int assessmentId, int level)
}
- public AVAILABLE_MATURITY_MODELS ProcessModelDefaults(int assessmentId, string installationMode)
+ public AVAILABLE_MATURITY_MODELS ProcessModelDefaults(int assessmentId, string installationMode, int maturityModelId = 3)
{
//if the available maturity model is not selected and the application is CSET
//the default is EDM
//if the application is ACET the default is ACET
+ //see ACETMaturityBusiness implementation
var myModel = _context.AVAILABLE_MATURITY_MODELS
.Include(x => x.model)
@@ -632,7 +633,7 @@ public AVAILABLE_MATURITY_MODELS ProcessModelDefaults(int assessmentId, string i
myModel = new AVAILABLE_MATURITY_MODELS()
{
Assessment_Id = assessmentId,
- model_id = (installationMode == "ACET") ? 1 : 3,
+ model_id = maturityModelId,
Selected = true
};
_context.AVAILABLE_MATURITY_MODELS.Add(myModel);
@@ -814,7 +815,11 @@ private LevelScore GetLevelScoreQuestions(Model.Nested.Grouping group, string le
public MaturityResponse GetMaturityQuestions(int assessmentId, string installationMode, bool fill, int groupingId, bool spanishFlag = false)
{
var response = new MaturityResponse();
+ return GetMaturityQuestions(assessmentId, installationMode, fill, groupingId, response, spanishFlag);
+ }
+ public MaturityResponse GetMaturityQuestions(int assessmentId, string installationMode, bool fill, int groupingId, MaturityResponse response, bool spanishFlag = false)
+ {
if (fill)
{
_context.FillEmptyMaturityQuestionsForAnalysis(assessmentId);
@@ -846,13 +851,6 @@ public MaturityResponse GetMaturityQuestions(int assessmentId, string installati
response.MaturityTargetLevel = GetMaturityTargetLevel(assessmentId);
- if (response.ModelName == "ACET")
- {
- response.OverallIRP = GetOverallIrpNumber(assessmentId);
- response.MaturityTargetLevel = response.OverallIRP;
- }
-
-
// get the levels and their display names for this model
response.Levels = GetMaturityLevelsForModel(myModel.model_id, response.MaturityTargetLevel);
@@ -1170,119 +1168,6 @@ public int StoreAnswer(int assessmentId, Answer answer)
}
- ///
- /// Returns the percentage of maturity questions that have been answered for the
- /// current maturity level (IRP).
- ///
- ///
- ///
- public double GetAnswerCompletionRate(int assessmentId)
- {
- var irp = GetOverallIrpNumber(assessmentId);
-
- // get the highest maturity level for the risk level (use the stairstep model)
- var topMatLevel = GetTopMatLevelForRisk(irp);
-
- var answerDistribution = _context.AcetAnswerDistribution(assessmentId, topMatLevel).ToList();
-
- var answeredCount = 0;
- var totalCount = 0;
- foreach (var d in answerDistribution)
- {
- if (d.Answer_Text != "U")
- {
- answeredCount += d.Count;
- }
- totalCount += d.Count;
- }
-
- return ((double)answeredCount / (double)totalCount) * 100d;
- }
-
-
- ///
- /// Returns the percentage of maturity questions that have been answered for the
- /// current maturity level (IRP).
- ///
- ///
- ///
- public double GetIseAnswerCompletionRate(int assessmentId)
- {
- var irp = GetOverallIseIrpNumber(assessmentId);
-
- // get the highest maturity level for the risk level (use the stairstep model)
- var topMatLevel = GetIseTopMatLevelForRisk(irp);
-
- var answerDistribution = _context.IseAnswerDistribution(assessmentId, topMatLevel).ToList();
-
- var answeredCount = 0;
- var totalCount = 0;
- foreach (var d in answerDistribution)
- {
- if (d.Answer_Text != "U")
- {
- answeredCount += d.Count;
- }
- totalCount += d.Count;
- }
-
- return ((double)answeredCount / (double)totalCount) * 100d;
- }
-
-
- ///
- /// Using the 'stairstep' model, determines the highest maturity level
- /// that corresponds to the specified IRP/risk.
- ///
- /// This stairstep model must match the stairstep defined in the UI -- getStairstepRequired(),
- /// though this method only returns the top level.
- ///
- ///
- ///
- private int GetTopMatLevelForRisk(int irp)
- {
- switch (irp)
- {
- case 1:
- case 2:
- return 1; // Baseline
- case 3:
- return 2; // Evolving
- case 4:
- return 3; // Intermediate
- case 5:
- return 4; // Advanced
- }
-
- return 0;
- }
-
-
- ///
- /// Using the 'stairstep' model, determines the highest maturity level
- /// that corresponds to the specified IRP/risk.
- ///
- /// This stairstep model must match the stairstep defined in the UI -- getStairstepRequired(),
- /// though this method only returns the top level.
- ///
- ///
- ///
- private int GetIseTopMatLevelForRisk(int irp)
- {
- switch (irp)
- {
- case 1:
- return 1; // SCUEP
- case 2:
- return 2; // CORE
- case 3:
- return 3; // CORE+
- }
-
- return 0;
- }
-
-
// The methods that follow were originally built for NCUA/ACET.
// It is hoped that they will eventually be refactored to fit a more
// 'generic' approach to maturity models.
diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Interfaces/Maturity/IMaturityBusiness.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Interfaces/Maturity/IMaturityBusiness.cs
index 7794d3fecd..1838b9d751 100644
--- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Interfaces/Maturity/IMaturityBusiness.cs
+++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Interfaces/Maturity/IMaturityBusiness.cs
@@ -23,7 +23,6 @@ public interface IMaturityBusiness
void PersistSelectedMaturityModel(int assessmentId, string modelName);
void ClearMaturityModel(int assessmentId);
void PersistMaturityLevel(int assessmentId, int level);
- AVAILABLE_MATURITY_MODELS ProcessModelDefaults(int assessmentId, string installationMode);
object GetEdmPercentScores(int assessmentId);
MaturityResponse GetMaturityQuestions(int assessmentId, string installationMode, bool fill, int groupingId, bool spanishFlag);
@@ -33,7 +32,6 @@ void BuildSubGroupings(MaturityGrouping g, int? parentID,
List answers);
int StoreAnswer(int assessmentId, Answer answer);
- double GetAnswerCompletionRate(int assessmentId);
List GetMaturityAnswers(int assessmentId, bool spanishFlag = false);
bool GetTargetBandOnly(int assessmentId);
void SetTargetBandOnly(int assessmentId, bool value);
diff --git a/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/MaturityController.cs b/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/MaturityController.cs
index 72a2aefd37..7ca0e74c70 100644
--- a/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/MaturityController.cs
+++ b/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/MaturityController.cs
@@ -137,7 +137,10 @@ public IActionResult SetMaturityLevel([FromBody] int level)
public IActionResult GetQuestions([FromQuery] string installationMode, bool fill, int groupingId = 0, bool spanishFlag = false)
{
int assessmentId = _tokenManager.AssessmentForUser();
-
+ if (installationMode == "ACET")
+ {
+ return Ok(new ACETMaturityBusiness(_context, _assessmentUtil, _adminTabBusiness).GetMaturityQuestions(assessmentId, installationMode, fill, groupingId, spanishFlag));
+ }
return Ok(new MaturityBusiness(_context, _assessmentUtil, _adminTabBusiness).GetMaturityQuestions(assessmentId, installationMode, fill, groupingId, spanishFlag));
}
@@ -488,7 +491,7 @@ public IActionResult GetAnswerCompletionRate()
{
int assessmentId = _tokenManager.AssessmentForUser();
- return Ok(new MaturityBusiness(_context, _assessmentUtil, _adminTabBusiness).GetAnswerCompletionRate(assessmentId));
+ return Ok(new ACETMaturityBusiness(_context, _assessmentUtil, _adminTabBusiness).GetAnswerCompletionRate(assessmentId));
}
@@ -502,7 +505,7 @@ public IActionResult GetIseAnswerCompletionRate()
{
int assessmentId = _tokenManager.AssessmentForUser();
- return Ok(new MaturityBusiness(_context, _assessmentUtil, _adminTabBusiness).GetIseAnswerCompletionRate(assessmentId));
+ return Ok(new ACETMaturityBusiness(_context, _assessmentUtil, _adminTabBusiness).GetIseAnswerCompletionRate(assessmentId));
}