Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
{
Expand Down
5 changes: 3 additions & 2 deletions DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> DefaultQuestionIDs { get; set; } = [];
public int? CustomAssessmentQuestionID { get; set; }
public bool AddDefaultAssessmentQuestions { get; set; } = true;
public bool AddCustomAssessmentQuestion { get; set; } = false;
public List<int> 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; }
Expand Down
Original file line number Diff line number Diff line change
@@ -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<int> 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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
<link rel="stylesheet" href="@Url.Content("~/css/frameworks/frameworksShared.css")" asp-append-version="true">
@section NavMenuItems {
<partial name="Shared/_NavMenuItems" />
}
@section NavBreadcrumbs {
<nav class="nhsuk-breadcrumb" aria-label="Breadcrumb">
<div class="nhsuk-width-container">
<ol class="nhsuk-breadcrumb__list">
<li class="nhsuk-breadcrumb__item"><a class="nhsuk-breadcrumb__link trigger-loader" asp-action="ViewFrameworks" asp-route-tabname="Mine">Frameworks</a></li>
<li class="nhsuk-breadcrumb__item"><a class="nhsuk-breadcrumb__link trigger-loader" asp-action="ViewFramework" asp-route-frameworkId="@ViewContext.RouteData.Values["frameworkId"]" asp-route-tabname="Structure">Framework Structure</a></li>
<li class="nhsuk-breadcrumb__item">Bulk upload</li>
</ol>
<p class="nhsuk-breadcrumb__back"><a class="nhsuk-breadcrumb__backlink" asp-action="ViewFramework" asp-route-frameworkId="@ViewContext.RouteData.Values["frameworkId"]" asp-route-tabname="Structure">Back to framework structure</a></p>
</div>
</nav>
}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
<div class="nhsuk-u-reading-width">
<form class="nhsuk-u-margin-bottom-3" method="post" asp-action="SubmitAddWhoToGroup" enctype="multipart/form-data">
<fieldset class="nhsuk-fieldset">
<legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
<h1 class="nhsuk-fieldset__heading">
Which @Model.FrameworkVocabularyPlural.ToLower() should the questions be added to?
</h1>
</legend>
<div class="nhsuk-hint nhsuk-u-margin-bottom-2">
Choose which @Model.FrameworkVocabularyPlural.ToLower() you want to add the @Model.TotalQuestions assessment questions to
</div>
<div class="nhsuk-hint">
Select one option
</div>
<div class="nhsuk-form-group">
<div class="nhsuk-radios">
@if (Model.CompetenciesToAddCount > 0)
{
<div class="nhsuk-radios__item">
<input class="nhsuk-radios__input" id="option-1" asp-for="@Model.AddAssessmentQuestionsOption" type="radio" value="1" aria-describedby="option-1-hint">
<label class="nhsuk-label nhsuk-radios__label" for="option-1">
Only add questions to new @Model.FrameworkVocabularyPlural.ToLower()
</label>
<div class="nhsuk-hint nhsuk-radios__hint" id="option-1-hint">
@Model.TotalQuestions assessment questions will be added to the @Model.CompetenciesToAddCount new @Model.FrameworkVocabularyPlural.ToLower()
</div>
</div>
}
<div class="nhsuk-radios__item">
<input class="nhsuk-radios__input" id="option-2" asp-for="@Model.AddAssessmentQuestionsOption" type="radio" value="2" aria-describedby="option-2-hint">
<label class="nhsuk-label nhsuk-radios__label" for="option-2">
Only add questions to @(Model.CompetenciesToAddCount > 0 ? Model.CompetenciesToAddCount + " new and " : "") modified @Model.FrameworkVocabularyPlural.ToLower()
</label>
<div class="nhsuk-hint nhsuk-radios__hint" id="option-2-hint">
@(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
</div>
</div>
<div class="nhsuk-radios__item">
<input class="nhsuk-radios__input" id="option-3" asp-for="@Model.AddAssessmentQuestionsOption" type="radio" value="3" aria-describedby="option-3-hint">
<label class="nhsuk-label nhsuk-radios__label" for="option-3">
Add questions to all @Model.FrameworkVocabularyPlural.ToLower() in my uploaded sheet
</label>
<div class="nhsuk-hint nhsuk-radios__hint" id="option-3-hint">
All @(Model.CompetenciesToProcessCount) @Model.FrameworkVocabularyPlural.ToLower() in the sheet that are will have the assessment questions added to them
</div>
</div>
</div>
</div>

</fieldset>
<a asp-controller="Frameworks" asp-action="AddAssessmentQuestions" asp-all-route-data="@cancelLinkData" role="button" class="nhsuk-button nhsuk-button--secondary">Back</a>
<button class="nhsuk-button" type="submit">Next</button>
</form>
<vc:back-link asp-controller="Frameworks" asp-action="Index" asp-all-route-data="@null" link-text="Cancel" />
</div>
</div>
</div>
Loading