diff --git a/DigitalLearningSolutions.Data.Migrations/202609021546_Alter_Table_SelfAssessments.cs b/DigitalLearningSolutions.Data.Migrations/202609021546_Alter_Table_SelfAssessments.cs new file mode 100644 index 0000000000..5ea9f07726 --- /dev/null +++ b/DigitalLearningSolutions.Data.Migrations/202609021546_Alter_Table_SelfAssessments.cs @@ -0,0 +1,23 @@ +namespace DigitalLearningSolutions.Data.Migrations +{ + using FluentMigrator; + [Migration(202609021546)] + public class Alter_Table_SelfAssessments : Migration + { + public override void Up() + { + Alter.Table("SelfAssessments") + .AlterColumn("ManageOptionalCompetenciesPrompt") + .AsString(2000) + .Nullable(); + } + + public override void Down() + { + Alter.Table("SelfAssessments") + .AlterColumn("ManageOptionalCompetenciesPrompt") + .AsString(1000) + .Nullable(); + } + } +} diff --git a/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs b/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs index 25888699d5..10d40e1b4c 100644 --- a/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs +++ b/DigitalLearningSolutions.Web/Controllers/CompetencyAssessmentsController/CompetencyAssessments.cs @@ -775,9 +775,20 @@ public IActionResult SetOptionalCompetencyLearnerPrompt(int competencyAssessment } [HttpPost] [Route("/Self-Assessment/{competencyAssessmentId}/{vocabularyPlural}/Optional/LearnerPrompt")] - public IActionResult SetOptionalCompetencyLearnerPrompt(SetOptionalCompetencyLearnerPromptFormData model) + public IActionResult SetOptionalCompetencyLearnerPrompt(SetOptionalCompetencyLearnerPromptViewModel model) { - + if (StringHelper.StripHtmlTags(model.ManageOptionalCompetenciesPrompt).Length > 1000) + { + ModelState.AddModelError(nameof(model.ManageOptionalCompetenciesPrompt), "Prompt text cannot exceed 1000 characters."); + return View("SetOptionalCompetencyLearnerPrompt", model); + } + + if (model.ManageOptionalCompetenciesPrompt?.Length > 2000) + { + ModelState.AddModelError(nameof(model.ManageOptionalCompetenciesPrompt), + "The formatted content is too large to save.Please reduce the content or formatting."); + return View("SetOptionalCompetencyLearnerPrompt", model); + } competencyAssessmentService.UpdateManageOptionalCompetenciesPrompt(model.ID, model.ManageOptionalCompetenciesPrompt); return RedirectToAction("ManageOptionalCompetencies", new { competencyAssessmentId = model.ID, vocabularyPlural = model.VocabularyPlural }); } diff --git a/DigitalLearningSolutions.Web/Scripts/frameworks/htmleditor.ts b/DigitalLearningSolutions.Web/Scripts/frameworks/htmleditor.ts index 3952d26df3..b10a1c6042 100644 --- a/DigitalLearningSolutions.Web/Scripts/frameworks/htmleditor.ts +++ b/DigitalLearningSolutions.Web/Scripts/frameworks/htmleditor.ts @@ -1,4 +1,6 @@ import { Jodit } from 'jodit'; +// eslint-disable-next-line import/extensions +import 'jodit/esm/plugins/all.js'; import DOMPurify from 'dompurify'; let jodited = false; @@ -59,6 +61,7 @@ if (jodited === false) { 'ol', '|', 'undo', 'redo', ], + countTextSpaces: true, style: { backgroundColor: '#FFF', }, diff --git a/DigitalLearningSolutions.Web/Styles/jodit.scss b/DigitalLearningSolutions.Web/Styles/jodit.scss index 416099e8f7..a4b59c85af 100644 --- a/DigitalLearningSolutions.Web/Styles/jodit.scss +++ b/DigitalLearningSolutions.Web/Styles/jodit.scss @@ -1,9 +1,10 @@ -@use "jodit/build/jodit.min"; +@use "jodit/es2021/jodit.min.css"; .jodit-error { border: 2px solid red !important; border-radius: 4px; } + .jodit-placeholder { display: none !important; } diff --git a/DigitalLearningSolutions.Web/ViewModels/CompetencyAssessments/SetOptionalCompetencyLearnerPromptViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/CompetencyAssessments/SetOptionalCompetencyLearnerPromptViewModel.cs index 7c58320f22..ac2fa489a1 100644 --- a/DigitalLearningSolutions.Web/ViewModels/CompetencyAssessments/SetOptionalCompetencyLearnerPromptViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/CompetencyAssessments/SetOptionalCompetencyLearnerPromptViewModel.cs @@ -7,6 +7,10 @@ public class SetOptionalCompetencyLearnerPromptViewModel : SetOptionalCompetencyLearnerPromptFormData { + public SetOptionalCompetencyLearnerPromptViewModel() + { + } + public SetOptionalCompetencyLearnerPromptViewModel(CompetencyAssessmentBase competencyAssessmentBase, IEnumerable competencies) { ID = competencyAssessmentBase.ID; diff --git a/DigitalLearningSolutions.Web/Views/CompetencyAssessments/SetOptionalCompetencyLearnerPrompt.cshtml b/DigitalLearningSolutions.Web/Views/CompetencyAssessments/SetOptionalCompetencyLearnerPrompt.cshtml index 5b3329863c..33d1b16988 100644 --- a/DigitalLearningSolutions.Web/Views/CompetencyAssessments/SetOptionalCompetencyLearnerPrompt.cshtml +++ b/DigitalLearningSolutions.Web/Views/CompetencyAssessments/SetOptionalCompetencyLearnerPrompt.cshtml @@ -3,6 +3,7 @@ @{ ViewData["Title"] = $"Set optional {Model.VocabularyPlural.ToLower()} learner prompt"; ViewData["Application"] = "Framework service"; + var errorHasOccurred = !ViewData.ModelState.IsValid && ViewData.ModelState.ContainsKey(nameof(Model.ManageOptionalCompetenciesPrompt)); } @@ -24,6 +25,10 @@ }
+ @if (errorHasOccurred) + { + + }

@Model.CompetencyAssessmentName @@ -45,12 +50,12 @@ hint-text="This text will be displayed above the optional @Model.VocabularyPlural.ToLower() list." populate-with-current-value="true" spell-check="false" /> - +