Skip to content

Commit 1483510

Browse files
committed
Merge branch 'DLS-Release-v1.2.1' into UAT
2 parents 6cb4689 + 7be11c2 commit 1483510

File tree

13 files changed

+162
-20
lines changed

13 files changed

+162
-20
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+

2+
3+
namespace DigitalLearningSolutions.Data.Migrations
4+
{
5+
using FluentMigrator;
6+
7+
[Migration(202504281045)]
8+
public class Alter_ReorderFrameworkCompetency : Migration
9+
{
10+
public override void Up()
11+
{
12+
Execute.Sql(Properties.Resources.TD_5447_Alter_ReorderFrameworkCompetency_Up);
13+
}
14+
public override void Down()
15+
{
16+
Execute.Sql(Properties.Resources.TD_5447_Alter_ReorderFrameworkCompetency_Down);
17+
}
18+
}
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
[Migration(202504281115)]
5+
public class UpdateFrameworkCompetenciesOrdering : ForwardOnlyMigration
6+
{
7+
public override void Up()
8+
{
9+
Execute.Sql(@"WITH Ranked AS (
10+
    SELECT ID,
11+
            ROW_NUMBER() OVER (PARTITION BY FrameworkID ORDER BY SysStartTime) AS NewOrder
12+
    FROM FrameworkCompetencies
13+
Where FrameworkCompetencyGroupID is null
14+
)
15+
UPDATE fc
16+
SET fc.Ordering = r.NewOrder
17+
FROM FrameworkCompetencies fc
18+
JOIN Ranked r ON fc.ID = r.ID;");
19+
}
20+
}
21+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
5+
[Migration(202504290900)]
6+
public class UpdateNotifications : ForwardOnlyMigration
7+
{
8+
public override void Up()
9+
{
10+
Execute.Sql(@$"UPDATE Notifications SET NotificationName = 'Completed course follow-up feedback requests' where NotificationID = 13");
11+
}
12+
13+
}
14+
}

DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,10 @@
481481
<data name="TD_5514_Alter_SendExpiredTBCReminders_Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
482482
<value>..\Scripts\TD-5514-Alter_SendExpiredTBCReminders_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
483483
</data>
484+
<data name="TD_5447_Alter_ReorderFrameworkCompetency_Down" type="System.Resources.ResXFileRef, System.Windows.Forms">
485+
<value>..\Scripts\TD-5447-Alter_ReorderFrameworkCompetency_Down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
486+
</data>
487+
<data name="TD_5447_Alter_ReorderFrameworkCompetency_Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
488+
<value>..\Scripts\TD-5447-Alter_ReorderFrameworkCompetency_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
489+
</data>
484490
</root>
Binary file not shown.

DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ string direction
252252
void RemoveCustomFlag(int flagId);
253253
void RemoveCollaboratorFromFramework(int frameworkId, int id);
254254

255-
void DeleteFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int competencyGroupId, int adminId);
255+
void DeleteFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int competencyGroupId, int frameworkId, int adminId);
256256

257-
void DeleteFrameworkCompetency(int frameworkCompetencyId, int adminId);
257+
void DeleteFrameworkCompetency(int frameworkCompetencyId, int? frameworkCompetencyGroupId, int frameworkId, int adminId);
258258

259259
void DeleteFrameworkDefaultQuestion(
260260
int frameworkId,
@@ -689,9 +689,11 @@ public int InsertFrameworkCompetency(
689689
var numberOfAffectedRows = connection.Execute(
690690
@"INSERT INTO FrameworkCompetencies ([CompetencyID], FrameworkCompetencyGroupID, UpdatedByAdminID, Ordering, FrameworkID)
691691
VALUES (@competencyId, @frameworkCompetencyGroupID, @adminId, COALESCE
692-
((SELECT MAX(Ordering) AS OrderNum
693-
FROM [FrameworkCompetencies]
694-
WHERE ([FrameworkCompetencyGroupID] = @frameworkCompetencyGroupID)), 0)+1, @frameworkId)",
692+
((SELECT MAX(Ordering) AS OrderNum
693+
FROM [FrameworkCompetencies]
694+
WHERE ((@frameworkCompetencyGroupID IS NULL AND FrameworkCompetencyGroupID IS NULL) OR
695+
(@frameworkCompetencyGroupID IS NOT NULL AND FrameworkCompetencyGroupID = @frameworkCompetencyGroupID)) AND
696+
FrameworkID = @frameworkId ), 0)+1, @frameworkId)",
695697
new { competencyId, frameworkCompetencyGroupID, adminId, frameworkId }
696698
);
697699
if (numberOfAffectedRows < 1)
@@ -1042,7 +1044,7 @@ int adminId
10421044
{
10431045
var numberOfAffectedRows = connection.Execute(
10441046
@"UPDATE CompetencyGroups SET Name = @name, UpdatedByAdminID = @adminId, Description = @description
1045-
WHERE ID = @competencyGroupId AND (Name <> @name OR Description <> @description)",
1047+
WHERE ID = @competencyGroupId AND (Name <> @name OR ISNULL(Description, '') <> ISNULL(@description, ''))",
10461048
new { name, adminId, competencyGroupId, description }
10471049
);
10481050
if (numberOfAffectedRows < 1)
@@ -1143,7 +1145,7 @@ public void MoveFrameworkCompetency(int frameworkCompetencyId, bool singleStep,
11431145
);
11441146
}
11451147

1146-
public void DeleteFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int competencyGroupId, int adminId)
1148+
public void DeleteFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int competencyGroupId, int frameworkId, int adminId)
11471149
{
11481150
if ((frameworkCompetencyGroupId < 1) | (adminId < 1))
11491151
{
@@ -1174,7 +1176,23 @@ public void DeleteFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int c
11741176
new { frameworkCompetencyGroupId }
11751177
);
11761178

1177-
if (numberOfAffectedRows < 1)
1179+
if (numberOfAffectedRows > 0)
1180+
{
1181+
connection.Execute(
1182+
@"WITH Ranked AS (
1183+
    SELECT ID,
1184+
            ROW_NUMBER() OVER (PARTITION BY FrameworkID ORDER BY Ordering) AS NewOrder
1185+
    FROM FrameworkCompetencyGroups
1186+
Where FrameworkID = @frameworkID
1187+
)
1188+
UPDATE fcg
1189+
SET fcg.Ordering = r.NewOrder
1190+
FROM FrameworkCompetencyGroups fcg
1191+
JOIN Ranked r ON fcg.ID = r.ID;",
1192+
new { frameworkId }
1193+
);
1194+
}
1195+
else
11781196
{
11791197
logger.LogWarning(
11801198
"Not deleting framework competency group as db update failed. " +
@@ -1219,7 +1237,7 @@ public void DeleteFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int c
12191237
}
12201238
}
12211239

