Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ string direction
public bool UpdateCompetencyAssessmentFeaturesTaskStatus(int id, bool descriptionStatus, bool providerandCategoryStatus, bool vocabularyStatus,
bool workingGroupStatus, bool AllframeworkCompetenciesStatus);
void UpdateSelfAssessmentFromFramework(int selfAssessmentId, int? frameworkId);
bool UpdatePrimaryFrameworkCompetencies(int assessmentId, int frameworkId);

//INSERT DATA
int InsertCompetencyAssessment(int adminId, int centreId, string competencyAssessmentName);
Expand Down Expand Up @@ -857,13 +858,33 @@ FROM FrameworkCompetencies AS FC

return true;
}
public bool UpdatePrimaryFrameworkCompetencies(int assessmentId, int frameworkId)
{
var numberOfAffectedRows = connection.Execute(
@"UPDATE SelfAssessmentFrameworks SET IsPrimary = 0 WHERE (SelfAssessmentId = @assessmentId) AND (RemovedDate IS NULL)",
new { assessmentId, frameworkId }
);
var numberOfAffectedRow = connection.Execute(
@"UPDATE SelfAssessmentFrameworks SET IsPrimary = 1 WHERE (SelfAssessmentId = @assessmentId) AND (FrameworkId = @frameworkId ) AND (RemovedDate IS NULL)",
new { assessmentId, frameworkId }
);
if (numberOfAffectedRow < 1)
{
logger.LogWarning(
"Not updating SelfAssessmentFrameworks as db update failed. " +
$"assessmentId: {assessmentId}, frameworkId: {frameworkId}"
);
return false;
}
return true;
}

