Skip to content

Commit ad4b3b0

Browse files
authored
Merge pull request #3065 from TechnologyEnhancedLearning/Develop/Features/TD-5233-BulkImportTidyUp
TD-5233 bulk import tidy up tasks
2 parents a73f76a + bf2b2af commit ad4b3b0

File tree

8 files changed

+39
-21
lines changed

8 files changed

+39
-21
lines changed

DigitalLearningSolutions.Data/Models/Frameworks/Import/CompetencyTableRow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public enum RowStatus
99
CompetencyGroupAndCompetencyInserted,
1010
CompetencyInserted,
1111
CompetencyUpdated,
12-
CompetencyUpdatedAndReordered,
1312
CompetencyGroupInserted,
1413
CompetencyGroupUpdated,
1514
CompetencyGroupAndCompetencyUpdated,
@@ -42,6 +41,7 @@ public CompetencyTableRow(IXLTable table, IXLRangeRow row)
4241
public string? AlwaysShowDescriptionRaw { get; set; }
4342
public ImportCompetenciesResult.ErrorReason? Error { get; set; }
4443
public RowStatus RowStatus { get; set; }
44+
public bool Reordered { get; set; } = false;
4545
public bool Validate()
4646
{
4747
if (string.IsNullOrEmpty(Competency))

DigitalLearningSolutions.Data/Models/Frameworks/Import/ImportCompetenciesResult.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ IReadOnlyCollection<CompetencyTableRow> competencyTableRows
2222
{
2323
ProcessedCount = competencyTableRows.Count;
2424
CompetencyAddedCount = competencyTableRows.Count(dr => dr.RowStatus == RowStatus.CompetencyInserted | dr.RowStatus == RowStatus.CompetencyGroupAndCompetencyInserted);
25-
CompetencyUpdatedCount = competencyTableRows.Count(dr => dr.RowStatus == RowStatus.CompetencyUpdated | dr.RowStatus == RowStatus.CompetencyUpdatedAndReordered);
26-
CompetencyReorderedCount = competencyTableRows.Count(dr => dr.RowStatus == RowStatus.CompetencyUpdatedAndReordered);
25+
CompetencyUpdatedCount = competencyTableRows.Count(dr => dr.RowStatus == RowStatus.CompetencyUpdated | dr.RowStatus == RowStatus.CompetencyGroupAndCompetencyUpdated);
2726
GroupAddedCount = competencyTableRows.Count(dr => dr.RowStatus == RowStatus.CompetencyGroupInserted | dr.RowStatus == RowStatus.CompetencyGroupAndCompetencyInserted);
28-
SkippedCount = competencyTableRows.Count(dr => dr.RowStatus == RowStatus.Skipped);
27+
SkippedCount = competencyTableRows.Count(dr => dr.RowStatus == RowStatus.Skipped && dr.Reordered == false);
28+
CompetencyReorderedCount = competencyTableRows.Count(dr => dr.Reordered == true);
2929
Errors = competencyTableRows.Where(dr => dr.Error.HasValue).Select(dr => (dr.RowNumber, dr.Error!.Value));
3030
FlagCount = competencyTableRows
3131
.Where(row => !string.IsNullOrWhiteSpace(row.FlagsCsv))

DigitalLearningSolutions.Web/Services/ImportCompetenciesFromFileService.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,10 @@ private void PreProcessCompetencyRow(CompetencyTableRow competencyRow, List<int>
6161
{
6262
int originalIndex = existingIds.IndexOf(id);
6363
int newIndex = newIds.IndexOf(id);
64-
if (originalIndex == newIndex)
64+
competencyRow.RowStatus = RowStatus.CompetencyUpdated;
65+
if (originalIndex != newIndex)
6566
{
66-
competencyRow.RowStatus = RowStatus.CompetencyUpdated;
67-
}
68-
else
69-
{
70-
competencyRow.RowStatus = RowStatus.CompetencyUpdatedAndReordered;
67+
competencyRow.Reordered = true;
7168
}
7269
}
7370
}
@@ -125,7 +122,7 @@ internal ImportCompetenciesResult ProcessCompetenciesTable(IXLTable table, int a
125122
{
126123
maxFrameworkCompetencyGroupId = ProcessCompetencyRow(adminUserId, frameworkId, maxFrameworkCompetencyId, maxFrameworkCompetencyGroupId, addAssessmentQuestionsOption, reorderCompetenciesOption, customAssessmentQuestionID, defaultQuestionIds, competencyRow);
127124
}
128-
// TO DO: Check for changes to competency group order and apply them if appropriate:
125+
// Check for changes to competency group order and apply them if appropriate:
129126
if (reorderCompetenciesOption == 2)
130127
{
131128
var distinctCompetencyGroups = competenciesRows
@@ -147,6 +144,10 @@ internal ImportCompetenciesResult ProcessCompetenciesTable(IXLTable table, int a
147144
{
148145
frameworkService.MoveFrameworkCompetencyGroup(thisGroup.ID, true, direction);
149146
}
147+
competenciesRows
148+
.Where(row => row.CompetencyGroup == thisGroup.Name)
149+
.ToList()
150+
.ForEach(row => row.Reordered = true);
150151
}
151152
}
152153
}
@@ -274,10 +275,7 @@ CompetencyTableRow competencyRow
274275
frameworkService.MoveFrameworkCompetency(frameworkCompetencyId, true, direction);
275276
}
276277

277-
if (competencyRow.RowStatus == RowStatus.Skipped)
278-
{
279-
competencyRow.RowStatus = RowStatus.CompetencyUpdated;
280-
}
278+
competencyRow.Reordered = true;
281279
}
282280
}
283281

