Skip to content

Commit 732ab42

Browse files
committed
TD-5233 Indicates the number of competencies reordered in the upload results page
1 parent a25e7b5 commit 732ab42

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
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
@@ -146,6 +143,10 @@ internal ImportCompetenciesResult ProcessCompetenciesTable(IXLTable table, int a
146143
for (int p = 0; p < placesToMove; p++)
147144
{
148145
frameworkService.MoveFrameworkCompetencyGroup(thisGroup.ID, true, direction);
146+
competenciesRows
147+
.Where(row => row.CompetencyGroup == thisGroup.Name)
148+
.ToList()
149+
.ForEach(row => row.Reordered = true);
149150
}
150151
}
151152
}
@@ -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: 3 additions & 3 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,7 +60,7 @@
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">
6666
The sequence of @Model.FrameworkVocabularyPlural.ToLower() in the framework will be changed to reflect the order in the sheet during processing.

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)