Skip to content

Commit 8d38416

Browse files
TD-5563 Implementing the missing requirement
1 parent 67e8296 commit 8d38416

File tree

6 files changed

+123
-15
lines changed

6 files changed

+123
-15
lines changed

DigitalLearningSolutions.Data/DataServices/CompetencyAssessmentDataService.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public interface ICompetencyAssessmentDataService
3434
IEnumerable<LinkedFramework> GetLinkedFrameworksForCompetencyAssessment(int competencyAssessmentId);
3535
int[] GetLinkedFrameworkCompetencyIds(int competencyAssessmentId, int frameworkId);
3636
CompetencyAssessmentFeatures? GetCompetencyAssessmentFeaturesTaskStatus(int competencyAssessmentId);
37+
int? GetSelfAssessmentStructure(int competencyAssessmentId);
3738

3839
//UPDATE DATA
3940
bool UpdateCompetencyAssessmentName(int competencyAssessmentId, int adminId, string competencyAssessmentName);
@@ -877,5 +878,13 @@ public bool UpdatePrimaryFrameworkCompetencies(int assessmentId, int frameworkId
877878
}
878879
return true;
879880
}
881+
882+
public int? GetSelfAssessmentStructure(int competencyAssessmentId)
883+
{
884+
return connection.QueryFirstOrDefault<int>(
885+
@"SELECT 1 from dbo.SelfAssessmentStructure where selfassessmentid = @competencyAssessmentId",
886+
new { competencyAssessmentId }
887+
);
888+
}
880889
}
881890
}

DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ public IActionResult CompetencyAssessmentFeatures(CompetencyAssessmentFeaturesVi
680680
[Route("/CompetencyAssessments/Framework/{frameworkId}/{competencyAssessmentId}/Summary")]
681681
public IActionResult CompetencyAssessmentSummary(int competencyAssessmentId, int? frameworkId = null)
682682
{
683-
683+
if (competencyAssessmentService.GetSelfAssessmentStructure(competencyAssessmentId) != 0) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 410 });
684684
if (competencyAssessmentId == 0) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
685685
var data = GetcompetencyAssessmentFeaturesData();
686686
if (data == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 500 });
@@ -692,6 +692,7 @@ public IActionResult CompetencyAssessmentSummary(int competencyAssessmentId, int
692692
public IActionResult CompetencyAssessmentSummary(CompetencyAssessmentFeaturesViewModel competency)
693693
{
694694
var data = GetcompetencyAssessmentFeaturesData();
695+
if (competencyAssessmentService.GetSelfAssessmentStructure(data.ID) != 0) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 410 });
695696
if (data.ID == 0) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
696697
var features = competencyAssessmentService.UpdateCompetencyAssessmentFeaturesTaskStatus(data.ID,
697698
data.DescriptionStatus,
@@ -707,30 +708,31 @@ public IActionResult CompetencyAssessmentSummary(CompetencyAssessmentFeaturesVie
707708
TempData.Clear();
708709
return RedirectToAction("ManageCompetencyAssessment", new { competencyAssessmentId = competency.ID, competency.FrameworkId });
709710
}
710-
[Route("/CompetencyAssessments/{competencyAssessmentId}/Frameworks/{frameworkId}/Change")]
711-
public IActionResult ConfirmChangePrimaryFramework(int frameworkId, int competencyAssessmentId)
711+
[Route("/CompetencyAssessments/{competencyAssessmentId}/Frameworks/{frameworkId}/Make")]
712+
public IActionResult ConfirmMaKePrimaryFramework(int frameworkId, int competencyAssessmentId)
712713
{
713714
var adminId = GetAdminID();
714715
var competencyAssessmentBase = competencyAssessmentService.GetCompetencyAssessmentBaseById(competencyAssessmentId, adminId);
715716
var framework = frameworkService.GetFrameworkDetailByFrameworkId(frameworkId, adminId);
716-
var model = new ConfirmChangePrimaryFrameworkViewModel(competencyAssessmentBase, framework);
717-
return View("ConfirmChangePrimaryFramework", model);
717+
var model = new ConfirmMakePrimaryFrameworkViewModel(competencyAssessmentBase, framework);
718+
return View("ConfirmMaKePrimaryFramework", model);
718719
}
719720
[HttpPost]
720-
[Route("/CompetencyAssessments/{competencyAssessmentId}/Frameworks/{frameworkId}/Change")]
721-
public IActionResult ConfirmChangePrimaryFramework(ConfirmChangePrimaryFrameworkViewModel model)
721+
[Route("/CompetencyAssessments/{competencyAssessmentId}/Frameworks/{frameworkId}/Make")]
722+
public IActionResult ConfirmMaKePrimaryFramework(ConfirmMakePrimaryFrameworkViewModel model)
722723
{
723724
if (!ModelState.IsValid)
724725
{
725-
return View("ConfirmChangePrimaryFramework", model);
726+
return View("ConfirmMaKePrimaryFramework", model);
726727
}
727728
competencyAssessmentService.UpdatePrimaryFrameworkCompetencies(model.CompetencyAssessmentId, model.FrameworkId);
728-
var baseModel = new CompetencyAssessmentFeaturesViewModel(model.CompetencyAssessmentId,
729-
model.FrameworkName,
730-
model.UserRole,
731-
model.FrameworkId);
732-
SetcompetencyAssessmentFeaturesData(baseModel);
733-
return RedirectToAction("CompetencyAssessmentFeatures", new { model.CompetencyAssessmentId, model.FrameworkId });
729+
var features = competencyAssessmentService.UpdateCompetencyAssessmentFeaturesTaskStatus(model.CompetencyAssessmentId,
730+
model.DescriptionStatus,
731+
model.ProviderandCategoryStatus,
732+
model.VocabularyStatus,
733+
model.WorkingGroupStatus,
734+
model.AllframeworkCompetenciesStatus);
735+
return RedirectToAction("ManageCompetencyAssessment", new { model.CompetencyAssessmentId, model.FrameworkId });
734736
}
735737
private void SetcompetencyAssessmentFeaturesData(CompetencyAssessmentFeaturesViewModel data)
736738
{

DigitalLearningSolutions.Web/Services/CompetencyAssessmentService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public interface ICompetencyAssessmentService
3131

3232
int[] GetLinkedFrameworkCompetencyIds(int competencyAssessmentId, int frameworkId);
3333
CompetencyAssessmentFeatures? GetCompetencyAssessmentFeaturesTaskStatus(int competencyAssessmentId);
34+
int? GetSelfAssessmentStructure(int competencyAssessmentId);
3435

3536
//UPDATE DATA
3637
bool UpdateCompetencyAssessmentName(int competencyAssessmentId, int adminId, string competencyAssessmentName);
@@ -291,5 +292,9 @@ public bool UpdatePrimaryFrameworkCompetencies(int assessmentId, int frameworkI
291292
{
292293
return competencyAssessmentDataService.UpdatePrimaryFrameworkCompetencies(assessmentId, frameworkId);
293294
}
295+
public int? GetSelfAssessmentStructure(int competencyAssessmentId)
296+
{
297+
return competencyAssessmentDataService.GetSelfAssessmentStructure(competencyAssessmentId);
298+
}
294299
}
295300
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using DigitalLearningSolutions.Data.Models.CompetencyAssessments;
2+
using DigitalLearningSolutions.Data.Models.Frameworks;
3+
using DigitalLearningSolutions.Web.Attributes;
4+
5+
namespace DigitalLearningSolutions.Web.ViewModels.CompetencyAssessments
6+
{
7+
public class ConfirmMakePrimaryFrameworkViewModel
8+
{
9+
public ConfirmMakePrimaryFrameworkViewModel()
10+
{}
11+
public ConfirmMakePrimaryFrameworkViewModel(CompetencyAssessmentBase competencyAssessmentBase, DetailFramework framework)
12+
{
13+
CompetencyAssessmentId = competencyAssessmentBase.ID;
14+
AssessmentName = competencyAssessmentBase.CompetencyAssessmentName;
15+
FrameworkName = framework.FrameworkName;
16+
FrameworkId = framework.ID;
17+
Vocabulary = competencyAssessmentBase.Vocabulary;
18+
}
19+
public int CompetencyAssessmentId { get; set; }
20+
public int UserRole { get; set; }
21+
public string? AssessmentName { get; set; }
22+
public string? FrameworkName { get; set; }
23+
public int FrameworkId { get; set; }
24+
public string? Vocabulary { get; set; }
25+
[BooleanMustBeTrue(ErrorMessage = "You need to confirm that you want to make this the primary framework")]
26+
public bool Confirm { get; set; }
27+
public bool DescriptionStatus { get; set; }
28+
public bool ProviderandCategoryStatus { get; set; }
29+
public bool VocabularyStatus { get; set; }
30+
public bool WorkingGroupStatus { get; set; }
31+
public bool AllframeworkCompetenciesStatus { get; set; }
32+
}
33+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@using DigitalLearningSolutions.Web.Helpers
2+
@using DigitalLearningSolutions.Web.ViewModels.CompetencyAssessments
3+
@model ConfirmMakePrimaryFrameworkViewModel;
4+
@{
5+
var errorHasOccurred = !ViewData.ModelState.IsValid;
6+
ViewData["Title"] = "Competency Assessments - Change primary framework";
7+
}
8+
<div class="nhsuk-grid-row">
9+
<div class="nhsuk-grid-column-full">
10+
@if (errorHasOccurred)
11+
{
12+
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.Confirm) })" />
13+
}
14+
15+
<h1 class="nhsuk-heading-xl">Make @Model.FrameworkName primary framework</h1>
16+
<h2>Which features of the framework do you want to copy into this @Model.FrameworkName framework?</h2>
17+
</div>
18+
</div>
19+
<div class="nhsuk-grid-row">
20+
<div class="nhsuk-grid-column-full">
21+
<form class="nhsuk-u-margin-bottom-3" method="post" asp-action="ConfirmMakePrimaryFramework">
22+
<nhs-form-group>
23+
<vc:single-checkbox asp-for="@nameof(Model.DescriptionStatus)" label="Description" hint-text="The framework description will be copied into the competency assessment description."></vc:single-checkbox>
24+
</nhs-form-group>
25+
<nhs-form-group>
26+
<vc:single-checkbox asp-for="@nameof(Model.ProviderandCategoryStatus)" label="Provider and category" hint-text="The framework branding (provider and category) will be copied."></vc:single-checkbox>
27+
</nhs-form-group>
28+
<nhs-form-group>
29+
<vc:single-checkbox asp-for="@nameof(Model.VocabularyStatus)" label="Vocabulary" hint-text="The framework vocabulary (such as proficiency, competency, or capability) will be copied."></vc:single-checkbox>
30+
</nhs-form-group>
31+
<nhs-form-group>
32+
<vc:single-checkbox asp-for="@nameof(Model.WorkingGroupStatus)" label="Working group" hint-text="Contributors and reviewers from the framework will be copied."></vc:single-checkbox>
33+
</nhs-form-group>
34+
<nhs-form-group>
35+
<vc:single-checkbox asp-for="@nameof(Model.AllframeworkCompetenciesStatus)" label="All framework competencies" hint-text="All competencies in the framework will be copied."></vc:single-checkbox>
36+
</nhs-form-group>
37+
<input type="hidden" asp-for="CompetencyAssessmentId" />
38+
<input type="hidden" asp-for="FrameworkId" />
39+
<input type="hidden" asp-for="FrameworkName" />
40+
<input type="hidden" asp-for="AssessmentName" />
41+
<input type="hidden" asp-for="UserRole" />
42+
<input type="hidden" asp-for="Vocabulary" />
43+
44+
<vc:single-checkbox asp-for="@nameof(Model.Confirm)"
45+
label="I am sure that I wish to make @Model.FrameworkName the primary framework"
46+
hint-text="" />
47+
48+
<button class="nhsuk-button" type="submit">Make primary framework</button>
49+
</form>
50+
<div class="nhsuk-back-link">
51+
<a class="nhsuk-back-link__link" asp-action="SelectFrameworkSources" asp-route-actionName="Summary" asp-route-competencyAssessmentId="@ViewContext.RouteData.Values["competencyAssessmentId"]">
52+
<svg class="nhsuk-icon nhsuk-icon__chevron-left" focusable='false' xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
53+
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
54+
</svg>
55+
Cancel
56+
</a>
57+
</div>
58+
</div>
59+
</div>

DigitalLearningSolutions.Web/Views/CompetencyAssessments/SelectFrameworkSources.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
</a>
7373
</li>
7474
<li class="nhsuk-summary-list__actions-list-item">
75-
<a asp-action="ConfirmChangePrimaryFramework"
75+
<a asp-action="ConfirmMaKePrimaryFramework"
7676
asp-route-frameworkId="@Model.AdditionalFrameworks.ElementAt(i).ID"
7777
asp-route-competencyAssessmentId="@ViewContext.RouteData.Values["competencyAssessmentId"]">
7878
Make primary <span class="nhsuk-u-visually-hidden">@Model.AdditionalFrameworks.ElementAt(i).FrameworkName</span>

0 commit comments

Comments
 (0)