Skip to content

Commit d15446a

Browse files
Merge branch 'DLS-Release-v1.3.0' into Develop/Features/TD-5401-Managesupervisionsettings
2 parents 825f65a + 7c47791 commit d15446a

File tree

13 files changed

+878
-7
lines changed

13 files changed

+878
-7
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
5+
[Migration(202510221132)]
6+
public class AddIncludeLearnerDeclarationPromptToSelfAssessmentsTable : Migration
7+
{
8+
public override void Up()
9+
{
10+
Alter.Table("SelfAssessments").AddColumn("IncludeLearnerDeclarationPrompt").AsBoolean().WithDefaultValue(false);
11+
}
12+
13+
public override void Down()
14+
{
15+
Delete.Column("IncludeLearnerDeclarationPrompt").FromTable("SelfAssessments");
16+
}
17+
}
18+
}

DigitalLearningSolutions.Data/DataServices/CompetencyAssessmentDataService.cs

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ int categoryId
5959
bool UpdateOptionalCompetenciesTaskStatus(int assessmentId, bool taskStatus, bool? previousStatus);
6060
bool UpdateRoleRequirementsTaskStatus(int assessmentId, bool taskStatus, bool? previousStatus);
6161
bool UpdateWorkingGroupTaskStatus(int assessmentId, bool taskStatus, bool? previousStatus);
62+
bool UpdateCompetencyAssessmentOptions(
63+
bool includeLearnerDeclarationPrompt,
64+
bool includesSignposting,
65+
bool linearNavigation,
66+
bool useDescriptionExpanders,
67+
string? questionLabelText,
68+
string? reviewerCommentsLabelText,
69+
int competencyAssessmentId, int adminId);
70+
bool UpdateCompetencyAssessmentOptionsTaskStatus(int assessmentId, bool taskStatus);
6271
void MoveCompetencyInSelfAssessment(int competencyAssessmentId,
6372
int competencyId,
6473
string direction
@@ -93,6 +102,7 @@ bool UpdateSelfAssessments(int competencyAssessmentId,
93102
int AddCollaboratorToCompetencyAssessment(int competencyAssessmentId, string? userEmail, bool canModify, int? centreID);
94103
void RemoveCollaboratorFromCompetencyAssessment(int competencyAssessmentId, int id);
95104
CompetencyAssessmentCollaboratorNotification? GetCollaboratorNotification(int id, int invitedByAdminId);
105+
bool HasCompetencyWithSignpostedLearning(int competencyAssessmentId);
96106
}
97107

98108
public class CompetencyAssessmentDataService : ICompetencyAssessmentDataService
@@ -109,6 +119,8 @@ public class CompetencyAssessmentDataService : ICompetencyAssessmentDataService
109119
sa.SupervisorSelfAssessmentReview,
110120
sa.SignOffSupervisorStatement,
111121
sa.SignOffRequestorStatement";
122+
sa.IncludeLearnerDeclarationPrompt, sa.IncludesSignposting, sa.LinearNavigation, sa.UseDescriptionExpanders, sa.QuestionLabel, sa.ReviewerCommentsLabel,
123+
sa.SupervisorSelfAssessmentReview, sa.SupervisorResultsReview ";
112124

113125
private const string SelfAssessmentFields =
114126
@", sa.CategoryID, sa.CreatedDate,
@@ -390,7 +402,7 @@ WHERE NOT EXISTS (SELECT 1 FROM SelfAssessmentFrameworks WHERE SelfAssessmentId
390402
{
391403
numberOfAffectedRows = connection.Execute(
392404
@"UPDATE SelfAssessmentFrameworks
393-
SET RemovedDate = NULL, RemovedByAdminId = NULL, AmendedByAdminId = @adminId
405+
SET RemovedDate = NULL, RemovedByAdminId = NULL, AmendedByAdminId = @adminId, IsPrimary = 0
394406
WHERE SelfAssessmentId = @selfAssessmentId AND FrameworkId = @frameworkId"
395407
,
396408
new { adminId, selfAssessmentId, frameworkId }
@@ -1136,6 +1148,80 @@ UPDATE SelfAssessments
11361148
$"competencyAssessmentId: {competencyAssessmentId}, supervised: {supervised}" +
11371149
$"signoff: {signoff}, confirm: {confirm}, supervisorDeclarationValue: {supervisorDeclarationValue} " +
11381150
$"supervisorCustomText: {supervisorCustomText}, leanerDeclarationValue: {leanerDeclarationValue}, leanerCustomText: {leanerCustomText} "
1151+
1152+
public bool HasCompetencyWithSignpostedLearning(int competencyAssessmentId)
1153+
{
1154+
int hasSignpostedLearning = connection.QueryFirstOrDefault<int>(
1155+
@"SELECT count(*) FROM SelfAssessmentStructure sas INNER JOIN
1156+
CompetencyLearningResources clr ON sas.CompetencyID = clr.CompetencyID AND
1157+
clr.RemovedDate IS NULL
1158+
WHERE sas.SelfAssessmentID = @competencyAssessmentId",
1159+
new { competencyAssessmentId });
1160+
1161+
return hasSignpostedLearning > 0;
1162+
}
1163+
public bool UpdateCompetencyAssessmentOptions(
1164+
bool includeLearnerDeclarationPrompt,
1165+
bool includesSignposting,
1166+
bool linearNavigation,
1167+
bool useDescriptionExpanders,
1168+
string? questionLabelText,
1169+
string? reviewerCommentsLabelText,
1170+
int competencyAssessmentId, int adminId)
1171+
{
1172+
if ((adminId < 1) | (competencyAssessmentId < 1))
1173+
{
1174+
logger.LogWarning(
1175+
$"Not updating role profile name as it failed server side validation. AdminId: {adminId}, competencyAssessmentId: {competencyAssessmentId}"
1176+
);
1177+
return false;
1178+
}
1179+
1180+
var numberOfAffectedRows = connection.Execute(
1181+
@"UPDATE SelfAssessments SET IncludeLearnerDeclarationPrompt = @includeLearnerDeclarationPrompt,
1182+
IncludesSignposting = @includesSignposting,
1183+
LinearNavigation = @linearNavigation,
1184+
UseDescriptionExpanders = @useDescriptionExpanders,
1185+
QuestionLabel = @questionLabelText,
1186+
ReviewerCommentsLabel = @reviewerCommentsLabelText,
1187+
UpdatedByAdminID = @adminId
1188+
WHERE ID = @competencyAssessmentId ",
1189+
new
1190+
{
1191+
includeLearnerDeclarationPrompt,
1192+
includesSignposting,
1193+
linearNavigation,
1194+
useDescriptionExpanders,
1195+
questionLabelText,
1196+
reviewerCommentsLabelText,
1197+
adminId,
1198+
competencyAssessmentId
1199+
}
1200+
);
1201+
if (numberOfAffectedRows < 1)
1202+
{
1203+
logger.LogWarning(
1204+
"Not updating options/labels as db update failed. " +
1205+
$"admin id: {adminId}, competencyAssessmentId: {competencyAssessmentId}"
1206+
);
1207+
return false;
1208+
}
1209+
1210+
return true;
1211+
}
1212+
1213+
public bool UpdateCompetencyAssessmentOptionsTaskStatus(int assessmentId, bool taskStatus)
1214+
{
1215+
var numberOfAffectedRows = connection.Execute(
1216+
@"UPDATE SelfAssessmentTaskStatus SET SelfAssessmentOptionsTaskStatus = @taskStatus
1217+
WHERE SelfAssessmentId = @assessmentId",
1218+
new { assessmentId, taskStatus }
1219+
);
1220+
if (numberOfAffectedRows < 1)
1221+
{
1222+
logger.LogWarning(
1223+
"Not updating SelfAssessmentOptionsTaskStatus as db update failed. " +
1224+
$"assessmentId: {assessmentId}, taskStatus: {taskStatus}"
11391225
);
11401226
return false;
11411227
}

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ FROM SelfAssessmentSupervisorRoles AS SelfAssessmentSupervisorRoles_1
223223
SA.ManageSupervisorsDescription,
224224
CA.NonReportable,
225225
U.FirstName +' '+ U.LastName AS DelegateName,
226-
SA.MinimumOptionalCompetencies
226+
SA.MinimumOptionalCompetencies,
227+
SA.IncludeLearnerDeclarationPrompt
227228
FROM CandidateAssessments CA
228229
JOIN SelfAssessments SA
229230
ON CA.SelfAssessmentID = SA.ID
@@ -248,7 +249,7 @@ GROUP BY
248249
CA.LaunchCount, CA.SubmittedDate, SA.LinearNavigation, SA.UseDescriptionExpanders,
249250
SA.ManageOptionalCompetenciesPrompt, SA.SupervisorSelfAssessmentReview, SA.SupervisorResultsReview,
250251
SA.ReviewerCommentsLabel,SA.EnforceRoleRequirementsForSignOff, SA.ManageSupervisorsDescription,CA.NonReportable,
251-
U.FirstName , U.LastName,SA.MinimumOptionalCompetencies, CA.SelfAssessmentProcessAgreed",
252+
U.FirstName , U.LastName,SA.MinimumOptionalCompetencies, CA.SelfAssessmentProcessAgreed, SA.IncludeLearnerDeclarationPrompt",
252253
new { delegateUserId, selfAssessmentId }
253254
);
254255
}

DigitalLearningSolutions.Data/Models/CompetencyAssessments/CompetencyAssessmentBase.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ public class CompetencyAssessmentBase
2424
public string? SignOffRequestorStatement { get; set; }
2525
public string? SignOffSupervisorStatement { get; set; }
2626
public string? Vocabulary { get; set; }
27+
public bool IncludeLearnerDeclarationPrompt { get; set; }
28+
public bool IncludesSignposting { get; set; }
29+
public bool LinearNavigation { get; set; }
30+
public bool UseDescriptionExpanders { get; set; }
31+
public string? QuestionLabel { get; set; }
32+
public string? ReviewerCommentsLabel { get; set; }
33+
public bool SupervisorSelfAssessmentReview { get; set; }
34+
public bool SupervisorResultsReview { get; set; }
2735
}
2836
}
2937

DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessment.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class SelfAssessment : CurrentLearningItem
1717

1818
public DateTime? EnrolmentCutoffDate { get; set; }
1919
public string? RetirementReason { get; set; }
20+
public bool IncludeLearnerDeclarationPrompt { get; set; }
2021

2122
}
2223
}

DigitalLearningSolutions.Web.Tests/TestHelpers/SelfAssessmentTestHelper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public static CurrentSelfAssessment CreateDefaultSelfAssessment(
2727
bool useDescriptionExpanders = true,
2828
string vocabulary = "Capability",
2929
string verificationRoleName = "Supervisor",
30-
string signOffRoleName = "Supervisor"
30+
string signOffRoleName = "Supervisor",
31+
bool includeLearnerDeclarationPrompt = true
3132
)
3233
{
3334
return new CurrentSelfAssessment
@@ -47,6 +48,7 @@ public static CurrentSelfAssessment CreateDefaultSelfAssessment(
4748
Vocabulary = vocabulary,
4849
VerificationRoleName = verificationRoleName,
4950
SignOffRoleName = signOffRoleName,
51+
IncludeLearnerDeclarationPrompt = includeLearnerDeclarationPrompt
5052
};
5153
}
5254

0 commit comments

Comments
 (0)