diff --git a/DigitalLearningSolutions.Data/Models/Frameworks/FrameworkCompetency.cs b/DigitalLearningSolutions.Data/Models/Frameworks/FrameworkCompetency.cs index cbcf5b8a5d..310751de5c 100644 --- a/DigitalLearningSolutions.Data/Models/Frameworks/FrameworkCompetency.cs +++ b/DigitalLearningSolutions.Data/Models/Frameworks/FrameworkCompetency.cs @@ -13,6 +13,7 @@ public class FrameworkCompetency : BaseSearchableItem public int Ordering { get; set; } public int AssessmentQuestions { get; set; } public int CompetencyLearningResourcesCount { get; set; } + public string? FrameworkName { get; set; } public override string SearchableName { diff --git a/DigitalLearningSolutions.Data/Services/FrameworkService.cs b/DigitalLearningSolutions.Data/Services/FrameworkService.cs index c9796ed09f..35477663a0 100644 --- a/DigitalLearningSolutions.Data/Services/FrameworkService.cs +++ b/DigitalLearningSolutions.Data/Services/FrameworkService.cs @@ -446,10 +446,14 @@ public IEnumerable GetAllFrameworks(int adminId) public IEnumerable GetAllCompetenciesForAdminId(string name, int adminId) { - return connection.Query( - $@"SELECT * FROM Competencies WHERE [Name] = @name AND [UpdatedByAdminID] = @adminId", - new { name, adminId } - ); + return connection.Query( + $@"SELECT f.FrameworkName,c.Description,c.UpdatedByAdminID,c.Name from Competencies as c + INNER JOIN FrameworkCompetencies AS fc ON c.ID = fc.CompetencyID + INNER JOIN Frameworks AS f ON fc.FrameworkID = f.ID + WHERE fc.FrameworkID = f.ID AND c.Name = @name AND c.UpdatedByAdminID = @adminId", + new { name, adminId } + ); + } public BrandedFramework CreateFramework(DetailFramework detailFramework, int adminId) diff --git a/DigitalLearningSolutions.Web/Controllers/FrameworksController/Competencies.cs b/DigitalLearningSolutions.Web/Controllers/FrameworksController/Competencies.cs index 1ba469a360..eeb0b4e36b 100644 --- a/DigitalLearningSolutions.Web/Controllers/FrameworksController/Competencies.cs +++ b/DigitalLearningSolutions.Web/Controllers/FrameworksController/Competencies.cs @@ -139,12 +139,12 @@ public IActionResult AddEditFrameworkCompetency(int frameworkId, FrameworkCompet frameworkCompetency.Description = SanitizerHelper.SanitizeHtmlData(frameworkCompetency.Description); frameworkCompetency.Description?.Trim(); var description = HttpUtility.HtmlDecode(HttpUtility.HtmlDecode(frameworkCompetency.Description)); + var detailFramework = frameworkService.GetDetailFrameworkByFrameworkId(frameworkId, GetAdminId()); if (string.IsNullOrWhiteSpace(description)) { frameworkCompetency.Description = null; } if (!ModelState.IsValid) { ModelState.Remove(nameof(FrameworkCompetency.Name)); ModelState.AddModelError(nameof(FrameworkCompetency.Name), "Please enter a valid competency statement (between 3 and 500 characters)"); - var detailFramework = frameworkService.GetDetailFrameworkByFrameworkId(frameworkId, GetAdminId()); var competencyFlags = frameworkService.GetCompetencyFlagsByFrameworkId(frameworkId, frameworkCompetency?.CompetencyID).ToList(); if (competencyFlags != null) competencyFlags.ForEach(f => f.Selected = selectedFlagIds.Contains(f.FlagId)); @@ -187,6 +187,7 @@ public IActionResult AddEditFrameworkCompetency(int frameworkId, FrameworkCompet FrameworkId = frameworkId, FrameworkGroupId = frameworkCompetencyGroupId, FrameworkCompetencyId = frameworkCompetencyId, + FrameworkConfig = detailFramework?.FrameworkConfig, Competency = new FrameworkCompetency() { Name = frameworkCompetency.Name, diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/SimilarCompetencyViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/SimilarCompetencyViewModel.cs index 45dccfc980..b0ebaa1471 100644 --- a/DigitalLearningSolutions.Web/ViewModels/Frameworks/SimilarCompetencyViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/SimilarCompetencyViewModel.cs @@ -1,6 +1,7 @@ namespace DigitalLearningSolutions.Web.ViewModels.Frameworks { using DigitalLearningSolutions.Data.Models.Frameworks; + using DigitalLearningSolutions.Web.Helpers; using System.Collections.Generic; public class SimilarCompetencyViewModel { @@ -8,7 +9,13 @@ public class SimilarCompetencyViewModel public FrameworkCompetency Competency { get; set; } public int FrameworkId { get; set; } public int? FrameworkGroupId { get; set; } - public int FrameworkCompetencyId { get; set; } + public int FrameworkCompetencyId { get; set; } + public string FrameworkConfig { get; set; } public IEnumerable SameCompetency { get; set; } + + public string VocabSingular() + { + return FrameworkVocabularyHelper.VocabularySingular(FrameworkConfig); + } } } diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Competency.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Competency.cshtml index cadadbc388..60bb4d1845 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Competency.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Competency.cshtml @@ -1,8 +1,8 @@ @using DigitalLearningSolutions.Web.ViewModels.Frameworks; @model FrameworkCompetencyViewModel; @{ - ViewData["Title"] = "Competency"; - ViewData["Application"] = "Framework Service"; + ViewData["Title"] = !string.IsNullOrWhiteSpace(Model.VocabSingular()) ? Model.VocabSingular(): "Competency"; + ViewData["Application"] = "Framework Service"; ViewData["HeaderPathName"] = "Framework Service"; } @@ -16,7 +16,7 @@
  1. Frameworks
  2. Framework Structure
  3. -
  4. Competency
  5. +
  6. @Model.VocabSingular()

Back to framework structure

diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SimilarCompetency.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SimilarCompetency.cshtml index 7c7cdbab2f..bf435193a3 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SimilarCompetency.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SimilarCompetency.cshtml @@ -1,7 +1,7 @@ @using DigitalLearningSolutions.Web.ViewModels.Frameworks @model SimilarCompetencyViewModel @{ - ViewData["Title"] = "Similar Competency"; + ViewData["Title"] = $"Similar {Model.VocabSingular()}"; ViewData["Application"] = "Framework Service"; ViewData["HeaderPathName"] = "Framework Service"; } @@ -9,10 +9,10 @@ @section NavMenuItems { } -

Duplicate competency name

+

Duplicate @Model.VocabSingular() name

- The item you are trying to add "@Model.Competency.Name" has the same name as an existing competency. + The item you are trying to add "@Model.Competency.Name" has the same name as an existing @Model.VocabSingular().

You can still create this item but we recommend that you give it a distinct name. @@ -22,10 +22,13 @@

Duplicates

+ @@ -38,6 +41,12 @@ @foreach (var competency in Model.SameCompetency) { +
- Competency + @Model.VocabSingular()
+ Framework + Name
+ Framework + + @competency.FrameworkName + + Name