diff --git a/DigitalLearningSolutions.Web/Helpers/StringHelper.cs b/DigitalLearningSolutions.Web/Helpers/StringHelper.cs index f5f7faf583..c2affb6f74 100644 --- a/DigitalLearningSolutions.Web/Helpers/StringHelper.cs +++ b/DigitalLearningSolutions.Web/Helpers/StringHelper.cs @@ -1,6 +1,7 @@ namespace DigitalLearningSolutions.Web.Helpers { using System; + using System.Text.RegularExpressions; using DigitalLearningSolutions.Data.Extensions; using Microsoft.Extensions.Configuration; @@ -16,5 +17,17 @@ public static string GetLocalRedirectUrl(IConfiguration config, string basicUrl) var applicationPath = new Uri(config.GetAppRootPath()).AbsolutePath.TrimEnd('/'); return applicationPath + basicUrl; } + public static string StripHtmlTags(string input) + { + if (string.IsNullOrWhiteSpace(input)) + { + return string.Empty; + } + + // Remove HTML tags + string result = Regex.Replace(input, "<.*?>", string.Empty).Trim(); + + return string.IsNullOrEmpty(result) ? string.Empty : result; + } } } diff --git a/DigitalLearningSolutions.Web/Services/FrameworkService.cs b/DigitalLearningSolutions.Web/Services/FrameworkService.cs index 7dadad0708..e1edf1637f 100644 --- a/DigitalLearningSolutions.Web/Services/FrameworkService.cs +++ b/DigitalLearningSolutions.Web/Services/FrameworkService.cs @@ -5,6 +5,7 @@ using DigitalLearningSolutions.Data.Models.Frameworks.Import; using DigitalLearningSolutions.Data.Models.SelfAssessments; using System.Collections.Generic; +using DigitalLearningSolutions.Web.Helpers; using AssessmentQuestion = DigitalLearningSolutions.Data.Models.Frameworks.AssessmentQuestion; using CompetencyResourceAssessmentQuestionParameter = DigitalLearningSolutions.Data.Models.Frameworks.CompetencyResourceAssessmentQuestionParameter; @@ -516,7 +517,12 @@ public FrameworkDefaultQuestionUsage GetFrameworkDefaultQuestionUsage(int framew public DetailFramework? GetFrameworkDetailByFrameworkId(int frameworkId, int adminId) { - return frameworkDataService.GetFrameworkDetailByFrameworkId(frameworkId, adminId); + var detailFramework = frameworkDataService.GetFrameworkDetailByFrameworkId(frameworkId, adminId); + if (StringHelper.StripHtmlTags(detailFramework.Description) == string.Empty) + { + detailFramework.Description = string.Empty; + } + return detailFramework; } public FrameworkReview? GetFrameworkReview(int frameworkId, int adminId, int reviewId)