diff --git a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/SelfAssessment.cs b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/SelfAssessment.cs index 52de613185..6b959dfc50 100644 --- a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/SelfAssessment.cs +++ b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/SelfAssessment.cs @@ -1538,6 +1538,23 @@ ManageOptionalCompetenciesViewModel model ); } } + if (model.GroupOptionalCompetenciesChecked != null) + { + var optionalCompetencies = + selfAssessmentService.GetCandidateAssessmentOptionalCompetencies(selfAssessmentId, delegateUserId); + foreach (var competencyGroup in model.GroupOptionalCompetenciesChecked) + { + var IncludedSelfAssessmentStructureIds = optionalCompetencies.Where(x => x.CompetencyGroup == competencyGroup).Select(x => x.SelfAssessmentStructureId).ToList(); + foreach (var selfAssessmentStructureId in IncludedSelfAssessmentStructureIds) + { + selfAssessmentService.UpdateCandidateAssessmentOptionalCompetencies( + selfAssessmentStructureId.Value, + delegateUserId + ); + } + } + + } return RedirectToAction("SelfAssessmentOverview", new { selfAssessmentId, vocabulary }); } diff --git a/DigitalLearningSolutions.Web/ViewModels/LearningPortal/SelfAssessments/ManageOptionalCompetenciesViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/LearningPortal/SelfAssessments/ManageOptionalCompetenciesViewModel.cs index 94f52b17f4..0fc3adb9b7 100644 --- a/DigitalLearningSolutions.Web/ViewModels/LearningPortal/SelfAssessments/ManageOptionalCompetenciesViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/LearningPortal/SelfAssessments/ManageOptionalCompetenciesViewModel.cs @@ -10,6 +10,7 @@ public class ManageOptionalCompetenciesViewModel public CurrentSelfAssessment? SelfAssessment { get; set; } public IEnumerable>? CompetencyGroups { get; set; } public List? IncludedSelfAssessmentStructureIds { get; set; } + public List? GroupOptionalCompetenciesChecked { get; set; } public string VocabPlural() { return FrameworkVocabularyHelper.VocabularyPlural(SelfAssessment.Vocabulary); diff --git a/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageOptionalCompetencies.cshtml b/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageOptionalCompetencies.cshtml index 3594ed3838..6ce45cf1f3 100644 --- a/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageOptionalCompetencies.cshtml +++ b/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageOptionalCompetencies.cshtml @@ -8,6 +8,11 @@ ViewData["SelfAssessmentTitle"] = @Model.SelfAssessment.Name; var backLinkData = Html.GetRouteValues(); } + @if (ViewBag.FromAddOptionalPage != null) { @section breadcrumbs { @@ -82,67 +87,97 @@ else @foreach (var competencyGroup in Model.CompetencyGroups) {
- - - @competencyGroup.Key - - + @if (competencyGroup.Count() > 1) { - - } - -
- @foreach (var competency in competencyGroup) + @if (competencyGroup.Any(x => x.GroupOptionalCompetencies)) { - @if (competency.GroupOptionalCompetencies) - { -
- - - -
-
- +
+ + +
+
+ +

-    What’s included in the @competency.CompetencyGroup + + What’s included in the @competencyGroup.Key + -

-
- @(Html.Raw(@competency.Name)) -
-
-
- } - else - { -
- -
+ +
+
+ + @foreach (var competency in competencyGroup) { - - - @flag.FlagName - - +
+ @foreach (var flag in competency.CompetencyFlags) + { + + + @flag.FlagName + + + } +
+ @competency.Name +
+
} +
- @competency.Name - + +
+ + +
+ } + else + { + + + @competencyGroup.Key + + + +
+ @foreach (var competency in competencyGroup) + { +
+ + +
+ + } +
} -
+ }
}