diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Model/Maturity/MaturityResponse.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Model/Maturity/MaturityResponse.cs index af156eb611..f3a54fd65f 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Model/Maturity/MaturityResponse.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Model/Maturity/MaturityResponse.cs @@ -20,6 +20,11 @@ public class MaturityResponse /// public string ModelName { get; set; } = ""; + /// + /// The ID of the grouping being returned. + /// + public int GroupingId { get; set; } + /// /// The name of the current grouping represented in the response; /// diff --git a/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/MaturityController.cs b/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/MaturityController.cs index f0c2fe0e2b..4aabde9152 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/MaturityController.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/MaturityController.cs @@ -383,6 +383,7 @@ public IActionResult GetGrouping([FromQuery] int groupingId) resp.AnswerOptions.ForEach(x => x = x.Trim()); } + resp.GroupingId = groupingId; resp.Title = grouping.Title; resp.Description = grouping.Description; resp.Description_Extended = grouping.Description_Extended; diff --git a/CSETWebNg/src/app/assessment/questions/maturity-questions/maturity-questions.component.html b/CSETWebNg/src/app/assessment/questions/maturity-questions/maturity-questions.component.html index f42a5c0c30..8f2c2ecc0b 100644 --- a/CSETWebNg/src/app/assessment/questions/maturity-questions/maturity-questions.component.html +++ b/CSETWebNg/src/app/assessment/questions/maturity-questions/maturity-questions.component.html @@ -53,7 +53,7 @@

{{ groupingTitle }}

-
diff --git a/CSETWebNg/src/app/assessment/questions/maturity-questions/maturity-questions.component.ts b/CSETWebNg/src/app/assessment/questions/maturity-questions/maturity-questions.component.ts index a17294d11d..a53d5e69c7 100644 --- a/CSETWebNg/src/app/assessment/questions/maturity-questions/maturity-questions.component.ts +++ b/CSETWebNg/src/app/assessment/questions/maturity-questions/maturity-questions.component.ts @@ -58,6 +58,7 @@ export class MaturityQuestionsComponent implements OnInit, AfterViewInit { groupingTitle: string = ''; questionsAlias: string = ''; showTargetLevel = false; // TODO: set this from a new column in the DB + modelSupportsTargetLevel = false; loaded = false; @@ -196,6 +197,9 @@ export class MaturityQuestionsComponent implements OnInit, AfterViewInit { this.groupings = response.groupings; this.assessSvc.assessment.maturityModel.maturityTargetLevel = response.maturityTargetLevel; + // 100 is the default level if the model does not support a target + this.modelSupportsTargetLevel = response.maturityTargetLevel < 100; + this.assessSvc.assessment.maturityModel.answerOptions = response.answerOptions; this.filterSvc.answerOptions = response.answerOptions.slice(); this.filterSvc.maturityModelId = response.modelId; @@ -237,9 +241,9 @@ export class MaturityQuestionsComponent implements OnInit, AfterViewInit { } this.completionSvc.reset(); + this.groupings = null; this.maturitySvc.getGroupingQuestions(groupingId).subscribe((response: MaturityQuestionResponse) => { - this.modelId = response.modelId; this.modelName = response.modelName; this.questionsAlias = response.questionsAlias; @@ -387,6 +391,6 @@ export class MaturityQuestionsComponent implements OnInit, AfterViewInit { * @returns */ areGroupingsVisible() { - return this.groupings.some(g => g.visible); + return this.groupings?.some(g => g.visible); } } diff --git a/CSETWebNg/src/app/initial/my-assessments/my-assessments.component.ts b/CSETWebNg/src/app/initial/my-assessments/my-assessments.component.ts index 1474d2edb2..78e576e126 100644 --- a/CSETWebNg/src/app/initial/my-assessments/my-assessments.component.ts +++ b/CSETWebNg/src/app/initial/my-assessments/my-assessments.component.ts @@ -247,18 +247,11 @@ export class MyAssessmentsComponent implements OnInit { assessmentiDs.push(item.assessmentId); item.isEntry = false; } - let type = ''; - if (item.useDiagram) type += ', Diagram'; - item.questionAlias = 'questions'; - if (item.useMaturity) { - type += ', ' + item.selectedMaturityModel; - if (item.selectedMaturityModel === 'ISE') { - item.questionAlias = 'statements'; - } - } - if (item.useStandard && item.selectedStandards) type += ', ' + item.selectedStandards; - if (type.length > 0) type = type.substring(2); - item.type = type; + + // determine assessment type display + item.type = this.determineAssessmentType(item); + + let currentAssessmentStats = assessmentsCompletionData.find(x => x.assessmentId === item.assessmentId); item.completedQuestionsCount = currentAssessmentStats?.completedCount; item.totalAvailableQuestionsCount = @@ -298,6 +291,43 @@ export class MyAssessmentsComponent implements OnInit { ))).subscribe(); } + /** + * + */ + determineAssessmentType(item: UserAssessment) { + let type = ''; + + if (item.useDiagram) type += ', Diagram'; + item.questionAlias = 'questions'; + + if (item.useMaturity) { + type += ', ' + this.getMaturityModelShortName(item); + if (item.selectedMaturityModel === 'ISE') { + item.questionAlias = 'statements'; + } + } + if (item.useStandard && item.selectedStandards) type += ', ' + item.selectedStandards; + if (type.length > 0) type = type.substring(2); + + return type; + } + + /** + * Tries to find a "model short title" in the language files. + * If it can't find a defintion, just use the selected model's title. + */ + getMaturityModelShortName(a: UserAssessment) { + const key = `${a.selectedMaturityModel.toLowerCase()}.model short title`; + const val = this.tSvc.translate(key); + if (key == val) { + return a.selectedMaturityModel; + } + return val; + } + + /** + * + */ hasPath(rpath: string) { if (rpath != null) { localStorage.removeItem("returnPath"); diff --git a/CSETWebNg/src/app/models/questions.model.ts b/CSETWebNg/src/app/models/questions.model.ts index 916b5f6394..729e0477ab 100644 --- a/CSETWebNg/src/app/models/questions.model.ts +++ b/CSETWebNg/src/app/models/questions.model.ts @@ -45,6 +45,7 @@ export interface MaturityQuestionResponse { modelId: number; modelName: string; questionsAlias: string; + groupingId: number; title: string; levels: []; maturityTargetLevel: number;