Skip to content

Commit 4a48c0c

Browse files
committed
Resolving post-rebase merge conflict problems
1 parent 46b4f4d commit 4a48c0c

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);
@@ -286,7 +285,7 @@ public class FrameworkDataService : IFrameworkDataService
286285
fwr.ID AS FrameworkReviewID";
287286

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

480-
var existingFrameworks = connection.QuerySingle<int>(
481479
var existingFrameworks = connection.QuerySingle<int>(
482480
@"SELECT COUNT(*) FROM Frameworks WHERE FrameworkName = @frameworkName",
483481
new { frameworkName }
@@ -551,7 +549,6 @@ int adminId
551549
return GetBrandedFrameworkByFrameworkId(frameworkId, adminId);
552550
}
553551

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

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

@@ -617,7 +595,6 @@ public int InsertFrameworkCompetencyGroup(int groupId, int frameworkId, int admi
617595
return -2;
618596
}
619597

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

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

@@ -692,15 +657,13 @@ public int InsertFrameworkCompetency(
692657
var existingId = 0;
693658
if (frameworkCompetencyGroupID == null)
694659
{
695-
existingId = connection.QuerySingle<int>(
696660
existingId = connection.QuerySingle<int>(
697661
@"SELECT COALESCE ((SELECT ID FROM FrameworkCompetencies WHERE [CompetencyID] = @competencyId AND FrameworkCompetencyGroupID IS NULL), 0) AS FrameworkCompetencyID",
698662
new { competencyId, frameworkCompetencyGroupID }
699663
);
700664
}
701665
else
702666
{
703-
existingId = connection.QuerySingle<int>(
704667
existingId = connection.QuerySingle<int>(
705668
@"SELECT COALESCE ((SELECT ID FROM FrameworkCompetencies WHERE [CompetencyID] = @competencyId AND FrameworkCompetencyGroupID = @frameworkCompetencyGroupID), 0) AS FrameworkCompetencyID",
706669
new { competencyId, frameworkCompetencyGroupID }
@@ -730,15 +693,13 @@ FROM [FrameworkCompetencies]
730693

731694
if (frameworkCompetencyGroupID == null)
732695
{
733-
existingId = connection.QuerySingle<int>(
734696
existingId = connection.QuerySingle<int>(
735697
@"SELECT COALESCE ((SELECT ID FROM FrameworkCompetencies WHERE [CompetencyID] = @competencyId AND FrameworkCompetencyGroupID IS NULL), 0) AS FrameworkCompetencyID",
736698
new { competencyId, frameworkCompetencyGroupID }
737699
);
738700
}
739701
else
740702
{
741-
existingId = connection.QuerySingle<int>(
742703
existingId = connection.QuerySingle<int>(
743704
@"SELECT COALESCE ((SELECT ID FROM FrameworkCompetencies WHERE [CompetencyID] = @competencyId AND FrameworkCompetencyGroupID = @frameworkCompetencyGroupID), 0) AS FrameworkCompetencyID",
744705
new { competencyId, frameworkCompetencyGroupID }
@@ -790,7 +751,6 @@ public int AddCollaboratorToFramework(int frameworkId, string? userEmail, bool c
790751
return -3;
791752
}
792753

793-
var existingId = connection.QuerySingle<int>(
794754
var existingId = connection.QuerySingle<int>(
795755
@"SELECT COALESCE
796756
((SELECT ID
@@ -841,7 +801,6 @@ FROM FrameworkCollaborators
841801
);
842802
}
843803

844-
existingId = connection.QuerySingle<int>(
845804
existingId = connection.QuerySingle<int>(
846805
@"SELECT COALESCE
847806
((SELECT ID
@@ -1030,7 +989,6 @@ int adminId
1030989
return;
1031990
}
1032991

1033-
var usedElsewhere = connection.QuerySingle<int>(
1034992
var usedElsewhere = connection.QuerySingle<int>(
1035993
@"SELECT COUNT(*) FROM FrameworkCompetencyGroups
1036994
WHERE CompetencyGroupId = @competencyGroupId
@@ -1089,7 +1047,7 @@ public void UpdateFrameworkCompetency(int frameworkCompetencyId, string name, st
10891047
@"UPDATE Competencies SET Name = @name, Description = @description, UpdatedByAdminID = @adminId, AlwaysShowDescription = CASE WHEN @alwaysShowDescription IS NULL THEN AlwaysShowDescription ELSE @alwaysShowDescription END
10901048
FROM Competencies INNER JOIN FrameworkCompetencies AS fc ON Competencies.ID = fc.CompetencyID
10911049
WHERE (fc.Id = @frameworkCompetencyId)",
1092-
new { name, description, adminId, frameworkCompetencyId, alwaysShowDescription}
1050+
new { name, description, adminId, frameworkCompetencyId, alwaysShowDescription }
10931051
);
10941052
if (numberOfAffectedRows < 1)
10951053
{
@@ -1201,15 +1159,13 @@ public void DeleteFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int c
12011159
}
12021160

12031161
//Check if used elsewhere and delete competency group if not:
1204-
var usedElsewhere = connection.QuerySingle<int>(
12051162
var usedElsewhere = connection.QuerySingle<int>(
12061163
@"SELECT COUNT(*) FROM FrameworkCompetencyGroups
12071164
WHERE CompetencyGroupId = @competencyGroupId",
12081165
new { competencyGroupId }
12091166
);
12101167
if (usedElsewhere == 0)
12111168
{
1212-
usedElsewhere = connection.QuerySingle<int>(
12131169
usedElsewhere = connection.QuerySingle<int>(
12141170
@"SELECT COUNT(*) FROM SelfAssessmentStructure
12151171
WHERE CompetencyGroupId = @competencyGroupId",
@@ -1241,7 +1197,6 @@ public void DeleteFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int c
12411197

12421198
public void DeleteFrameworkCompetency(int frameworkCompetencyId, int adminId)
12431199
{
1244-
var competencyId = connection.QuerySingle<int>(
12451200
var competencyId = connection.QuerySingle<int>(
12461201
@"SELECT CompetencyID FROM FrameworkCompetencies WHERE ID = @frameworkCompetencyId",
12471202
new { frameworkCompetencyId }
@@ -1273,15 +1228,13 @@ public void DeleteFrameworkCompetency(int frameworkCompetencyId, int adminId)
12731228
}
12741229

12751230
//Check if used elsewhere and delete competency group if not:
1276-
var usedElsewhere = connection.QuerySingle<int>(
12771231
var usedElsewhere = connection.QuerySingle<int>(
12781232
@"SELECT COUNT(*) FROM FrameworkCompetencies
12791233
WHERE CompetencyID = @competencyId",
12801234
new { competencyId }
12811235
);
12821236
if (usedElsewhere == 0)
12831237
{
1284-
usedElsewhere = connection.QuerySingle<int>(
12851238
usedElsewhere = connection.QuerySingle<int>(
12861239
@"SELECT COUNT(*) FROM SelfAssessmentStructure
12871240
WHERE CompetencyID = @competencyId",
@@ -2222,15 +2175,15 @@ public void ArchiveReviewRequest(int reviewId)
22222175
FROM FrameworkCollaborators
22232176
WHERE (FrameworkID = FW.ID) AND (IsDeleted=0)))) AS MyFrameworksCount,
22242177
2225-
(SELECT COUNT(*) FROM SelfAssessments) AS CompetencyAssessmentCount,
2178+
(SELECT COUNT(*) FROM SelfAssessments) AS RoleProfileCount,
22262179
22272180
(SELECT COUNT(*) FROM SelfAssessments AS RP LEFT OUTER JOIN
22282181
SelfAssessmentCollaborators AS RPC ON RPC.SelfAssessmentID = RP.ID AND RPC.AdminID = @adminId
22292182
WHERE (RP.CreatedByAdminID = @adminId) OR
22302183
(@adminId IN
22312184
(SELECT AdminID
22322185
FROM SelfAssessmentCollaborators
2233-
WHERE (SelfAssessmentID = RP.ID)))) AS MyCompetencyAssessmentCount",
2186+
WHERE (SelfAssessmentID = RP.ID)))) AS MyRoleProfileCount",
22342187
new { adminId }
22352188
).FirstOrDefault();
22362189
}
@@ -2240,7 +2193,7 @@ public IEnumerable<DashboardToDoItem> GetDashboardToDoItems(int adminId)
22402193
return connection.Query<DashboardToDoItem>(
22412194
@"SELECT
22422195
FW.ID AS FrameworkID,
2243-
0 AS CompetencyAssessmentID,
2196+
0 AS RoleProfileID,
22442197
FW.FrameworkName AS ItemName,
22452198
AU.Forename + ' ' + AU.Surname + (CASE WHEN AU.Active = 1 THEN '' ELSE ' (Inactive)' END) AS RequestorName,
22462199
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);
@@ -676,7 +674,7 @@ public int UpdateCompetencyFlags(int frameworkId, int competencyId, int[] select
676674
}
677675

678676
public void UpdateFrameworkCompetency(int frameworkCompetencyId, string name, string? description, int adminId, bool? alwaysShowDescription)
679-
{
677+
{
680678
frameworkDataService.UpdateFrameworkCompetency(frameworkCompetencyId, name, description, adminId, alwaysShowDescription);
681679
}
682680

0 commit comments

Comments
 (0)