1222-
public void DeleteFrameworkCompetency(int frameworkCompetencyId, int adminId)
1240+
public void DeleteFrameworkCompetency(int frameworkCompetencyId, int? frameworkCompetencyGroupId, int frameworkId, int adminId)
12231241
{
12241242
var competencyId = connection.QuerySingle<int>(
12251243
@"SELECT CompetencyID FROM FrameworkCompetencies WHERE ID = @frameworkCompetencyId",
@@ -1243,7 +1261,24 @@ public void DeleteFrameworkCompetency(int frameworkCompetencyId, int adminId)
12431261
@"DELETE FROM FrameworkCompetencies WHERE ID = @frameworkCompetencyId",
12441262
new { frameworkCompetencyId }
12451263
);
1246-
if (numberOfAffectedRows < 1)
1264+
if (numberOfAffectedRows > 0)
1265+
{
1266+
connection.Execute(
1267+
@"WITH Ranked AS (
1268+
    SELECT ID,
1269+
            ROW_NUMBER() OVER (PARTITION BY FrameworkID ORDER BY Ordering) AS NewOrder
1270+
    FROM FrameworkCompetencies
1271+
Where (FrameworkCompetencyGroupID = @frameworkCompetencyGroupID) OR (FrameworkCompetencyGroupID IS NULL AND @frameworkCompetencyGroupID IS NULL) AND
1272+
FrameworkID = @frameworkID
1273+
)
1274+
UPDATE fc
1275+
SET fc.Ordering = r.NewOrder
1276+
FROM FrameworkCompetencies fc
1277+
JOIN Ranked r ON fc.ID = r.ID;",
1278+
new { frameworkCompetencyGroupId, frameworkId }
1279+
);
1280+
}
1281+
else
12471282
{
12481283
logger.LogWarning(
12491284
"Not deleting framework competency as db update failed. " +

DigitalLearningSolutions.Web/Controllers/FrameworksController/Competencies.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public IActionResult DeleteFrameworkCompetencyGroup(int frameworkId, int compete
102102

103103
var adminId = GetAdminId();
104104

105-
frameworkService.DeleteFrameworkCompetencyGroup(frameworkCompetencyGroupId, competencyGroupId, adminId);
105+
frameworkService.DeleteFrameworkCompetencyGroup(frameworkCompetencyGroupId, competencyGroupId, frameworkId, adminId);
106106

107107
return new RedirectResult(Url.Action("ViewFramework", new { tabname = "Structure", frameworkId, frameworkCompetencyGroupId }));
108108
}
@@ -235,7 +235,7 @@ public IActionResult DeleteFrameworkCompetency(int frameworkId, int frameworkCom
235235
{
236236
var userRole = frameworkService.GetAdminUserRoleForFrameworkId(GetAdminId(), frameworkId);
237237
if (userRole < 2) return StatusCode(403);
238-
frameworkService.DeleteFrameworkCompetency(frameworkCompetencyId, GetAdminId());
238+
frameworkService.DeleteFrameworkCompetency(frameworkCompetencyId, frameworkCompetencyGroupId, frameworkId, GetAdminId());
239239
return frameworkCompetencyGroupId != null ? new RedirectResult(Url.Action("ViewFramework", new { tabname = "Structure", frameworkId, frameworkCompetencyGroupId }) + "#fcgroup-" + frameworkCompetencyGroupId.ToString()) : new RedirectResult(Url.Action("ViewFramework", new { tabname = "Structure", frameworkId }) + "#fc-ungrouped");
240240
}
241241
[Route("/Frameworks/{frameworkId}/Competency/{frameworkCompetencyGroupId:int=0}/{frameworkCompetencyId}/Preview/")]

DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ public IActionResult AddQuestionsToWhichCompetencies(int AddAssessmentQuestionsO
246246
[Route("/Framework/{frameworkId}/{tabname}/Import/Summary")]
247247
public IActionResult ImportSummary()
248248
{
249+
if (!TempData.Any()) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 410 });
249250
var data = GetBulkUploadData();
250251
var model = new ImportSummaryViewModel(data);
251252
return View("Developer/Import/ImportSummary", model);

0 commit comments

Comments
 (0)