Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -34,7 +34,6 @@ public interface ICompetencyAssessmentDataService
IEnumerable<LinkedFramework> GetLinkedFrameworksForCompetencyAssessment(int competencyAssessmentId);
int[] GetLinkedFrameworkCompetencyIds(int competencyAssessmentId, int frameworkId);
CompetencyAssessmentFeatures? GetCompetencyAssessmentFeaturesTaskStatus(int competencyAssessmentId);
int? GetSelfAssessmentStructure(int competencyAssessmentId);

//UPDATE DATA
bool UpdateCompetencyAssessmentName(int competencyAssessmentId, int adminId, string competencyAssessmentName);
Expand Down Expand Up @@ -68,6 +67,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 +857,25 @@ FROM FrameworkCompetencies AS FC

return true;
}
public int? GetSelfAssessmentStructure(int competencyAssessmentId)
public bool UpdatePrimaryFrameworkCompetencies(int assessmentId, int frameworkId)
{
return connection.QueryFirstOrDefault<int>(
@"SELECT 1 from dbo.SelfAssessmentStructure where selfassessmentid = @competencyAssessmentId",
new { competencyAssessmentId }
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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ public IActionResult CompetencyAssessmentFeatures(CompetencyAssessmentFeaturesVi
[Route("/CompetencyAssessments/Framework/{frameworkId}/{competencyAssessmentId}/Summary")]
public IActionResult CompetencyAssessmentSummary(int competencyAssessmentId, int? frameworkId = null)
{
if (competencyAssessmentService.GetSelfAssessmentStructure(competencyAssessmentId) != 0) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 410 });

if (competencyAssessmentId == 0) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
var data = GetcompetencyAssessmentFeaturesData();
if (data == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 500 });
Expand All @@ -693,7 +693,6 @@ public IActionResult CompetencyAssessmentSummary(CompetencyAssessmentFeaturesVie
{
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 });
var features = competencyAssessmentService.UpdateCompetencyAssessmentFeaturesTaskStatus(data.ID,
data.DescriptionStatus,
data.ProviderandCategoryStatus,
Expand All @@ -708,7 +707,31 @@ public IActionResult CompetencyAssessmentSummary(CompetencyAssessmentFeaturesVie
TempData.Clear();
return RedirectToAction("ManageCompetencyAssessment", new { competencyAssessmentId = competency.ID, competency.FrameworkId });
}

[Route("/CompetencyAssessments/{competencyAssessmentId}/Frameworks/{frameworkId}/Change")]
public IActionResult ConfirmChangePrimaryFramework(int frameworkId, int competencyAssessmentId)
{
var adminId = GetAdminID();
var competencyAssessmentBase = competencyAssessmentService.GetCompetencyAssessmentBaseById(competencyAssessmentId, adminId);
var framework = frameworkService.GetFrameworkDetailByFrameworkId(frameworkId, adminId);
var model = new ConfirmChangePrimaryFrameworkViewModel(competencyAssessmentBase, framework);
return View("ConfirmChangePrimaryFramework", model);
}
[HttpPost]
[Route("/CompetencyAssessments/{competencyAssessmentId}/Frameworks/{frameworkId}/Change")]
public IActionResult ConfirmChangePrimaryFramework(ConfirmChangePrimaryFrameworkViewModel model)
{
if (!ModelState.IsValid)
{
return View("ConfirmChangePrimaryFramework", model);
}
competencyAssessmentService.UpdatePrimaryFrameworkCompetencies(model.CompetencyAssessmentId, model.FrameworkId);
var baseModel = new CompetencyAssessmentFeaturesViewModel(model.CompetencyAssessmentId,
model.FrameworkName,
model.UserRole,
model.FrameworkId);
SetcompetencyAssessmentFeaturesData(baseModel);
return RedirectToAction("CompetencyAssessmentFeatures", new { model.CompetencyAssessmentId, model.FrameworkId });
}
private void SetcompetencyAssessmentFeaturesData(CompetencyAssessmentFeaturesViewModel data)
{
multiPageFormService.SetMultiPageFormData(
Expand All @@ -717,7 +740,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 @@ -31,7 +31,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 +57,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 +287,9 @@ 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);
}
}
}
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,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
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="ConfirmChangePrimaryFramework"
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