DigitalLearningSolutions.Web/ViewModels/Frameworks/Import/ImportCompetenciesResultsViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public ImportCompetenciesResultsViewModel(ImportCompetenciesResult importCompete
1414
CompetenciesUpdatedCount = importCompetenciesResult.CompetencyUpdatedCount;
1515
CompetencyGroupsInsertedCount = importCompetenciesResult.GroupAddedCount;
1616
CompetencyGroupsUpdatedCount = importCompetenciesResult.GroupUpdatedCount;
17+
CompetenciesReorderedCount = importCompetenciesResult.CompetencyReorderedCount;
1718
SkippedCount = importCompetenciesResult.SkippedCount;
1819
Errors = importCompetenciesResult.Errors.Select(x => (x.RowNumber, MapReasonToErrorMessage(x.Reason)));
1920
FrameworkID = frameworkId;
@@ -26,6 +27,7 @@ public ImportCompetenciesResultsViewModel(ImportCompetenciesResult importCompete
2627
public int ProcessedCount { get; set; }
2728
public int CompetenciesInsertedCount { get; set; }
2829
public int CompetenciesUpdatedCount { get; set; }
30+
public int CompetenciesReorderedCount { get; set; }
2931
public int CompetencyGroupsInsertedCount { get; set; }
3032
public int CompetencyGroupsUpdatedCount { get; set; }
3133
public int SkippedCount { get; set; }

DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/ApplyCompetencyOrdering.cshtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<p>We strongly recommend including all framework competencies in your uploaded sheet if reordering competencies to ensure that the correct sequence is applied.</p>
4242
</div>
4343
<div class="nhsuk-hint nhsuk-u-margin-bottom-2">
44-
Your uploaded file includes changes to the sequence of existing @Model.FrameworkVocabularyPlural.ToLower(). Choose whether to store the changes to @Model.FrameworkVocabularySingular.ToLower() sequence during update.
44+
Your uploaded file includes changes to the order of existing @Model.FrameworkVocabularyPlural.ToLower(). Choose whether to store the changes to @Model.FrameworkVocabularySingular.ToLower() order during update.
4545
</div>
4646
<div class="nhsuk-hint">
4747
Select an option
@@ -51,7 +51,7 @@
5151
<div class="nhsuk-radios__item">
5252
<input class="nhsuk-radios__input" id="option-1" asp-for="@Model.ReorderCompetenciesOption" type="radio" value="1" aria-describedby="option-1-hint">
5353
<label class="nhsuk-label nhsuk-radios__label" for="option-1">
54-
Ignore changes to @Model.FrameworkVocabularySingular.ToLower() sequence
54+
Ignore changes to @Model.FrameworkVocabularySingular.ToLower() order
5555
</label>
5656
<div class="nhsuk-hint nhsuk-radios__hint" id="option-1-hint">
5757
@Model.FrameworkVocabularyPlural will be updated if they have changed but there sequence/order in the framework will not change.
@@ -60,10 +60,10 @@
6060
<div class="nhsuk-radios__item">
6161
<input class="nhsuk-radios__input" id="option-2" asp-for="@Model.ReorderCompetenciesOption" type="radio" value="2" aria-describedby="option-2-hint">
6262
<label class="nhsuk-label nhsuk-radios__label" for="option-2">
63-
Apply changes to @Model.FrameworkVocabularySingular.ToLower() sequence
63+
Apply changes to @Model.FrameworkVocabularySingular.ToLower() order
6464
</label>
6565
<div class="nhsuk-hint nhsuk-radios__hint" id="option-2-hint">
66-
The sequence of @Model.FrameworkVocabularyPlural.ToLower() in the framework will be changed to reflect the order in the sheet during processing.
66+
The oder of @Model.FrameworkVocabularyPlural.ToLower() in the framework will be changed to reflect the order in the sheet during processing.
6767
</div>
6868
</div>
6969
</div>

DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/ImportSummary.cshtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
<div class="nhsuk-grid-row">
3232
<div class="nhsuk-grid-column-full">
3333
<h1 class="nhsuk-heading-xl">@Model.FrameworkVocabularyPlural import summary</h1>
34+
@if (Model.PublishStatusID == 3)
35+
{
36+
<partial name="Shared/_PublishedWarning" />
37+
}
3438
<p class="nhsuk-body-l nhsuk-u-reading-width">Your @Model.FrameworkVocabularySingular.ToLower() sheet is ready to be processed. Please check the details below are correct before proceeding to @process @Model.FrameworkVocabularyPlural.ToLower() in the framework @Model.FrameworkName.</p>
3539
<h2>Upload summary</h2>
3640
<dl class="nhsuk-summary-list">

DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/Index.cshtml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,23 @@
3636
{
3737
<partial name="Shared/_PublishedWarning" />
3838
}
39-
@* <vc:inset-text css-class="" text="The building blocks for your framework will be referred to as 'competencies' for the purpose of importing. Once they have been imported, they will be referred to using your chosen vocabulary."></vc:inset-text> *@
39+
4040
<div class="nhsuk-form-group">
4141
@if (Model.IsNotBlank)
4242
{
43-
43+
<div class="nhsuk-inset-text">
44+
<span class="nhsuk-u-visually-hidden">Note: </span>
45+
<p>
46+
Bulk upload <strong>cannot</strong> be used to:
47+
</p>
48+
<ul>
49+
<li>Delete @Model.FrameworkVocabularyPlural.ToLower() or @Model.FrameworkVocabularySingular.ToLower() groups</li>
50+
<li>Remove assessment questions from existing @Model.FrameworkVocabularyPlural.ToLower()</li>
51+
<li>Add more than one custom assessment question to uploaded @Model.FrameworkVocabularyPlural.ToLower()</li>
52+
<li>Remove flags from @Model.FrameworkVocabularyPlural.ToLower()</li>
53+
</ul>
54+
55+
</div>
4456
<p class="nhsuk-body-m">
4557
To bulk add and/or update @Model.FrameworkVocabularyPlural.ToLower() in the framework, <strong>@Model.FrameworkName</strong>, download an Excel workbook using one of the options below.
4658
</p>
@@ -91,6 +103,7 @@
91103
}
92104
else
93105
{
106+
<vc:inset-text css-class="" text="Bulk upload cannot be used to add more than one custom assessment question to uploaded @Model.FrameworkVocabularyPlural.ToLower()."></vc:inset-text>
94107
<p class="nhsuk-body-m">
95108
Download a blank template for bulk adding @Model.FrameworkVocabularyPlural.ToLower() to your framework, <strong>@Model.FrameworkName</strong>. This Excel file will be empty. New @Model.FrameworkVocabularyPlural.ToLower() can be added by including their details on a blank row.
96109
</p>

DigitalLearningSolutions.Web/Views/Frameworks/Developer/Import/UploadResults.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<li>@Model.CompetencyGroupsInsertedCount new @(Model.CompetencyGroupsInsertedCount == 1 ? $"{Model.FrameworkVocabularySingular.ToLower()} group" : $"{Model.FrameworkVocabularySingular.ToLower()} groups") inserted</li>
3838
<li>@Model.CompetenciesInsertedCount new @(Model.CompetenciesInsertedCount == 1 ? Model.FrameworkVocabularySingular.ToLower() : Model.FrameworkVocabularyPlural.ToLower()) inserted</li>
3939
<li>@Model.CompetenciesUpdatedCount existing @(Model.CompetenciesUpdatedCount == 1 ? Model.FrameworkVocabularySingular.ToLower() : Model.FrameworkVocabularyPlural.ToLower()) updated</li>
40+
<li>@Model.CompetenciesReorderedCount existing @(Model.CompetenciesReorderedCount == 1 ? Model.FrameworkVocabularySingular.ToLower() : Model.FrameworkVocabularyPlural.ToLower()) reordered</li>
4041
<li>@Model.SkippedCount rows @(Model.SkippedCount == 1 ? "line" : "lines") skipped (nothing inserted or updated but no errors)</li>
4142
<li>@Model.ErrorCount @(Model.ErrorCount == 1 ? "line" : "lines") skipped due to errors</li>
4243
</ul>

0 commit comments

Comments
 (0)