Skip to content

Commit

Permalink
New static page: advice for qualification at level 7.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertGHippo committed Aug 6, 2024
1 parent 7ac31a9 commit fd6c80c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ public static class AdvicePages
/// Entry ID for the "Qualifications achieved in Scotland" advice page.
/// </summary>
public const string QualificationsAchievedInScotland = "3deQYTynsM9iLnJ5fgFqk";

/// <summary>
/// Entry ID for the "Qualifications achieved in Northern Ireland" advice page.
/// </summary>
public const string QualificationsAchievedInWales = "1Xu4FPcZDxFb5yDCI6lLCj";

/// <summary>
/// Entry ID for the "Qualification not on the list" advice page.
/// </summary>
public const string QualificationNotOnTheList = "XU6vhxIHdeasGLwueCGel";

/// <summary>
/// Entry ID for the "Qualification Level 7" advice page
/// </summary>
public const string QualificationLevel7 = "1bGiyvwsJZPd14dwrVtWCM";
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Dfe.EarlyYearsQualification.Mock.Content;
public class MockContentfulService : IContentService
{
private const string WhereWasTheQualificationAwardedPath = "/questions/where-was-the-qualification-awarded";
private const string WhatLevelIsTheQualificationPath = "/questions/what-level-is-the-qualification";

public async Task<AccessibilityStatementPage?> GetAccessibilityStatementPage()
{
Expand Down Expand Up @@ -39,7 +40,7 @@ await Task.FromResult(CreateAdvicePage("Qualifications achieved outside the Unit
AdvicePages.QualificationsStartedBetweenSept2014AndAug2019 =>
await
Task.FromResult(CreateAdvicePage("Level 2 qualifications started between 1 September 2014 and 31 August 2019",
body, "/questions/what-level-is-the-qualification")),
body, WhatLevelIsTheQualificationPath)),

AdvicePages.QualificationsAchievedInScotland =>
await Task.FromResult(CreateAdvicePage("Qualifications achieved in Scotland",
Expand All @@ -56,6 +57,12 @@ await Task.FromResult(CreateAdvicePage("Qualifications achieved in Northern Irel
AdvicePages.QualificationNotOnTheList =>
await Task.FromResult(CreateAdvicePage("Qualification not on the list",
body, "/qualifications")),

AdvicePages.QualificationLevel7 =>
await Task.FromResult(CreateAdvicePage("Qualification at Level 7",
body,
WhatLevelIsTheQualificationPath)),

_ => null
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,43 @@ public async Task<IActionResult> QualificationOutsideTheUnitedKingdom()
{
return await GetView(AdvicePages.QualificationsAchievedOutsideTheUk);
}

[HttpGet("level-2-qualifications-started-between-1-sept-2014-and-31-aug-2019")]
public async Task<IActionResult> QualificationsStartedBetweenSept2014AndAug2019()
{
return await GetView(AdvicePages.QualificationsStartedBetweenSept2014AndAug2019);
}

[HttpGet("qualifications-achieved-in-northern-ireland")]
public async Task<IActionResult> QualificationsAchievedInNorthernIreland()
{
return await GetView(AdvicePages.QualificationsAchievedInNorthernIreland);
}

[HttpGet("qualifications-achieved-in-scotland")]
public async Task<IActionResult> QualificationsAchievedInScotland()
{
return await GetView(AdvicePages.QualificationsAchievedInScotland);
}

[HttpGet("qualifications-achieved-in-wales")]
public async Task<IActionResult> QualificationsAchievedInWales()
{
return await GetView(AdvicePages.QualificationsAchievedInWales);
}

[HttpGet("qualification-not-on-the-list")]
public async Task<IActionResult> QualificationNotOnTheList()
{
return await GetView(AdvicePages.QualificationNotOnTheList);
}

[HttpGet("qualification-level-7")]
public async Task<IActionResult> QualificationLevel7()
{
return await GetView(AdvicePages.QualificationLevel7);
}

private async Task<IActionResult> GetView(string advicePageId)
{
var advicePage = await contentService.GetAdvicePage(advicePageId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ public async Task<IActionResult> WhenWasTheQualificationStarted()
return RedirectToAction("Index", "Error");
}

var model = await MapDateModel(new DateQuestionModel(), questionPage, nameof(this.WhenWasTheQualificationStarted),
Questions);
var model = await MapDateModel(new DateQuestionModel(), questionPage,
nameof(this.WhenWasTheQualificationStarted),
Questions);
return View("Date", model);
}

Expand All @@ -90,7 +91,7 @@ public async Task<IActionResult> WhenWasTheQualificationStarted(DateQuestionMode
if (!ModelState.IsValid || !questionModelValidator.IsValid(model))
{
var questionPage = await contentService.GetDateQuestionPage(QuestionPages.WhenWasTheQualificationStarted);

// ReSharper disable once InvertIf
if (questionPage is not null)
{
Expand Down Expand Up @@ -120,7 +121,7 @@ public async Task<IActionResult> WhatLevelIsTheQualification(RadioQuestionModel
if (!ModelState.IsValid)
{
var questionPage = await contentService.GetRadioQuestionPage(QuestionPages.WhatLevelIsTheQualification);

// ReSharper disable once InvertIf
if (questionPage is not null)
{
Expand All @@ -133,12 +134,13 @@ public async Task<IActionResult> WhatLevelIsTheQualification(RadioQuestionModel

userJourneyCookieService.SetLevelOfQualification(model.Option!);

if (model.Option == "2" && WasAwardedBetweenSeptember2014AndAugust2019())
{
return RedirectToAction("QualificationsStartedBetweenSept2014AndAug2019", "Advice");
}

return RedirectToAction(nameof(this.WhatIsTheAwardingOrganisation));
return model.Option switch
{
"2" when WasAwardedBetweenSeptember2014AndAugust2019() =>
RedirectToAction("QualificationsStartedBetweenSept2014AndAug2019", "Advice"),
"7" => RedirectToAction(nameof(AdviceController.QualificationLevel7), "Advice"),
_ => RedirectToAction(nameof(this.WhatIsTheAwardingOrganisation))
};
}

[HttpGet("what-is-the-awarding-organisation")]
Expand All @@ -154,8 +156,8 @@ public async Task<IActionResult> WhatIsTheAwardingOrganisation()
var qualifications = await GetFilteredQualifications();

var model = await MapDropdownModel(new DropdownQuestionModel(), questionPage, qualifications,
nameof(this.WhatIsTheAwardingOrganisation),
Questions);
nameof(this.WhatIsTheAwardingOrganisation),
Questions);

return View("Dropdown", model);
}
Expand All @@ -167,15 +169,15 @@ public async Task<IActionResult> WhatIsTheAwardingOrganisation(DropdownQuestionM
{
var questionPage =
await contentService.GetDropdownQuestionPage(QuestionPages.WhatIsTheAwardingOrganisation);

// ReSharper disable once InvertIf
if (questionPage is not null)
{
var qualifications = await GetFilteredQualifications();

model = await MapDropdownModel(model, questionPage, qualifications,
nameof(this.WhatIsTheAwardingOrganisation),
Questions);
nameof(this.WhatIsTheAwardingOrganisation),
Questions);
model.HasErrors = true;
}

Expand Down Expand Up @@ -239,8 +241,9 @@ private async Task<RadioQuestionModel> MapRadioModel(RadioQuestionModel model, R
return model;
}

private async Task<DateQuestionModel> MapDateModel(DateQuestionModel model, DateQuestionPage question, string actionName,
string controllerName)
private async Task<DateQuestionModel> MapDateModel(DateQuestionModel model, DateQuestionPage question,
string actionName,
string controllerName)
{
model.Question = question.Question;
model.CtaButtonText = question.CtaButtonText;
Expand All @@ -258,9 +261,10 @@ private async Task<DateQuestionModel> MapDateModel(DateQuestionModel model, Date
return model;
}

private async Task<DropdownQuestionModel> MapDropdownModel(DropdownQuestionModel model, DropdownQuestionPage question,
List<Qualification> qualifications, string actionName,
string controllerName)
private async Task<DropdownQuestionModel> MapDropdownModel(DropdownQuestionModel model,
DropdownQuestionPage question,
List<Qualification> qualifications, string actionName,
string controllerName)
{
var awardingOrganisationExclusions =
new[] { AwardingOrganisations.AllHigherEducation, AwardingOrganisations.Various };
Expand Down Expand Up @@ -294,7 +298,7 @@ var uniqueAwardingOrganisations
Text = awardingOrg
});
}

model.ErrorBannerHeading = question.ErrorBannerHeading;
model.ErrorBannerLinkText = question.ErrorBannerLinkText;
model.AdditionalInformationHeader = question.AdditionalInformationHeader;
Expand Down

0 comments on commit fd6c80c

Please sign in to comment.