-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/hook-up-advice-page
- Loading branch information
Showing
15 changed files
with
892 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Dfe.EarlyYearsQualification.Content/Entities/ConfirmQualificationPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Dfe.EarlyYearsQualification.Content.Entities; | ||
|
||
public class ConfirmQualificationPage | ||
{ | ||
public string Heading { get; init; } = string.Empty; | ||
public string QualificationLabel { get; init; } = string.Empty; | ||
public string LevelLabel { get; init; } = string.Empty; | ||
public string AwardingOrganisationLabel { get; init; } = string.Empty; | ||
public string DateAddedLabel { get; init; } = string.Empty; | ||
public string RadioHeading { get; init; } = string.Empty; | ||
public List<Option> Options { get; init; } = []; | ||
public string ErrorBannerHeading { get; init; } = string.Empty; | ||
public string ErrorBannerLink { get; init; } = string.Empty; | ||
public string ErrorText { get; init; } = string.Empty; | ||
public string ButtonText { get; init; } = string.Empty; | ||
public NavigationLink? BackButton { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
src/Dfe.EarlyYearsQualification.Web/Controllers/ConfirmQualificationController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
using Dfe.EarlyYearsQualification.Content.Entities; | ||
using Dfe.EarlyYearsQualification.Content.Services; | ||
using Dfe.EarlyYearsQualification.Web.Controllers.Base; | ||
using Dfe.EarlyYearsQualification.Web.Models.Content; | ||
using Dfe.EarlyYearsQualification.Web.Models.Content.QuestionModels; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Dfe.EarlyYearsQualification.Web.Controllers; | ||
|
||
[Route("confirm-qualification")] | ||
public class ConfirmQualificationController( | ||
ILogger<ConfirmQualificationController> logger, | ||
IContentService contentService) | ||
: ServiceController | ||
{ | ||
[HttpGet] | ||
[Route("{qualificationId}")] | ||
public async Task<IActionResult> Index(string qualificationId) | ||
{ | ||
if (string.IsNullOrEmpty(qualificationId)) | ||
{ | ||
return BadRequest(); | ||
} | ||
|
||
var content = await contentService.GetConfirmQualificationPage(); | ||
|
||
if (content is null) | ||
{ | ||
logger.LogError("No content for the cookies page"); | ||
return RedirectToAction("Index", "Error"); | ||
} | ||
|
||
var qualification = await contentService.GetQualificationById(qualificationId); | ||
if (qualification is null) | ||
{ | ||
var loggedQualificationId = qualificationId.Replace(Environment.NewLine, ""); | ||
logger.LogError("Could not find details for qualification with ID: {QualificationId}", | ||
loggedQualificationId); | ||
|
||
return RedirectToAction("Index", "Error"); | ||
} | ||
|
||
var model = Map(content, qualification); | ||
|
||
return View(model); | ||
} | ||
|
||
[HttpPost] | ||
public async Task<IActionResult> Confirm(ConfirmQualificationPageModel model) | ||
{ | ||
if (!ModelState.IsValid) | ||
{ | ||
var content = await contentService.GetConfirmQualificationPage(); | ||
|
||
if (content is null) | ||
{ | ||
logger.LogError("No content for the cookies page"); | ||
return RedirectToAction("Index", "Error"); | ||
} | ||
|
||
if (string.IsNullOrEmpty(model.QualificationId)) | ||
{ | ||
logger.LogError("No qualification id provided"); | ||
return RedirectToAction("Index", "Error"); | ||
} | ||
|
||
var qualification = await contentService.GetQualificationById(model.QualificationId); | ||
if (qualification is null) | ||
{ | ||
var loggedQualificationId = model.QualificationId.Replace(Environment.NewLine, ""); | ||
logger.LogError("Could not find details for qualification with ID: {QualificationId}", | ||
loggedQualificationId); | ||
|
||
return RedirectToAction("Index", "Error"); | ||
} | ||
|
||
model = Map(content, qualification); | ||
model.HasErrors = true; | ||
|
||
return View("Index", model); | ||
} | ||
|
||
return model.ConfirmQualificationAnswer == "yes" ? RedirectToAction("Index", "QualificationDetails", new { qualificationId = model.QualificationId }) : RedirectToAction("Get", "QualificationDetails"); | ||
} | ||
|
||
private static ConfirmQualificationPageModel Map(ConfirmQualificationPage content, Qualification qualification) | ||
{ | ||
return new ConfirmQualificationPageModel | ||
{ | ||
Heading = content.Heading, | ||
Options = content.Options.Select(x => new OptionModel { Label = x.Label, Value = x.Value }).ToList(), | ||
ErrorText = content.ErrorText, | ||
LevelLabel = content.LevelLabel, | ||
QualificationLabel = content.QualificationLabel, | ||
RadioHeading = content.RadioHeading, | ||
DateAddedLabel = content.DateAddedLabel, | ||
AwardingOrganisationLabel = content.AwardingOrganisationLabel, | ||
ErrorBannerHeading = content.ErrorBannerHeading, | ||
ErrorBannerLink = content.ErrorBannerLink, | ||
ButtonText = content.ButtonText, | ||
HasErrors = false, | ||
QualificationName = qualification.QualificationName, | ||
QualificationLevel = qualification.QualificationLevel.ToString(), | ||
QualificationId = qualification.QualificationId, | ||
QualificationAwardingOrganisation = qualification.AwardingOrganisationTitle, | ||
QualificationDateAdded = qualification.FromWhichYear!, | ||
BackButton = content.BackButton, | ||
}; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Dfe.EarlyYearsQualification.Web/Models/Content/ConfirmQualificationPageModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Dfe.EarlyYearsQualification.Content.Entities; | ||
using Dfe.EarlyYearsQualification.Web.Models.Content.QuestionModels; | ||
|
||
namespace Dfe.EarlyYearsQualification.Web.Models.Content; | ||
|
||
public class ConfirmQualificationPageModel | ||
{ | ||
public string Heading { get; init; } = string.Empty; | ||
public string QualificationLabel { get; init; } = string.Empty; | ||
public string LevelLabel { get; init; } = string.Empty; | ||
public string AwardingOrganisationLabel { get; init; } = string.Empty; | ||
public string DateAddedLabel { get; init; } = string.Empty; | ||
public string RadioHeading { get; init; } = string.Empty; | ||
public List<OptionModel> Options { get; init; } = []; | ||
public bool HasErrors { get; set; } = false; | ||
public string ErrorBannerHeading { get; init; } = string.Empty; | ||
public string ErrorBannerLink { get; init; } = string.Empty; | ||
public string ErrorText { get; init; } = string.Empty; | ||
[Required] public string? ConfirmQualificationAnswer { get; init; } = string.Empty; | ||
public string ButtonText { get; init; } = string.Empty; | ||
[Required] public string QualificationId { get; init; } = string.Empty; | ||
public string QualificationName { get; init; } = string.Empty; | ||
public string QualificationLevel { get; init; } = string.Empty; | ||
public string QualificationAwardingOrganisation { get; init; } = string.Empty; | ||
public string QualificationDateAdded { get; init; } = string.Empty; | ||
public NavigationLink? BackButton { get; init; } | ||
} |
94 changes: 94 additions & 0 deletions
94
src/Dfe.EarlyYearsQualification.Web/Views/ConfirmQualification/index.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
@model Dfe.EarlyYearsQualification.Web.Models.Content.ConfirmQualificationPageModel | ||
|
||
@{ | ||
ViewData["Title"] = "Confirm Qualification"; | ||
} | ||
|
||
@{ | ||
await Html.RenderPartialAsync("Partials/BackButton", @Model.BackButton); | ||
} | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds-from-desktop"> | ||
@if (Model.HasErrors) | ||
{ | ||
<div id="error-banner" class="govuk-error-summary" data-module="govuk-error-summary"> | ||
<div role="alert"> | ||
<h2 class="govuk-error-summary__title"> | ||
@Model.ErrorBannerHeading | ||
</h2> | ||
<div class="govuk-error-summary__body"> | ||
<ul class="govuk-list govuk-error-summary__list"> | ||
<li> | ||
<a id="error-banner-link" href="#confirm-qualification-choice-error">@Model.ErrorBannerLink</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
<h1 id="heading" class="govuk-heading-xl">@Model.Heading</h1> | ||
<dl class="govuk-summary-list"> | ||
<div id="qualification-name-row" class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"> | ||
@Model.QualificationLabel | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
@Model.QualificationName | ||
</dd> | ||
</div> | ||
<div id="qualification-level-row" class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"> | ||
@Model.LevelLabel | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
@Model.QualificationLevel | ||
</dd> | ||
</div> | ||
<div id="qualification-org-row" class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"> | ||
@Model.AwardingOrganisationLabel | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
@Model.QualificationAwardingOrganisation | ||
</dd> | ||
</div> | ||
<div id="qualification-date-added-row" class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"> | ||
@Model.DateAddedLabel | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
@Model.QualificationDateAdded | ||
</dd> | ||
</div> | ||
</dl> | ||
<form id="confirm-qualification" asp-controller="ConfirmQualification" asp-action="Confirm" method="post"> | ||
<input type="hidden" name="qualificationId" value="@Model.QualificationId"> | ||
<div id="confirm-qualification-form-group" class="govuk-form-group @(Model.HasErrors ? "govuk-form-group--error" : "")"> | ||
<h4 id="radio-heading" class="govuk-heading-m">@Model.RadioHeading</h4> | ||
<fieldset class="govuk-fieldset" role="group" aria-describedby="confirm-qualification-choice-error"> | ||
@if (Model.HasErrors) | ||
{ | ||
<p id="confirm-qualification-choice-error" class="govuk-error-message"> | ||
<span class="govuk-visually-hidden">Error:</span> @Model.ErrorText | ||
</p> | ||
} | ||
@foreach (var option in Model.Options) | ||
{ | ||
<div class="govuk-radios__item"> | ||
@Html.RadioButtonFor(x => x.ConfirmQualificationAnswer, option.Value, new { @class = "govuk-radios__input", id = option.Value }) | ||
<label class="govuk-label govuk-radios__label" for="@option.Value"> | ||
@option.Label | ||
</label> | ||
</div> | ||
} | ||
</fieldset> | ||
</div> | ||
<div class="govuk-form-group"> | ||
<button id="confirm-qualification-button" class="govuk-button" data-module="govuk-button"> | ||
@Model.ButtonText | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.