Skip to content

Commit 697b272

Browse files
committed
Resolving post-rebase merge conflict problems
1 parent f5a2341 commit 697b272

File tree

4 files changed

+69
-77
lines changed

4 files changed

+69
-77
lines changed

DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ bool zeroBased
123123
//INSERT DATA
124124
BrandedFramework CreateFramework(DetailFramework detailFramework, int adminId);
125125

126-
int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId, int? frameworkId);
127126
int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId, int? frameworkId);
128127

129128
int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId);
@@ -285,7 +284,7 @@ public class FrameworkDataService : IFrameworkDataService
285284
fwr.ID AS FrameworkReviewID";
286285

287286
private const string BrandedFrameworkFields =
288-
@", FW.Description, (SELECT BrandName
287+
@",(SELECT BrandName
289288
FROM Brands
290289
WHERE (BrandID = FW.BrandID)) AS Brand,
291290
(SELECT CategoryName
@@ -476,7 +475,6 @@ public BrandedFramework CreateFramework(DetailFramework detailFramework, int adm
476475
return new BrandedFramework();
477476
}
478477

479-
var existingFrameworks = connection.QuerySingle<int>(
480478
var existingFrameworks = connection.QuerySingle<int>(
481479
@"SELECT COUNT(*) FROM Frameworks WHERE FrameworkName = @frameworkName",
482480
new { frameworkName }
@@ -550,7 +548,6 @@ int adminId
550548
return GetBrandedFrameworkByFrameworkId(frameworkId, adminId);
551549
}
552550

553-
public int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId, int? frameworkId)
554551
public int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId, int? frameworkId)
555552
{
556553
if ((groupName.Length == 0) | (adminId < 1))
@@ -583,26 +580,7 @@ OUTPUT INSERTED.Id
583580
VALUES (@groupName, @groupDescription, @adminId)",
584581
new { groupName, groupDescription, adminId }
585582
);
586-
if (numberOfAffectedRows < 1)
587-
{
588-
logger.LogWarning(
589-
"Not inserting competency group as db insert failed. " +
590-
$"Group name: {groupName}, admin id: {adminId}"
591-
);
592-
return -1;
593-
}
594583

595-
existingId = connection.QuerySingle<int>(
596-
@"SELECT COALESCE
597-
((SELECT TOP (1) ID
598-
FROM CompetencyGroups
599-
WHERE (Name = @groupName) AND EXISTS
600-
(SELECT 1 AS Expr1
601-
FROM FrameworkCompetencyGroups
602-
WHERE (CompetencyGroupID = CompetencyGroups.ID) AND (FrameworkID = @frameworkId) OR
603-
(CompetencyGroupID = CompetencyGroups.ID) AND (@frameworkId IS NULL))), 0) AS CompetencyGroupID",
604-
new { groupName, groupDescription }
605-
);
606584
return existingId;
607585
}
608586

@@ -616,7 +594,6 @@ public int InsertFrameworkCompetencyGroup(int groupId, int frameworkId, int admi
616594
return -2;
617595
}
618596

619-
var existingId = connection.QuerySingle<int>(
620597
var existingId = connection.QuerySingle<int>(
621598
@"SELECT COALESCE ((SELECT ID FROM FrameworkCompetencyGroups WHERE CompetencyGroupID = @groupID AND FrameworkID = @frameworkID), 0) AS FrameworkCompetencyGroupID",
622599
new { groupId, frameworkId }
@@ -635,19 +612,7 @@ FROM [FrameworkCompetencyGroups]
635612
WHERE ([FrameworkID] = @frameworkId)), 0)+1, @frameworkId)",
636613
new { groupId, adminId, frameworkId }
637614
);
638-
if (numberOfAffectedRows < 1)
639-
{
640-
logger.LogWarning(
641-
"Not inserting framework competency group as db insert failed. " +
642-
$"Group id: {groupId}, admin id: {adminId}, frameworkId: {frameworkId}"
643-
);
644-
return -1;
645-
}
646615

