From a0fa229394e3fe935a144a1bae76dba8314f7b4e Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Mon, 30 Dec 2024 10:43:24 +0000 Subject: [PATCH 1/5] TD-5155 Begins to implement add questions view model --- .../Import/AddAssessmentQuestionsViewModel.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs new file mode 100644 index 0000000000..b50b1dc6a1 --- /dev/null +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs @@ -0,0 +1,13 @@ +using DigitalLearningSolutions.Data.Models.Frameworks; +using Microsoft.AspNetCore.Mvc.Rendering; +using System.Collections.Generic; + +namespace DigitalLearningSolutions.Web.ViewModels.Frameworks.Import +{ + public class AddAssessmentQuestionsViewModel + { + public DetailFramework Framework { get; set; } + public IEnumerable? FrameworkDefaultQuestions { get; set; } + public SelectList? QuestionSelectList { get; set; } + } +} From e1f0f26bd5ead38cc3163b15004c62a3ab1384a3 Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Tue, 31 Dec 2024 09:37:40 +0000 Subject: [PATCH 2/5] TD-5155 Adds view model and constructor --- .../ImportCompetencies.cs | 22 +++++++++++++++++-- .../Models/BulkCompetenciesData.cs | 1 + .../Import/AddAssessmentQuestionsFormData.cs | 10 +++++++++ .../Import/AddAssessmentQuestionsViewModel.cs | 21 ++++++++++++++---- 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs diff --git a/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs b/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs index dad1bbd4c1..d9cbb44318 100644 --- a/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs +++ b/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs @@ -6,7 +6,9 @@ using DigitalLearningSolutions.Web.ViewModels.Frameworks.Import; using GDS.MultiPageFormData.Enums; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; using System.IO; +using System.Linq; namespace DigitalLearningSolutions.Web.Controllers.FrameworksController { @@ -94,8 +96,24 @@ public IActionResult ImportCompleted() public IActionResult AddAssessmentQuestions() { var data = GetBulkUploadData(); - - return View(); + var adminId = GetAdminId(); + var defaultQuestions = frameworkService.GetFrameworkDefaultQuestionsById(data.FrameworkId, adminId); + var questionList = frameworkService.GetAssessmentQuestions(data.FrameworkId, adminId).ToList(); + var questionSelectList = new SelectList(questionList, "ID", "Label"); + var model = new AddAssessmentQuestionsViewModel + ( + data.FrameworkId, + data.FrameworkName, + data.FrameworkVocubulary, + data.PublishStatusID, + data.CompetenciesToAddCount, + data.CompetenciesToUpdateCount, + defaultQuestions, + questionSelectList + ); + model.DefaultAssessmentQuestionIDs = data.DefaultQuestionIDs; + model.OtherAssessmentQuestionIDs = data.AssessmentQuestionIDs; + return View(model); } private void setupBulkUploadData(int frameworkId, int adminUserID, string competenciessFileName, string tabName, bool isNotBlank) { diff --git a/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs b/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs index 44ae69f92b..525437093c 100644 --- a/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs +++ b/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs @@ -27,6 +27,7 @@ public BulkCompetenciesData(DetailFramework framework, int adminUserId, string c public int AdminUserId { get; set; } public bool IsNotBlank { get; set; } public string CompetenciesFileName { get; set; } + public List DefaultQuestionIDs { get; set; } public List AssessmentQuestionIDs { get; set; } public int? AddAssessmentQuestionOption { get; set; } public int CompetenciesToProcessCount { get; set; } diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs new file mode 100644 index 0000000000..428f7f22df --- /dev/null +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace DigitalLearningSolutions.Web.ViewModels.Frameworks.Import +{ + public class AddAssessmentQuestionsFormData + { + public List DefaultAssessmentQuestionIDs { get; set; } + public List OtherAssessmentQuestionIDs { get; set; } + } +} diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs index b50b1dc6a1..024378c538 100644 --- a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs @@ -1,13 +1,26 @@ using DigitalLearningSolutions.Data.Models.Frameworks; +using DigitalLearningSolutions.Web.Helpers; using Microsoft.AspNetCore.Mvc.Rendering; using System.Collections.Generic; namespace DigitalLearningSolutions.Web.ViewModels.Frameworks.Import { - public class AddAssessmentQuestionsViewModel + public class AddAssessmentQuestionsViewModel( + DetailFramework framework, + int newCompetencies, + int existingCompetencies, + IEnumerable defaultQuestions, + SelectList questionSelectList + ) : AddAssessmentQuestionsFormData { - public DetailFramework Framework { get; set; } - public IEnumerable? FrameworkDefaultQuestions { get; set; } - public SelectList? QuestionSelectList { get; set; } + public int FrameworkID { get; set; } = framework.ID; + public string FrameworkName { get; set; } = framework.FrameworkName; + public string FrameworkVocabularySingular { get; set; } = FrameworkVocabularyHelper.VocabularySingular(framework.FrameworkConfig); + public string FrameworkVocabularyPlural { get; set; } = FrameworkVocabularyHelper.VocabularyPlural(framework.FrameworkConfig); + public int PublishStatusID { get; set; } = framework.PublishStatusID; + public int NewCompetencies { get; set; } = newCompetencies; + public int ExistingCompetencies { get; set; } = existingCompetencies; + public IEnumerable? DefaultQuestions { get; set; } = defaultQuestions; + public SelectList? QuestionSelectList { get; set; } = questionSelectList; } } From 6995c8d5c738edbe0889d1c0214305a9ec22e541 Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Tue, 31 Dec 2024 16:36:33 +0000 Subject: [PATCH 3/5] TD-5155 Implements conditional preselected checkboxes for default questions --- .../ImportCompetencies.cs | 19 ++- .../Models/BulkCompetenciesData.cs | 7 +- .../Import/AddAssessmentQuestionsFormData.cs | 2 + .../Import/AddAssessmentQuestionsViewModel.cs | 15 ++- .../Import/AddAssessmentQuestions.cshtml | 86 ++++++++++++++ .../Developer/Import/ImportCompleted.cshtml | 108 +++++++++--------- .../Developer/Import/ImportFailed.cshtml | 2 +- .../Frameworks/Developer/Import/Index.cshtml | 2 +- .../Developer/Import/UploadResults.cshtml | 2 +- 9 files changed, 177 insertions(+), 66 deletions(-) create mode 100644 DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddAssessmentQuestions.cshtml diff --git a/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs b/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs index d9cbb44318..681d019a2c 100644 --- a/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs +++ b/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs @@ -4,9 +4,12 @@ using DigitalLearningSolutions.Web.Models; using DigitalLearningSolutions.Web.Services; using DigitalLearningSolutions.Web.ViewModels.Frameworks.Import; +using DocumentFormat.OpenXml.Office2010.ExcelAc; using GDS.MultiPageFormData.Enums; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.DotNet.Scaffolding.Shared.Project; +using System.Collections.Generic; using System.IO; using System.Linq; @@ -89,7 +92,7 @@ public IActionResult ImportCompleted() catch (InvalidHeadersException) { FileHelper.DeleteFile(webHostEnvironment, data.CompetenciesFileName); - return View("ImportFailed"); + return View("Developer/Import/ImportFailed"); } } [Route("/Framework/{frameworkId}/{tabname}/Import/AssessmentQuestions")] @@ -98,6 +101,16 @@ public IActionResult AddAssessmentQuestions() var data = GetBulkUploadData(); var adminId = GetAdminId(); var defaultQuestions = frameworkService.GetFrameworkDefaultQuestionsById(data.FrameworkId, adminId); + if (!data.DefaultQuestionIDs.Any() && defaultQuestions.Any() && data.AddDefaultAssessmentQuestions == true) + { + var defaultQuestionsList = new List(); + foreach (var question in defaultQuestions) + { + defaultQuestionsList.Add(question.ID); + } + data.DefaultQuestionIDs = defaultQuestionsList; + setBulkUploadData(data); + } var questionList = frameworkService.GetAssessmentQuestions(data.FrameworkId, adminId).ToList(); var questionSelectList = new SelectList(questionList, "ID", "Label"); var model = new AddAssessmentQuestionsViewModel @@ -111,9 +124,11 @@ public IActionResult AddAssessmentQuestions() defaultQuestions, questionSelectList ); + model.AddDefaultAssessmentQuestions = data.AddDefaultAssessmentQuestions; + model.AddCustomAssessmentQuestion = data.AddCustomAssessmentQuestion; model.DefaultAssessmentQuestionIDs = data.DefaultQuestionIDs; model.OtherAssessmentQuestionIDs = data.AssessmentQuestionIDs; - return View(model); + return View("Developer/Import/AddAssessmentQuestions", model); } private void setupBulkUploadData(int frameworkId, int adminUserID, string competenciessFileName, string tabName, bool isNotBlank) { diff --git a/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs b/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs index 525437093c..69800b0187 100644 --- a/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs +++ b/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs @@ -27,9 +27,10 @@ public BulkCompetenciesData(DetailFramework framework, int adminUserId, string c public int AdminUserId { get; set; } public bool IsNotBlank { get; set; } public string CompetenciesFileName { get; set; } - public List DefaultQuestionIDs { get; set; } - public List AssessmentQuestionIDs { get; set; } - public int? AddAssessmentQuestionOption { get; set; } + public List DefaultQuestionIDs { get; set; } = []; + public List AssessmentQuestionIDs { get; set; } = []; + public bool AddDefaultAssessmentQuestions { get; set; } = true; + public bool AddCustomAssessmentQuestion { get; set; } = false; public int CompetenciesToProcessCount { get; set; } public int CompetenciesToAddCount { get; set; } public int CompetenciesToUpdateCount { get; set; } diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs index 428f7f22df..aa1e0ab2ce 100644 --- a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs @@ -4,6 +4,8 @@ namespace DigitalLearningSolutions.Web.ViewModels.Frameworks.Import { public class AddAssessmentQuestionsFormData { + public bool AddDefaultAssessmentQuestions { get; set; } + public bool AddCustomAssessmentQuestion { get; set; } public List DefaultAssessmentQuestionIDs { get; set; } public List OtherAssessmentQuestionIDs { get; set; } } diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs index 024378c538..bfd1cf3d12 100644 --- a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsViewModel.cs @@ -6,18 +6,21 @@ namespace DigitalLearningSolutions.Web.ViewModels.Frameworks.Import { public class AddAssessmentQuestionsViewModel( - DetailFramework framework, + int frameworkId, + string frameworkName, + string frameworkVocabulary, + int publishStatusId, int newCompetencies, int existingCompetencies, IEnumerable defaultQuestions, SelectList questionSelectList ) : AddAssessmentQuestionsFormData { - public int FrameworkID { get; set; } = framework.ID; - public string FrameworkName { get; set; } = framework.FrameworkName; - public string FrameworkVocabularySingular { get; set; } = FrameworkVocabularyHelper.VocabularySingular(framework.FrameworkConfig); - public string FrameworkVocabularyPlural { get; set; } = FrameworkVocabularyHelper.VocabularyPlural(framework.FrameworkConfig); - public int PublishStatusID { get; set; } = framework.PublishStatusID; + public int FrameworkID { get; set; } = frameworkId; + public string FrameworkName { get; set; } = frameworkName; + public string FrameworkVocabularySingular { get; set; } = FrameworkVocabularyHelper.VocabularySingular(frameworkVocabulary); + public string FrameworkVocabularyPlural { get; set; } = FrameworkVocabularyHelper.VocabularyPlural(frameworkVocabulary); + public int PublishStatusID { get; set; } = publishStatusId; public int NewCompetencies { get; set; } = newCompetencies; public int ExistingCompetencies { get; set; } = existingCompetencies; public IEnumerable? DefaultQuestions { get; set; } = defaultQuestions; diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddAssessmentQuestions.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddAssessmentQuestions.cshtml new file mode 100644 index 0000000000..e3a0e29540 --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddAssessmentQuestions.cshtml @@ -0,0 +1,86 @@ +@using DigitalLearningSolutions.Web.Extensions +@using DigitalLearningSolutions.Web.ViewModels.Frameworks.Import + +@model AddAssessmentQuestionsViewModel + +@{ + ViewData["Application"] = "Framework Service"; + ViewData["HeaderPathName"] = "Framework Service"; + var errorHasOccurred = !ViewData.ModelState.IsValid; + var checkListErrorClass = !ViewData.ModelState.IsValid && Model.AddDefaultAssessmentQuestions == null ? "nhsuk-form-group nhsuk-form-group--error" : "nhsuk-form-group"; + ViewData["Title"] = errorHasOccurred ? "Error: Add Assessment Questions" : "Add Assessment Questions"; + var cancelLinkData = Html.GetRouteValues(); + var hintTextString = Model.NewCompetencies != 0 && Model.ExistingCompetencies != 0 ? "new and/or updated " : (Model.NewCompetencies == 0 ? "updated " : "new "); +} + +@section NavMenuItems { + +} +@section NavBreadcrumbs { + +} +
+
+
+ @if (errorHasOccurred) + { + + } +
+
+
+ +

+ @ViewData["Title"] +

+
+
+ Which assessment questions would you like to attach to the @hintTextString @Model.FrameworkVocabularyPlural.ToLower()? +
+
+ @if (Model.DefaultQuestions.Any()) + { +
+ + +
+
+ +
+
+ @foreach (var (defaultQuestion, index) in Model.DefaultQuestions.Select((t, i) => (t, i))) + { +
+ + +
+ } +
+
+
+ } +
+
+
+
+
+
+
diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/ImportCompleted.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/ImportCompleted.cshtml index 1db1e511ba..fcabc89014 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/ImportCompleted.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/ImportCompleted.cshtml @@ -26,60 +26,64 @@ } -

Delegate file uploaded

-
-

@(Model.ErrorCount == 0 ? "Your file is error free and ready to be processed. Check the information below looks, correct before processing" : "Your file contains the following, including some errors:")

-
    -
  • @Model.ToProcessCount @(Model.ToProcessCount == 1 ? "row" : "rows") to process
  • -
  • @Model.CompetenciesToAddCount new @(Model.CompetenciesToAddCount == 1 ? Model.FrameworkVocabularySingular.ToLower() : Model.FrameworkVocabularyPlural.ToLower()) to add
  • -
  • @Model.ToUpdateOrSkipCount @Model.FrameworkVocabularySingular.ToLower() @(Model.ToUpdateOrSkipCount == 1 ? "record" : "records") to update (or skip if unchanged)
  • - @if (Model.ErrorCount > 0) - { -
  • @Model.ErrorCount @(Model.ErrorCount == 1 ? "row" : "rows") containing errors that cannot be processed
  • - } - else - { -
  • No errors
  • - } -
- @if (Model.ErrorCount == 0) - { - Continue - } - else - { -

Check the information below. You will need fix these errors before continuing or remove the rows with errors from your spreadsheet:

-
- - Error: @Model.ErrorCount @Model.FrameworkVocabularySingular.ToLower() @(Model.ErrorCount == 1 ? "row" : "rows") contain errors and cannot be processed - -
- @foreach (var (rowNumber, errorMessage) in Model.Errors) +
+
+

Delegate file uploaded

+
+

@(Model.ErrorCount == 0 ? "Your file is error free and ready to be processed. Check the information below looks, correct before processing" : "Your file contains the following, including some errors:")

+
    +
  • @Model.ToProcessCount @(Model.ToProcessCount == 1 ? "row" : "rows") to process
  • +
  • @Model.CompetenciesToAddCount new @(Model.CompetenciesToAddCount == 1 ? Model.FrameworkVocabularySingular.ToLower() : Model.FrameworkVocabularyPlural.ToLower()) to add
  • +
  • @Model.ToUpdateOrSkipCount @Model.FrameworkVocabularySingular.ToLower() @(Model.ToUpdateOrSkipCount == 1 ? "record" : "records") to update (or skip if unchanged)
  • + @if (Model.ErrorCount > 0) { -
    -
    - Row @rowNumber -
    -
    - @errorMessage -
    - -
    +
  • @Model.ErrorCount @(Model.ErrorCount == 1 ? "row" : "rows") containing errors that cannot be processed
  • } -
-
-

Upload corrected file

-

- Once you have made corrections to the Excel competency workbook to address the errors above, save and restart the upload process. -

-
+ else + { +
  • No errors
  • + } + + @if (Model.ErrorCount == 0) + { + Continue + } + else + { +

    Check the information below. You will need fix these errors before continuing or remove the rows with errors from your spreadsheet:

    +
    + + Error: @Model.ErrorCount @Model.FrameworkVocabularySingular.ToLower() @(Model.ErrorCount == 1 ? "row" : "rows") contain errors and cannot be processed + +
    + @foreach (var (rowNumber, errorMessage) in Model.Errors) + { +
    +
    + Row @rowNumber +
    +
    + @errorMessage +
    + +
    + } +
    +
    +

    Upload corrected file

    +

    + Once you have made corrections to the Excel competency workbook to address the errors above, save and restart the upload process. +

    + - - - + + + - - - } - + + + } + +
    + diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/ImportFailed.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/ImportFailed.cshtml index c16803e9df..1001851c70 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/ImportFailed.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/ImportFailed.cshtml @@ -30,7 +30,7 @@

    Import failed

    -
    +

    The file that you uploaded either does not have the correct column headers on the first row or is not formatted as a table.

    diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/Index.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/Index.cshtml index 649f7a608f..a11a391b24 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/Index.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/Index.cshtml @@ -31,7 +31,7 @@ }

    Bulk upload @(Model.IsNotBlank ? "or update" : "") @Model.FrameworkVocabularyPlural.ToLower()

    -
    +
    @if (Model.PublishStatusID == 3) { diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/UploadResults.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/UploadResults.cshtml index 16aac10fde..d83d3ca428 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/UploadResults.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/UploadResults.cshtml @@ -30,7 +30,7 @@

    Import competencies complete

    -
    +

    Summary of results:

    • @Model.ProcessedCount @(Model.ProcessedCount == 1 ? "line" : "lines") processed
    • From ca75d04afdb770d6787f26ba768cd42f27c9732e Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Thu, 2 Jan 2025 11:35:02 +0000 Subject: [PATCH 4/5] TD-5155 Implements add assessment questions form view --- .../ImportCompetencies.cs | 14 ++++- .../Models/BulkCompetenciesData.cs | 2 +- .../Import/AddAssessmentQuestionsFormData.cs | 2 +- .../Import/AddAssessmentQuestions.cshtml | 62 ++++++++++++------- 4 files changed, 55 insertions(+), 25 deletions(-) diff --git a/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs b/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs index 681d019a2c..62dbd65315 100644 --- a/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs +++ b/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs @@ -127,9 +127,21 @@ public IActionResult AddAssessmentQuestions() model.AddDefaultAssessmentQuestions = data.AddDefaultAssessmentQuestions; model.AddCustomAssessmentQuestion = data.AddCustomAssessmentQuestion; model.DefaultAssessmentQuestionIDs = data.DefaultQuestionIDs; - model.OtherAssessmentQuestionIDs = data.AssessmentQuestionIDs; + model.CustomAssessmentQuestionID = data.CustomAssessmentQuestionID; return View("Developer/Import/AddAssessmentQuestions", model); } + [HttpPost] + [Route("/Framework/{frameworkId}/{tabname}/Import/AssessmentQuestions")] + public IActionResult AddAssessmentQuestions(AddAssessmentQuestionsFormData model) + { + var data = GetBulkUploadData(); + data.AddDefaultAssessmentQuestions = model.AddDefaultAssessmentQuestions; + data.AddCustomAssessmentQuestion = model.AddCustomAssessmentQuestion; + data.DefaultQuestionIDs = model.DefaultAssessmentQuestionIDs; + data.CustomAssessmentQuestionID = model.CustomAssessmentQuestionID; + setBulkUploadData(data); + return RedirectToAction("AddQuestionsToWhichCompetencies"); + } private void setupBulkUploadData(int frameworkId, int adminUserID, string competenciessFileName, string tabName, bool isNotBlank) { TempData.Clear(); diff --git a/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs b/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs index 69800b0187..2a8e40562d 100644 --- a/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs +++ b/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs @@ -28,7 +28,7 @@ public BulkCompetenciesData(DetailFramework framework, int adminUserId, string c public bool IsNotBlank { get; set; } public string CompetenciesFileName { get; set; } public List DefaultQuestionIDs { get; set; } = []; - public List AssessmentQuestionIDs { get; set; } = []; + public int CustomAssessmentQuestionID { get; set; } public bool AddDefaultAssessmentQuestions { get; set; } = true; public bool AddCustomAssessmentQuestion { get; set; } = false; public int CompetenciesToProcessCount { get; set; } diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs index aa1e0ab2ce..5db7d3b97a 100644 --- a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs @@ -7,6 +7,6 @@ public class AddAssessmentQuestionsFormData public bool AddDefaultAssessmentQuestions { get; set; } public bool AddCustomAssessmentQuestion { get; set; } public List DefaultAssessmentQuestionIDs { get; set; } - public List OtherAssessmentQuestionIDs { get; set; } + public int CustomAssessmentQuestionID { get; set; } } } diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddAssessmentQuestions.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddAssessmentQuestions.cshtml index e3a0e29540..ae9cdec7c2 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddAssessmentQuestions.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddAssessmentQuestions.cshtml @@ -33,11 +33,11 @@
      @if (errorHasOccurred) { - + } -
      +
      -
      +

      @ViewData["Title"] @@ -50,37 +50,55 @@ @if (Model.DefaultQuestions.Any()) {
      - + -
      -
      +
      + choose which default questions associated with this framework to add to the imported and/or updated @Model.FrameworkVocabularyPlural.ToLower() +
      +
      -
      -
      - @foreach (var (defaultQuestion, index) in Model.DefaultQuestions.Select((t, i) => (t, i))) - { -
      - - -
      - } +
      +
      + @foreach (var (defaultQuestion, index) in Model.DefaultQuestions.Select((t, i) => (t, i))) + { +
      + + +
      + } +
      } +
      + + +
      +
      + + + +

      +
      +
    From dd936159362061546b6ec18bafec9fcca77ea7d0 Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Thu, 2 Jan 2025 11:47:10 +0000 Subject: [PATCH 5/5] Tweaks post data processing to handle storing false values --- .../FrameworksController/ImportCompetencies.cs | 18 ++++++++++++++++-- .../Models/BulkCompetenciesData.cs | 2 +- .../Import/AddAssessmentQuestionsFormData.cs | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs b/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs index 62dbd65315..1e77c8f05c 100644 --- a/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs +++ b/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs @@ -136,9 +136,23 @@ public IActionResult AddAssessmentQuestions(AddAssessmentQuestionsFormData model { var data = GetBulkUploadData(); data.AddDefaultAssessmentQuestions = model.AddDefaultAssessmentQuestions; + if (model.AddDefaultAssessmentQuestions) + { + data.DefaultQuestionIDs = model.DefaultAssessmentQuestionIDs; + } + else + { + data.DefaultQuestionIDs = []; + } data.AddCustomAssessmentQuestion = model.AddCustomAssessmentQuestion; - data.DefaultQuestionIDs = model.DefaultAssessmentQuestionIDs; - data.CustomAssessmentQuestionID = model.CustomAssessmentQuestionID; + if (model.AddCustomAssessmentQuestion) + { + data.CustomAssessmentQuestionID = model.CustomAssessmentQuestionID; + } + else + { + data.CustomAssessmentQuestionID = null; + } setBulkUploadData(data); return RedirectToAction("AddQuestionsToWhichCompetencies"); } diff --git a/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs b/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs index 2a8e40562d..bf7cb9b61d 100644 --- a/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs +++ b/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs @@ -28,7 +28,7 @@ public BulkCompetenciesData(DetailFramework framework, int adminUserId, string c public bool IsNotBlank { get; set; } public string CompetenciesFileName { get; set; } public List DefaultQuestionIDs { get; set; } = []; - public int CustomAssessmentQuestionID { get; set; } + public int? CustomAssessmentQuestionID { get; set; } public bool AddDefaultAssessmentQuestions { get; set; } = true; public bool AddCustomAssessmentQuestion { get; set; } = false; public int CompetenciesToProcessCount { get; set; } diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs index 5db7d3b97a..4b90f1198c 100644 --- a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddAssessmentQuestionsFormData.cs @@ -7,6 +7,6 @@ public class AddAssessmentQuestionsFormData public bool AddDefaultAssessmentQuestions { get; set; } public bool AddCustomAssessmentQuestion { get; set; } public List DefaultAssessmentQuestionIDs { get; set; } - public int CustomAssessmentQuestionID { get; set; } + public int? CustomAssessmentQuestionID { get; set; } } }