Skip to content

Commit

Permalink
Add logic for nice short assessment description on landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
randywoods1 committed Dec 20, 2024
1 parent 97bf10f commit d95c76d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public class MaturityResponse
/// </summary>
public string ModelName { get; set; } = "";

/// <summary>
/// The ID of the grouping being returned.
/// </summary>
public int GroupingId { get; set; }

/// <summary>
/// The name of the current grouping represented in the response;
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h4>{{ groupingTitle }}</h4>
</div>
</div>

<div *ngIf="!!groupings && !areGroupingsVisible()"
<div *ngIf="!!groupings && !areGroupingsVisible() && modelSupportsTargetLevel"
class="alert-warning mt-4 mb-4 d-flex flex-row justify-content-center align-items-center flex-11a">
<span class="p-md-3 p-2 fs-large cset-icons-exclamation-triangle"></span>
<span class="fs-base-3 p-2 d-flex flex-column justify-content-center flex-11a">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions CSETWebNg/src/app/models/questions.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface MaturityQuestionResponse {
modelId: number;
modelName: string;
questionsAlias: string;
groupingId: number;
title: string;
levels: [];
maturityTargetLevel: number;
Expand Down

0 comments on commit d95c76d

Please sign in to comment.