647-
existingId = connection.QuerySingle<int>(
648-
@"SELECT COALESCE ((SELECT ID FROM FrameworkCompetencyGroups WHERE CompetencyGroupID = @groupID AND FrameworkID = @frameworkID), 0) AS FrameworkCompetencyGroupID",
649-
new { groupId, frameworkId }
650-
);
651616
return existingId;
652617
}
653618

@@ -691,15 +656,13 @@ public int InsertFrameworkCompetency(
691656
var existingId = 0;
692657
if (frameworkCompetencyGroupID == null)
693658
{
694-
existingId = connection.QuerySingle<int>(
695659
existingId = connection.QuerySingle<int>(
696660
@"SELECT COALESCE ((SELECT ID FROM FrameworkCompetencies WHERE [CompetencyID] = @competencyId AND FrameworkCompetencyGroupID IS NULL), 0) AS FrameworkCompetencyID",
697661
new { competencyId, frameworkCompetencyGroupID }
698662
);
699663
}
700664
else
701665
{
702-
existingId = connection.QuerySingle<int>(
703666
existingId = connection.QuerySingle<int>(
704667
@"SELECT COALESCE ((SELECT ID FROM FrameworkCompetencies WHERE [CompetencyID] = @competencyId AND FrameworkCompetencyGroupID = @frameworkCompetencyGroupID), 0) AS FrameworkCompetencyID",
705668
new { competencyId, frameworkCompetencyGroupID }
@@ -729,15 +692,13 @@ FROM [FrameworkCompetencies]
729692

730693
if (frameworkCompetencyGroupID == null)
731694
{
732-
existingId = connection.QuerySingle<int>(
733695
existingId = connection.QuerySingle<int>(
734696
@"SELECT COALESCE ((SELECT ID FROM FrameworkCompetencies WHERE [CompetencyID] = @competencyId AND FrameworkCompetencyGroupID IS NULL), 0) AS FrameworkCompetencyID",
735697
new { competencyId, frameworkCompetencyGroupID }
736698
);
737699
}
738700
else
739701
{
740-
existingId = connection.QuerySingle<int>(
741702
existingId = connection.QuerySingle<int>(
742703
@"SELECT COALESCE ((SELECT ID FROM FrameworkCompetencies WHERE [CompetencyID] = @competencyId AND FrameworkCompetencyGroupID = @frameworkCompetencyGroupID), 0) AS FrameworkCompetencyID",
743704
new { competencyId, frameworkCompetencyGroupID }
@@ -789,7 +750,6 @@ public int AddCollaboratorToFramework(int frameworkId, string? userEmail, bool c
789750
return -3;
790751
}
791752

792-
var existingId = connection.QuerySingle<int>(
793753
var existingId = connection.QuerySingle<int>(
794754
@"SELECT COALESCE
795755
((SELECT ID
@@ -840,7 +800,6 @@ FROM FrameworkCollaborators
840800
);
841801
}
842802

843-
existingId = connection.QuerySingle<int>(
844803
existingId = connection.QuerySingle<int>(
845804
@"SELECT COALESCE
846805
((SELECT ID
@@ -1029,7 +988,6 @@ int adminId
1029988
return;
1030989
}
1031990

1032-
var usedElsewhere = connection.QuerySingle<int>(
1033991
var usedElsewhere = connection.QuerySingle<int>(
1034992
@"SELECT COUNT(*) FROM FrameworkCompetencyGroups
1035993
WHERE CompetencyGroupId = @competencyGroupId
@@ -1088,7 +1046,7 @@ public void UpdateFrameworkCompetency(int frameworkCompetencyId, string name, st
10881046
@"UPDATE Competencies SET Name = @name, Description = @description, UpdatedByAdminID = @adminId, AlwaysShowDescription = CASE WHEN @alwaysShowDescription IS NULL THEN AlwaysShowDescription ELSE @alwaysShowDescription END
10891047
FROM Competencies INNER JOIN FrameworkCompetencies AS fc ON Competencies.ID = fc.CompetencyID
10901048
WHERE (fc.Id = @frameworkCompetencyId)",
1091-
new { name, description, adminId, frameworkCompetencyId, alwaysShowDescription}
1049+
new { name, description, adminId, frameworkCompetencyId, alwaysShowDescription }
10921050
);
10931051
if (numberOfAffectedRows < 1)
10941052
{
@@ -1200,15 +1158,13 @@ public void DeleteFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int c
12001158
}
12011159

12021160
//Check if used elsewhere and delete competency group if not:
1203-
var usedElsewhere = connection.QuerySingle<int>(
12041161
var usedElsewhere = connection.QuerySingle<int>(
12051162
@"SELECT COUNT(*) FROM FrameworkCompetencyGroups
12061163
WHERE CompetencyGroupId = @competencyGroupId",
12071164
new { competencyGroupId }
12081165
);
12091166
if (usedElsewhere == 0)
12101167
{
1211-
usedElsewhere = connection.QuerySingle<int>(
12121168
usedElsewhere = connection.QuerySingle<int>(
12131169
@"SELECT COUNT(*) FROM SelfAssessmentStructure
12141170
WHERE CompetencyGroupId = @competencyGroupId",
@@ -1240,7 +1196,6 @@ public void DeleteFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int c
12401196

12411197
public void DeleteFrameworkCompetency(int frameworkCompetencyId, int adminId)
12421198
{
1243-
var competencyId = connection.QuerySingle<int>(
12441199
var competencyId = connection.QuerySingle<int>(
12451200
@"SELECT CompetencyID FROM FrameworkCompetencies WHERE ID = @frameworkCompetencyId",
12461201
new { frameworkCompetencyId }
@@ -1272,15 +1227,13 @@ public void DeleteFrameworkCompetency(int frameworkCompetencyId, int adminId)
12721227
}
12731228

12741229
//Check if used elsewhere and delete competency group if not:
1275-
var usedElsewhere = connection.QuerySingle<int>(
12761230
var usedElsewhere = connection.QuerySingle<int>(
12771231
@"SELECT COUNT(*) FROM FrameworkCompetencies
12781232
WHERE CompetencyID = @competencyId",
12791233
new { competencyId }
12801234
);
12811235
if (usedElsewhere == 0)
12821236
{
1283-
usedElsewhere = connection.QuerySingle<int>(
12841237
usedElsewhere = connection.QuerySingle<int>(
12851238
@"SELECT COUNT(*) FROM SelfAssessmentStructure
12861239
WHERE CompetencyID = @competencyId",
@@ -2221,15 +2174,15 @@ public void ArchiveReviewRequest(int reviewId)
22212174
FROM FrameworkCollaborators
22222175
WHERE (FrameworkID = FW.ID) AND (IsDeleted=0)))) AS MyFrameworksCount,
22232176
2224-
(SELECT COUNT(*) FROM SelfAssessments) AS CompetencyAssessmentCount,
2177+
(SELECT COUNT(*) FROM SelfAssessments) AS RoleProfileCount,
22252178
22262179
(SELECT COUNT(*) FROM SelfAssessments AS RP LEFT OUTER JOIN
22272180
SelfAssessmentCollaborators AS RPC ON RPC.SelfAssessmentID = RP.ID AND RPC.AdminID = @adminId
22282181
WHERE (RP.CreatedByAdminID = @adminId) OR
22292182
(@adminId IN
22302183
(SELECT AdminID
22312184
FROM SelfAssessmentCollaborators
2232-
WHERE (SelfAssessmentID = RP.ID)))) AS MyCompetencyAssessmentCount",
2185+
WHERE (SelfAssessmentID = RP.ID)))) AS MyRoleProfileCount",
22332186
new { adminId }
22342187
).FirstOrDefault();
22352188
}
@@ -2239,7 +2192,7 @@ public IEnumerable<DashboardToDoItem> GetDashboardToDoItems(int adminId)
22392192
return connection.Query<DashboardToDoItem>(
22402193
@"SELECT
22412194
FW.ID AS FrameworkID,
2242-
0 AS CompetencyAssessmentID,
2195+
0 AS RoleProfileID,
22432196
FW.FrameworkName AS ItemName,
22442197
AU.Forename + ' ' + AU.Surname + (CASE WHEN AU.Active = 1 THEN '' ELSE ' (Inactive)' END) AS RequestorName,
22452198
FWR.SignOffRequired,

DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public IActionResult AddAssessmentQuestions(AddAssessmentQuestionsFormData model
200200
public IActionResult AddQuestionsToWhichCompetencies()
201201
{
202202
var data = GetBulkUploadData();
203-
if (data.DefaultQuestionIDs.Count ==0 && data.CustomAssessmentQuestionID == null)
203+
if (data.DefaultQuestionIDs.Count == 0 && data.CustomAssessmentQuestionID == null)
204204
{
205205
return RedirectToAction("ImportSummary", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName });
206206
}
@@ -245,9 +245,23 @@ public IActionResult ImportSummarySubmit()
245245
var workbook = new XLWorkbook(filePath);
246246
var results = importCompetenciesFromFileService.ProcessCompetenciesFromFile(workbook, adminId, data.FrameworkId, data.FrameworkVocubulary, data.ReorderCompetenciesOption, data.AddAssessmentQuestionsOption, data.AddCustomAssessmentQuestion ? (int)data.CustomAssessmentQuestionID : 0, data.AddDefaultAssessmentQuestions ? data.DefaultQuestionIDs : []);
247247
data.ImportCompetenciesResult = results;
248+
//TO DO apply ordering changes if required:
249+
if (data.ReorderCompetenciesOption == 2 && data.CompetenciesToReorderCount > 0)
250+
{
251+
252+
}
248253
setBulkUploadData(data);
249254
return RedirectToAction("UploadResults", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName });
250255
}
256+
[Route("/Framework/{frameworkId}/{tabname}/Import/Results")]
257+
public IActionResult UploadResults()
258+
{
259+
var data = GetBulkUploadData();
260+
FileHelper.DeleteFile(webHostEnvironment, data.CompetenciesFileName);
261+
TempData.Clear();
262+
var model = new ImportCompetenciesResultsViewModel(data.ImportCompetenciesResult, data.FrameworkId, data.FrameworkName, data.FrameworkVocubulary);
263+
return View("Developer/Import/UploadResults", model);
264+
}
251265
[Route("CancelImport")]
252266
public IActionResult CancelImport()
253267
{

DigitalLearningSolutions.Web/Services/FrameworkService.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,12 @@ bool zeroBased
119119

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

122-
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool alwaysShowDescription = false);
123122
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool alwaysShowDescription = false);
124123

125124
IEnumerable<FrameworkCompetency> GetAllCompetenciesForAdminId(string name, int adminId);
126125

127126
int InsertCompetency(string name, string? description, int adminId);
128127

129-
int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId);
130128
int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId);
131129

132130
int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify, int? centreID);
@@ -675,7 +673,7 @@ public int UpdateCompetencyFlags(int frameworkId, int competencyId, int[] select
675673
}
676674

677675
public void UpdateFrameworkCompetency(int frameworkCompetencyId, string name, string? description, int adminId, bool? alwaysShowDescription)
678-
{
676+
{
679677
frameworkDataService.UpdateFrameworkCompetency(frameworkCompetencyId, name, description, adminId, alwaysShowDescription);
680678
}
681679

0 commit comments

Comments
 (0)