public int? GetSelfAssessmentStructure(int competencyAssessmentId)
{
return connection.QueryFirstOrDefault<int>(
@"SELECT 1 from dbo.SelfAssessmentStructure where selfassessmentid = @competencyAssessmentId",
new { competencyAssessmentId }
);

);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,8 @@ public IActionResult CompetencyAssessmentSummary(int competencyAssessmentId, int
public IActionResult CompetencyAssessmentSummary(CompetencyAssessmentFeaturesViewModel competency)
{
var data = GetcompetencyAssessmentFeaturesData();
if (data.ID == 0) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
if (competencyAssessmentService.GetSelfAssessmentStructure(data.ID) != 0) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 410 });
if (data.ID == 0) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
var features = competencyAssessmentService.UpdateCompetencyAssessmentFeaturesTaskStatus(data.ID,
data.DescriptionStatus,
data.ProviderandCategoryStatus,
Expand All @@ -708,7 +708,32 @@ public IActionResult CompetencyAssessmentSummary(CompetencyAssessmentFeaturesVie
TempData.Clear();
return RedirectToAction("ManageCompetencyAssessment", new { competencyAssessmentId = competency.ID, competency.FrameworkId });
}

[Route("/CompetencyAssessments/{competencyAssessmentId}/Frameworks/{frameworkId}/Make")]
public IActionResult ConfirmMaKePrimaryFramework(int frameworkId, int competencyAssessmentId)
{
var adminId = GetAdminID();
var competencyAssessmentBase = competencyAssessmentService.GetCompetencyAssessmentBaseById(competencyAssessmentId, adminId);
var framework = frameworkService.GetFrameworkDetailByFrameworkId(frameworkId, adminId);
var model = new ConfirmMakePrimaryFrameworkViewModel(competencyAssessmentBase, framework);
return View("ConfirmMaKePrimaryFramework", model);
}
[HttpPost]
[Route("/CompetencyAssessments/{competencyAssessmentId}/Frameworks/{frameworkId}/Make")]
public IActionResult ConfirmMaKePrimaryFramework(ConfirmMakePrimaryFrameworkViewModel model)
{
if (!ModelState.IsValid)
{
return View("ConfirmMaKePrimaryFramework", model);
}
competencyAssessmentService.UpdatePrimaryFrameworkCompetencies(model.CompetencyAssessmentId, model.FrameworkId);
var features = competencyAssessmentService.UpdateCompetencyAssessmentFeaturesTaskStatus(model.CompetencyAssessmentId,
model.DescriptionStatus,
model.ProviderandCategoryStatus,
model.VocabularyStatus,
model.WorkingGroupStatus,
model.AllframeworkCompetenciesStatus);
return RedirectToAction("ManageCompetencyAssessment", new { model.CompetencyAssessmentId, model.FrameworkId });
}
private void SetcompetencyAssessmentFeaturesData(CompetencyAssessmentFeaturesViewModel data)
{
multiPageFormService.SetMultiPageFormData(
Expand All @@ -717,7 +742,6 @@ private void SetcompetencyAssessmentFeaturesData(CompetencyAssessmentFeaturesVie
TempData
);
}

private CompetencyAssessmentFeaturesViewModel GetcompetencyAssessmentFeaturesData()
{
var data = multiPageFormService.GetMultiPageFormData<CompetencyAssessmentFeaturesViewModel>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public interface ICompetencyAssessmentService
int[] GetLinkedFrameworkCompetencyIds(int competencyAssessmentId, int frameworkId);
CompetencyAssessmentFeatures? GetCompetencyAssessmentFeaturesTaskStatus(int competencyAssessmentId);
int? GetSelfAssessmentStructure(int competencyAssessmentId);

//UPDATE DATA
bool UpdateCompetencyAssessmentName(int competencyAssessmentId, int adminId, string competencyAssessmentName);
bool UpdateCompetencyRoleProfileLinks(int competencyAssessmentId, int adminId, int? professionalGroupId, int? subGroupId, int? roleId);
Expand All @@ -57,6 +58,7 @@ string direction
bool UpdateCompetencyAssessmentFeaturesTaskStatus(int id, bool descriptionStatus, bool providerandCategoryStatus, bool vocabularyStatus,
bool workingGroupStatus, bool AllframeworkCompetenciesStatus);
void UpdateSelfAssessmentFromFramework(int selfAssessmentId, int? frameworkId);
bool UpdatePrimaryFrameworkCompetencies(int assessmentId, int frameworkId);

//INSERT DATA
int InsertCompetencyAssessment(int adminId, int centreId, string competencyAssessmentName, int? frameworkId);
Expand Down Expand Up @@ -286,9 +288,13 @@ public void UpdateSelfAssessmentFromFramework(int selfAssessmentId, int? framewo
{
competencyAssessmentDataService.UpdateSelfAssessmentFromFramework(selfAssessmentId, frameworkId);
}
public int? GetSelfAssessmentStructure(int competencyAssessmentId)
public bool UpdatePrimaryFrameworkCompetencies(int assessmentId, int frameworkId)
{
return competencyAssessmentDataService.GetSelfAssessmentStructure(competencyAssessmentId);
return competencyAssessmentDataService.UpdatePrimaryFrameworkCompetencies(assessmentId, frameworkId);
}
public int? GetSelfAssessmentStructure(int competencyAssessmentId)
{
return competencyAssessmentDataService.GetSelfAssessmentStructure(competencyAssessmentId);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using DigitalLearningSolutions.Data.Models.CompetencyAssessments;
using DigitalLearningSolutions.Data.Models.Frameworks;
using DigitalLearningSolutions.Web.Attributes;

namespace DigitalLearningSolutions.Web.ViewModels.CompetencyAssessments
{
public class ConfirmChangePrimaryFrameworkViewModel
{
public ConfirmChangePrimaryFrameworkViewModel()
{}
public ConfirmChangePrimaryFrameworkViewModel(CompetencyAssessmentBase competencyAssessmentBase, DetailFramework framework)
{
CompetencyAssessmentId = competencyAssessmentBase.ID;
AssessmentName = competencyAssessmentBase.CompetencyAssessmentName;
FrameworkName = framework.FrameworkName;
FrameworkId = framework.ID;
Vocabulary = competencyAssessmentBase.Vocabulary;
}
public int CompetencyAssessmentId { get; set; }
public int UserRole { get; set; }
public string? AssessmentName { get; set; }
public string? FrameworkName { get; set; }
public int FrameworkId { get; set; }
public string? Vocabulary { get; set; }
[BooleanMustBeTrue(ErrorMessage = "You must confirm that you wish to change the primary framework")]
public bool Confirm { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using DigitalLearningSolutions.Data.Models.CompetencyAssessments;
using DigitalLearningSolutions.Data.Models.Frameworks;
using DigitalLearningSolutions.Web.Attributes;

namespace DigitalLearningSolutions.Web.ViewModels.CompetencyAssessments
{
public class ConfirmMakePrimaryFrameworkViewModel
{
public ConfirmMakePrimaryFrameworkViewModel()
{}
public ConfirmMakePrimaryFrameworkViewModel(CompetencyAssessmentBase competencyAssessmentBase, DetailFramework framework)
{
CompetencyAssessmentId = competencyAssessmentBase.ID;
AssessmentName = competencyAssessmentBase.CompetencyAssessmentName;
FrameworkName = framework.FrameworkName;
FrameworkId = framework.ID;
Vocabulary = competencyAssessmentBase.Vocabulary;
}
public int CompetencyAssessmentId { get; set; }
public int UserRole { get; set; }
public string? AssessmentName { get; set; }
public string? FrameworkName { get; set; }
public int FrameworkId { get; set; }
public string? Vocabulary { get; set; }
[BooleanMustBeTrue(ErrorMessage = "You need to confirm that you want to make this the primary framework")]
public bool Confirm { get; set; }
public bool DescriptionStatus { get; set; }
public bool ProviderandCategoryStatus { get; set; }
public bool VocabularyStatus { get; set; }
public bool WorkingGroupStatus { get; set; }
public bool AllframeworkCompetenciesStatus { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@using DigitalLearningSolutions.Web.Helpers
@using DigitalLearningSolutions.Web.ViewModels.CompetencyAssessments
@model ConfirmChangePrimaryFrameworkViewModel;
@{
var errorHasOccurred = !ViewData.ModelState.IsValid;
ViewData["Title"] = "Competency Assessments - Change primary framework";
}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
@if (errorHasOccurred)
{
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.Confirm) })" />
}

<h1 class="nhsuk-heading-xl">Change primary framework to @Model.FrameworkName</h1>
</div>
</div>
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
<form class="nhsuk-u-margin-bottom-3" method="post" asp-action="ConfirmChangePrimaryFramework">
<input type="hidden" asp-for="CompetencyAssessmentId" />
<input type="hidden" asp-for="FrameworkId" />
<input type="hidden" asp-for="FrameworkName" />
<input type="hidden" asp-for="AssessmentName" />
<input type="hidden" asp-for="UserRole" />
<input type="hidden" asp-for="Vocabulary" />

<vc:single-checkbox asp-for="@nameof(Model.Confirm)"
label="I am sure that I wish to change the primary framework to @Model.FrameworkName "
hint-text="" />

<button class="nhsuk-button" type="submit">Change primary framework</button>
</form>
<div class="nhsuk-back-link">
<a class="nhsuk-back-link__link" asp-action="SelectFrameworkSources" asp-route-actionName="Summary" asp-route-competencyAssessmentId="@ViewContext.RouteData.Values["competencyAssessmentId"]">
<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">
<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>
</svg>
Cancel
</a>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@using DigitalLearningSolutions.Web.Helpers
@using DigitalLearningSolutions.Web.ViewModels.CompetencyAssessments
@model ConfirmMakePrimaryFrameworkViewModel;
@{
var errorHasOccurred = !ViewData.ModelState.IsValid;
ViewData["Title"] = "Competency Assessments - Change primary framework";
}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
@if (errorHasOccurred)
{
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.Confirm) })" />
}

<h1 class="nhsuk-heading-xl">Make @Model.FrameworkName primary framework</h1>
<h2>Which features of the framework do you want to copy into this @Model.FrameworkName framework?</h2>
</div>
</div>
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
<form class="nhsuk-u-margin-bottom-3" method="post" asp-action="ConfirmMakePrimaryFramework">
<nhs-form-group>
<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>
</nhs-form-group>
<nhs-form-group>
<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>
</nhs-form-group>
<nhs-form-group>
<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>
</nhs-form-group>
<nhs-form-group>
<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>
</nhs-form-group>
<nhs-form-group>
<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>
</nhs-form-group>
<input type="hidden" asp-for="CompetencyAssessmentId" />
<input type="hidden" asp-for="FrameworkId" />
<input type="hidden" asp-for="FrameworkName" />
<input type="hidden" asp-for="AssessmentName" />
<input type="hidden" asp-for="UserRole" />
<input type="hidden" asp-for="Vocabulary" />

<vc:single-checkbox asp-for="@nameof(Model.Confirm)"
label="I am sure that I wish to make @Model.FrameworkName the primary framework"
hint-text="" />

<button class="nhsuk-button" type="submit">Make primary framework</button>
</form>
<div class="nhsuk-back-link">
<a class="nhsuk-back-link__link" asp-action="SelectFrameworkSources" asp-route-actionName="Summary" asp-route-competencyAssessmentId="@ViewContext.RouteData.Values["competencyAssessmentId"]">
<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">
<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>
</svg>
Cancel
</a>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
</div>
</nav>
}
<style>
.left-align-actions {
white-space: nowrap;
display: inline-flex;
gap: 1rem;
}
</style>

<h1>Select framework sources for @Model.CompetencyAssessmentName</h1>
<dl class="nhsuk-summary-list">
Expand All @@ -34,9 +41,13 @@
@Model.PrimaryFramework.FrameworkName
</dd>
<dd class="nhsuk-summary-list__actions">
<a asp-action="RemoveFramework" asp-route-frameworkId="@Model.PrimaryFramework.ID" asp-route-competencyAssessmentId="@ViewContext.RouteData.Values["competencyAssessmentId"]">
Remove<span class="nhsuk-u-visually-hidden"> @Model.PrimaryFramework.FrameworkName</span>
</a>
<ul class="nhsuk-summary-list__actions-list left-align-actions">
<li class="nhsuk-summary-list__actions-list-item">
<a asp-action="RemoveFramework" asp-route-frameworkId="@Model.PrimaryFramework.ID" asp-route-competencyAssessmentId="@ViewContext.RouteData.Values["competencyAssessmentId"]">
Remove<span class="nhsuk-u-visually-hidden"> @Model.PrimaryFramework.FrameworkName</span>
</a>
</li>
</ul>
</dd>
</div>
}
Expand All @@ -52,9 +63,23 @@
@Model.AdditionalFrameworks.ElementAt(i).FrameworkName
</dd>
<dd class="nhsuk-summary-list__actions">
<a asp-action="RemoveFramework" asp-route-frameworkId="@Model.AdditionalFrameworks.ElementAt(i).ID" asp-route-competencyAssessmentId="@ViewContext.RouteData.Values["competencyAssessmentId"]">
Remove<span class="nhsuk-u-visually-hidden"> @Model.AdditionalFrameworks.ElementAt(i).FrameworkName</span>
</a>
<ul class="nhsuk-summary-list__actions-list nhsuk-summary-list__actions-list--inline left-align-actions">
<li class="nhsuk-summary-list__actions-list-item">
<a asp-action="RemoveFramework"
asp-route-frameworkId="@Model.AdditionalFrameworks.ElementAt(i).ID"
asp-route-competencyAssessmentId="@ViewContext.RouteData.Values["competencyAssessmentId"]">
Remove <span class="nhsuk-u-visually-hidden">@Model.AdditionalFrameworks.ElementAt(i).FrameworkName</span>
</a>
</li>
<li class="nhsuk-summary-list__actions-list-item">
<a asp-action="ConfirmMaKePrimaryFramework"
asp-route-frameworkId="@Model.AdditionalFrameworks.ElementAt(i).ID"
asp-route-competencyAssessmentId="@ViewContext.RouteData.Values["competencyAssessmentId"]">
Make primary <span class="nhsuk-u-visually-hidden">@Model.AdditionalFrameworks.ElementAt(i).FrameworkName</span>
</a>
</li>

</ul>
</dd>
</div>
}
Expand Down
Loading