diff --git a/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs b/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs index 1e77c8f05c..68d3e26d6f 100644 --- a/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs +++ b/DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs @@ -4,11 +4,9 @@ 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; @@ -85,7 +83,7 @@ public IActionResult ImportCompleted() var resultsModel = new ImportCompetenciesPreProcessViewModel(results, data) { IsNotBlank = data.IsNotBlank, TabName = data.TabName }; data.CompetenciesToProcessCount = resultsModel.ToProcessCount; data.CompetenciesToAddCount = resultsModel.CompetenciesToAddCount; - data.CompetenciesToUpdateCount = resultsModel.CompetenciesToUpdateCount; + data.CompetenciesToUpdateCount = resultsModel.ToUpdateOrSkipCount; setBulkUploadData(data); return View("Developer/Import/ImportCompleted", resultsModel); } @@ -153,8 +151,45 @@ public IActionResult AddAssessmentQuestions(AddAssessmentQuestionsFormData model { data.CustomAssessmentQuestionID = null; } + if (data.CompetenciesToUpdateCount > 0) + { + data.AddAssessmentQuestionsOption = 2; + setBulkUploadData(data); + return RedirectToAction("AddQuestionsToWhichCompetencies", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName }); + } + else + { + data.AddAssessmentQuestionsOption = 1; + setBulkUploadData(data); + return RedirectToAction("Summary", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName }); + } + } + [Route("/Framework/{frameworkId}/{tabname}/Import/AssessmentQuestions/Competencies")] + public IActionResult AddQuestionsToWhichCompetencies() + { + var data = GetBulkUploadData(); + var model = new AddQuestionsToWhichCompetenciesViewModel + ( + data.FrameworkId, + data.FrameworkName, + data.FrameworkVocubulary, + data.DefaultQuestionIDs, + data.CustomAssessmentQuestionID, + data.AddAssessmentQuestionsOption, + data.CompetenciesToProcessCount, + data.CompetenciesToAddCount, + data.CompetenciesToUpdateCount + ); + return View("Developer/Import/AddQuestionsToWhichCompetencies", model); + } + [HttpPost] + [Route("/Framework/{frameworkId}/{tabname}/Import/AssessmentQuestions/Competencies")] + public IActionResult AddQuestionsToWhichCompetencies(int AddAssessmentQuestionsOption) + { + var data = GetBulkUploadData(); + data.AddAssessmentQuestionsOption = AddAssessmentQuestionsOption; setBulkUploadData(data); - return RedirectToAction("AddQuestionsToWhichCompetencies"); + return RedirectToAction("Summary", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName }); } 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 bf7cb9b61d..738acbf9ea 100644 --- a/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs +++ b/DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs @@ -27,10 +27,11 @@ 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 int? CustomAssessmentQuestionID { get; set; } public bool AddDefaultAssessmentQuestions { get; set; } = true; public bool AddCustomAssessmentQuestion { get; set; } = false; + public List DefaultQuestionIDs { get; set; } = []; + public int? CustomAssessmentQuestionID { get; set; } + public int AddAssessmentQuestionsOption { get; set; } //1 = only added, 2 = added and updated, 3 = all uploaded public int CompetenciesToProcessCount { get; set; } public int CompetenciesToAddCount { get; set; } public int CompetenciesToUpdateCount { get; set; } diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddQuestionsToWhichCompetenciesViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddQuestionsToWhichCompetenciesViewModel.cs new file mode 100644 index 0000000000..d6cbae84ca --- /dev/null +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/AddQuestionsToWhichCompetenciesViewModel.cs @@ -0,0 +1,41 @@ +using DigitalLearningSolutions.Web.Helpers; +using System.Collections.Generic; +using System.Runtime.Versioning; + +namespace DigitalLearningSolutions.Web.ViewModels.Frameworks.Import +{ + public class AddQuestionsToWhichCompetenciesViewModel + { + public AddQuestionsToWhichCompetenciesViewModel + ( + int frameworkId, + string frameworkName, + string frameworkVocabulary, + List defaultQuestions, + int? customQuestionId, + int addAssessmentQuestionsOption, + int competenciesToProcessCount, + int competenciesToAddCount, + int competenciesToUpdateCount) + { + FrameworkID = frameworkId; + FrameworkName = frameworkName; + FrameworkVocabularySingular = FrameworkVocabularyHelper.VocabularySingular(frameworkVocabulary); + FrameworkVocabularyPlural = FrameworkVocabularyHelper.VocabularyPlural(frameworkVocabulary); + TotalQuestions = defaultQuestions.Count + (customQuestionId != null ? 1 : 0); + AddAssessmentQuestionsOption = addAssessmentQuestionsOption; + CompetenciesToProcessCount = competenciesToProcessCount; + CompetenciesToAddCount = competenciesToAddCount; + CompetenciesToUpdateCount = competenciesToUpdateCount; + } + public int FrameworkID { get; set; } + public string FrameworkName { get; set; } + public string FrameworkVocabularySingular { get; set; } + public string FrameworkVocabularyPlural { get; set; } + public int TotalQuestions { get; set; } + public int AddAssessmentQuestionsOption { get; set; } = 1; //1 = only added, 2 = added and updated, 3 = all uploaded + public int CompetenciesToProcessCount { get; set; } + public int CompetenciesToAddCount { get; set; } + public int CompetenciesToUpdateCount { get; set; } + } +} diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/ImportCompetenciesPreProcessViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/ImportCompetenciesPreProcessViewModel.cs index f92f056115..67f604723a 100644 --- a/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/ImportCompetenciesPreProcessViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/ImportCompetenciesPreProcessViewModel.cs @@ -18,8 +18,6 @@ public ImportCompetenciesPreProcessViewModel(ImportCompetenciesResult bulkCompet ToProcessCount = bulkCompetenciesResult.ProcessedCount; CompetenciesToAddCount = bulkCompetenciesResult.CompetencyAddedCount; ToUpdateOrSkipCount = bulkCompetenciesResult.CompetencyUpdatedCount; - CompetencyGroupsToAddCount = bulkCompetenciesResult.GroupAddedCount; - CompetencyGroupsToUpdateCount = bulkCompetenciesResult.GroupUpdatedCount; Errors = bulkCompetenciesResult.Errors.Select(x => (x.RowNumber, MapReasonToErrorMessage(x.Reason, FrameworkVocabularyHelper.VocabularySingular(bulkCompetenciesData.FrameworkVocubulary)))); } public string? FrameworkName { get; set; } @@ -30,9 +28,6 @@ public ImportCompetenciesPreProcessViewModel(ImportCompetenciesResult bulkCompet public int ErrorCount => Errors.Count(); public int ToProcessCount { get; set; } public int CompetenciesToAddCount { get; set; } - public int CompetenciesToUpdateCount { get; set; } - public int CompetencyGroupsToAddCount { get; set; } - public int CompetencyGroupsToUpdateCount { get; set; } public int ToUpdateOrSkipCount { get; set; } public string? ImportFile { get; set; } public bool IsNotBlank { get; set; } diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddQuestionsToWhichCompetencies.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddQuestionsToWhichCompetencies.cshtml new file mode 100644 index 0000000000..bb5a3b3a5f --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/AddQuestionsToWhichCompetencies.cshtml @@ -0,0 +1,87 @@ +@using DigitalLearningSolutions.Web.Extensions +@using DigitalLearningSolutions.Web.ViewModels.Frameworks.Import + +@model AddQuestionsToWhichCompetenciesViewModel + +@{ + ViewData["Application"] = "Framework Service"; + ViewData["HeaderPathName"] = "Framework Service"; + var errorHasOccurred = !ViewData.ModelState.IsValid; + ViewData["Title"] = errorHasOccurred ? "Error: Add Assessment Questions" : "Add Assessment Questions"; + var cancelLinkData = Html.GetRouteValues(); +} + +@section NavMenuItems { + +} +@section NavBreadcrumbs { + +} +
+
+
+
+
+ +

+ Which @Model.FrameworkVocabularyPlural.ToLower() should the questions be added to? +

+
+
+ Choose which @Model.FrameworkVocabularyPlural.ToLower() you want to add the @Model.TotalQuestions assessment questions to +
+
+ Select one option +
+
+
+ @if (Model.CompetenciesToAddCount > 0) + { +
+ + +
+ @Model.TotalQuestions assessment questions will be added to the @Model.CompetenciesToAddCount new @Model.FrameworkVocabularyPlural.ToLower() +
+
+ } +
+ + +
+ @(Model.CompetenciesToAddCount > 0 ? Model.CompetenciesToAddCount + " new @Model.FrameworkVocabularyPlural.ToLower() and only those of the " : "Only those of the ") @Model.CompetenciesToUpdateCount existing @Model.FrameworkVocabularyPlural.ToLower() that have been modified in the sheet will have the assessment questions added +
+
+
+ + +
+ All @(Model.CompetenciesToProcessCount) @Model.FrameworkVocabularyPlural.ToLower() in the sheet that are will have the assessment questions added to them +
+
+
+
+ +
+ Back + +
+ +
+
+