Skip to content

Commit 877288e

Browse files
authored
Merge pull request #3200 from TechnologyEnhancedLearning/Develop/Fixes/TD-5155-FixTestingFails
TD-5155 fix testing fails
2 parents c19d90a + 066f0bf commit 877288e

File tree

7 files changed

+28
-30
lines changed

7 files changed

+28
-30
lines changed

DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ bool zeroBased
130130

131131
IEnumerable<FrameworkCompetency> GetAllCompetenciesForAdminId(string name, int adminId);
132132

133-
int InsertCompetency(string name, string? description, int adminId);
133+
int InsertCompetency(string name, string? description, int adminId, bool alwaysShowDescription = false);
134134

135-
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool alwaysShowDescription = false);
135+
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool addDefaultQuestions = true);
136136

137137
int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify, int? centreID);
138138

@@ -618,7 +618,7 @@ FROM [FrameworkCompetencyGroups]
618618
return existingId;
619619
}
620620

621-
public int InsertCompetency(string name, string? description, int adminId)
621+
public int InsertCompetency(string name, string? description, int adminId, bool alwaysShowDescription = false)
622622
{
623623
if ((name.Length == 0) | (adminId < 1))
624624
{
@@ -630,10 +630,10 @@ public int InsertCompetency(string name, string? description, int adminId)
630630
description = (description?.Trim() == "" ? null : description);
631631

632632
var existingId = connection.QuerySingle<int>(
633-
@"INSERT INTO Competencies ([Name], [Description], UpdatedByAdminID)
633+
@"INSERT INTO Competencies ([Name], [Description], UpdatedByAdminID, AlwaysShowDescription)
634634
OUTPUT INSERTED.Id
635-
VALUES (@name, @description, @adminId)",
636-
new { name, description, adminId }
635+
VALUES (@name, @description, @adminId, @alwaysShowDescription)",
636+
new { name, description, adminId, alwaysShowDescription }
637637
);
638638

639639
return existingId;
@@ -644,7 +644,7 @@ public int InsertFrameworkCompetency(
644644
int? frameworkCompetencyGroupID,
645645
int adminId,
646646
int frameworkId,
647-
bool alwaysShowDescription = false
647+
bool addDefaultQuestions = true
648648
)
649649
{
650650
if ((competencyId < 1) | (adminId < 1) | (frameworkId < 1))
@@ -706,8 +706,10 @@ FROM [FrameworkCompetencies]
706706
new { competencyId, frameworkCompetencyGroupID }
707707
);
708708
}
709-
710-
AddDefaultQuestionsToCompetency(competencyId, frameworkId);
709+
if(addDefaultQuestions)
710+
{
711+
AddDefaultQuestionsToCompetency(competencyId, frameworkId);
712+
}
711713
return existingId;
712714
}
713715

DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,16 @@ public IActionResult AddAssessmentQuestions()
181181
public IActionResult AddAssessmentQuestions(AddAssessmentQuestionsFormData model)
182182
{
183183
var data = GetBulkUploadData();
184-
data.AddDefaultAssessmentQuestions = model.AddDefaultAssessmentQuestions;
184+
185185
if (model.AddDefaultAssessmentQuestions)
186186
{
187-
data.DefaultQuestionIDs = model.DefaultAssessmentQuestionIDs;
187+
data.DefaultQuestionIDs = model.DefaultAssessmentQuestionIDs ?? [];
188188
}
189189
else
190190
{
191191
data.DefaultQuestionIDs = [];
192192
}
193+
data.AddDefaultAssessmentQuestions = (data.DefaultQuestionIDs.Count > 0 && model.AddDefaultAssessmentQuestions);
193194
data.AddCustomAssessmentQuestion = model.AddCustomAssessmentQuestion;
194195
if (model.AddCustomAssessmentQuestion)
195196
{
@@ -199,9 +200,8 @@ public IActionResult AddAssessmentQuestions(AddAssessmentQuestionsFormData model
199200
{
200201
data.CustomAssessmentQuestionID = null;
201202
}
202-
if (data.CompetenciesToUpdateCount > 0)
203+
if (data.CompetenciesToUpdateCount > 0 && (data.DefaultQuestionIDs.Count + (data.CustomAssessmentQuestionID != null ? 1 : 0) > 0))
203204
{
204-
data.AddAssessmentQuestionsOption = 2;
205205
setBulkUploadData(data);
206206
return RedirectToAction("AddQuestionsToWhichCompetencies", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName });
207207
}
@@ -261,11 +261,6 @@ public IActionResult ImportSummarySubmit()
261261
var workbook = new XLWorkbook(filePath);
262262
var results = importCompetenciesFromFileService.ProcessCompetenciesFromFile(workbook, adminId, data.FrameworkId, data.FrameworkVocubulary, data.ReorderCompetenciesOption, data.AddAssessmentQuestionsOption, data.AddCustomAssessmentQuestion ? (int)data.CustomAssessmentQuestionID : 0, data.AddDefaultAssessmentQuestions ? data.DefaultQuestionIDs : []);
263263
data.ImportCompetenciesResult = results;
264-
//TO DO apply ordering changes if required:
265-
if (data.ReorderCompetenciesOption == 2 && data.CompetenciesToReorderCount > 0)
266-
{
267-
268-
}
269264
setBulkUploadData(data);
270265
return RedirectToAction("UploadResults", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName });
271266
}

DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public BulkCompetenciesData(DetailFramework framework, int adminUserId, string c
3232
public bool AddCustomAssessmentQuestion { get; set; } = false;
3333
public List<int> DefaultQuestionIDs { get; set; } = [];
3434
public int? CustomAssessmentQuestionID { get; set; }
35-
public int AddAssessmentQuestionsOption { get; set; } = 1; //1 = only added, 2 = added and updated, 3 = all uploaded
35+
public int AddAssessmentQuestionsOption { get; set; } = 2; //1 = only added, 2 = added and updated, 3 = all uploaded
3636
public int CompetenciesToProcessCount { get; set; }
3737
public int CompetenciesToAddCount { get; set; }
3838
public int CompetenciesToUpdateCount { get; set; }

DigitalLearningSolutions.Web/Services/FrameworkService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ bool zeroBased
120120

121121
int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId, int? frameworkId = null);
122122

123-
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool alwaysShowDescription = false);
123+
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool addDefaultQuestions = true);
124124

125125
IEnumerable<FrameworkCompetency> GetAllCompetenciesForAdminId(string name, int adminId);
126126

127-
int InsertCompetency(string name, string? description, int adminId);
127+
int InsertCompetency(string name, string? description, int adminId, bool alwaysShowDescription = false);
128128

129129
int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId);
130130

@@ -594,19 +594,19 @@ public int InsertComment(int frameworkId, int adminId, string comment, int? repl
594594
return frameworkDataService.InsertComment(frameworkId, adminId, comment, replyToCommentId);
595595
}
596596

597-
public int InsertCompetency(string name, string? description, int adminId)
597+
public int InsertCompetency(string name, string? description, int adminId, bool alwaysShowDescription = false)
598598
{
599-
return frameworkDataService.InsertCompetency(name, description, adminId);
599+
return frameworkDataService.InsertCompetency(name, description, adminId, alwaysShowDescription);
600600
}
601601

602602
public int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId, int? frameworkId)
603603
{
604604
return frameworkDataService.InsertCompetencyGroup(groupName, groupDescription, adminId, frameworkId);
605605
}
606606

607-
public int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool alwaysShowDescription = false)
607+
public int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool addDefaultQuestions = true)
608608
{
609-
return frameworkDataService.InsertFrameworkCompetency(competencyId, frameworkCompetencyGroupID, adminId, frameworkId, alwaysShowDescription);
609+
return frameworkDataService.InsertFrameworkCompetency(competencyId, frameworkCompetencyGroupID, adminId, frameworkId, addDefaultQuestions);
610610
}
611611

612612
public int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId)

DigitalLearningSolutions.Web/Services/ImportCompetenciesFromFileService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ CompetencyTableRow competencyRow
211211
else
212212
{
213213
//Check if competency already exists in framework competency group and add if not
214-
newCompetencyId = frameworkService.InsertCompetency(competencyRow.Competency, competencyRow.CompetencyDescription, adminId);
214+
newCompetencyId = frameworkService.InsertCompetency(competencyRow.Competency, competencyRow.CompetencyDescription, adminId, competencyRow.AlwaysShowDescription ?? false);
215215
if (newCompetencyId > 0)
216216
{
217-
newFrameworkCompetencyId = frameworkService.InsertFrameworkCompetency(newCompetencyId, frameworkCompetencyGroupId, adminId, frameworkId, competencyRow.AlwaysShowDescription ?? false); //including always show desc flag
217+
newFrameworkCompetencyId = frameworkService.InsertFrameworkCompetency(newCompetencyId, frameworkCompetencyGroupId, adminId, frameworkId, false);
218218
if (newFrameworkCompetencyId > maxFrameworkCompetencyId)
219219
{
220220
competencyRow.RowStatus = (competencyRow.RowStatus == RowStatus.CompetencyGroupInserted ? RowStatus.CompetencyGroupAndCompetencyInserted : RowStatus.CompetencyInserted);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using DigitalLearningSolutions.Web.Helpers;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Runtime.Versioning;
45

56
namespace DigitalLearningSolutions.Web.ViewModels.Frameworks.Import

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
@if (Model.CompetenciesToAddCount > 0)
4848
{
4949
<div class="nhsuk-radios__item">
50-
<input class="nhsuk-radios__input" id="option-1" asp-for="@Model.AddAssessmentQuestionsOption" type="radio" value="1" aria-describedby="option-1-hint">
50+
<input class="nhsuk-radios__input" id="option-1" asp-for="AddAssessmentQuestionsOption" type="radio" value="1" aria-describedby="option-1-hint">
5151
<label class="nhsuk-label nhsuk-radios__label" for="option-1">
5252
Only add questions to new @Model.FrameworkVocabularyPlural.ToLower()
5353
</label>
@@ -57,7 +57,7 @@
5757
</div>
5858
}
5959
<div class="nhsuk-radios__item">
60-
<input class="nhsuk-radios__input" id="option-2" asp-for="@Model.AddAssessmentQuestionsOption" type="radio" value="2" aria-describedby="option-2-hint">
60+
<input class="nhsuk-radios__input" id="option-2" asp-for="AddAssessmentQuestionsOption" type="radio" value="2" aria-describedby="option-2-hint">
6161
<label class="nhsuk-label nhsuk-radios__label" for="option-2">
6262
Only add questions to @(Model.CompetenciesToAddCount > 0 ? " new and " : "") modified @Model.FrameworkVocabularyPlural.ToLower()
6363
</label>
@@ -66,7 +66,7 @@
6666
</div>
6767
</div>
6868
<div class="nhsuk-radios__item">
69-
<input class="nhsuk-radios__input" id="option-3" asp-for="@Model.AddAssessmentQuestionsOption" type="radio" value="3" aria-describedby="option-3-hint">
69+
<input class="nhsuk-radios__input" id="option-3" asp-for="AddAssessmentQuestionsOption" type="radio" value="3" aria-describedby="option-3-hint">
7070
<label class="nhsuk-label nhsuk-radios__label" for="option-3">
7171
Add questions to all @Model.FrameworkVocabularyPlural.ToLower() in my uploaded sheet
7272
</label>

0 commit comments

Comments
 (0)