Skip to content

Commit 8240175

Browse files
authored
Merge pull request #3201 from TechnologyEnhancedLearning/Develop/Fixes/TD-5263-FixEmptyDescription
TD- 5263 fix empty description
2 parents 877288e + 4d5c08c commit 8240175

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

DigitalLearningSolutions.Web/Helpers/StringHelper.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace DigitalLearningSolutions.Web.Helpers
22
{
33
using System;
4+
using System.Text.RegularExpressions;
45
using DigitalLearningSolutions.Data.Extensions;
56
using Microsoft.Extensions.Configuration;
67

@@ -16,5 +17,17 @@ public static string GetLocalRedirectUrl(IConfiguration config, string basicUrl)
1617
var applicationPath = new Uri(config.GetAppRootPath()).AbsolutePath.TrimEnd('/');
1718
return applicationPath + basicUrl;
1819
}
20+
public static string StripHtmlTags(string input)
21+
{
22+
if (string.IsNullOrWhiteSpace(input))
23+
{
24+
return string.Empty;
25+
}
26+
27+
// Remove HTML tags
28+
string result = Regex.Replace(input, "<.*?>", string.Empty).Trim();
29+
30+
return string.IsNullOrEmpty(result) ? string.Empty : result;
31+
}
1932
}
2033
}

DigitalLearningSolutions.Web/Services/FrameworkService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using DigitalLearningSolutions.Data.Models.Frameworks.Import;
66
using DigitalLearningSolutions.Data.Models.SelfAssessments;
77
using System.Collections.Generic;
8+
using DigitalLearningSolutions.Web.Helpers;
89
using AssessmentQuestion = DigitalLearningSolutions.Data.Models.Frameworks.AssessmentQuestion;
910
using CompetencyResourceAssessmentQuestionParameter =
1011
DigitalLearningSolutions.Data.Models.Frameworks.CompetencyResourceAssessmentQuestionParameter;
@@ -516,7 +517,12 @@ public FrameworkDefaultQuestionUsage GetFrameworkDefaultQuestionUsage(int framew
516517

517518
public DetailFramework? GetFrameworkDetailByFrameworkId(int frameworkId, int adminId)
518519
{
519-
return frameworkDataService.GetFrameworkDetailByFrameworkId(frameworkId, adminId);
520+
var detailFramework = frameworkDataService.GetFrameworkDetailByFrameworkId(frameworkId, adminId);
521+
if (StringHelper.StripHtmlTags(detailFramework.Description) == string.Empty)
522+
{
523+
detailFramework.Description = string.Empty;
524+
}
525+
return detailFramework;
520526
}
521527

522528
public FrameworkReview? GetFrameworkReview(int frameworkId, int adminId, int reviewId)

0 commit comments

Comments
 (0)