Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5b5f099
444 Set up add/edit signposting parameters flow and choose assessment…
daniel-manta-hee Dec 26, 2021
0e60f2e
445 Signposting parameters choose trigger range/choose trigger option…
daniel-manta-hee Dec 27, 2021
dec5bf3
DLSV2-445 Signposting parameters slider to break dependencies on lear…
daniel-manta-hee Dec 28, 2021
fddb2dc
DLSV2-445 Signposting parameters checkbox questions, fixing bugs, etc
daniel-manta-hee Dec 28, 2021
395c5a6
DLSV2-444 Signposting parameters fixes problem with Back button, navi…
daniel-manta-hee Dec 28, 2021
f52641e
DLSV2-446 Signposting parameters Compare result view (,mock)
daniel-manta-hee Dec 29, 2021
1daa2ed
DLSV2-445 Removed BOM characters from ts file
daniel-manta-hee Dec 29, 2021
5e088f1
DLSV2-462 Load data for Manage competency resource signposting view f…
daniel-manta-hee Dec 29, 2021
7333beb
DLSV2-462 Removed unnecessary join as foreign keys can be used instead
daniel-manta-hee Dec 29, 2021
ed9c59b
DLSV2-446 Signposting parameters Compare result view
daniel-manta-hee Dec 30, 2021
e8797c0
DLSV2-443 Fixes problem with breadcrumbs missing after sections moved…
daniel-manta-hee Dec 30, 2021
608cfa1
DLSV2-443 Replaced Back buttons for links and fixing routing, retriev…
daniel-manta-hee Dec 31, 2021
2af83ea
DLSV2-445 Signposting parameters slider and checkboxes: when navigati…
daniel-manta-hee Dec 31, 2021
2fdf394
DLSV2-444 Use nhs validation component for making mandatory to choose…
daniel-manta-hee Dec 31, 2021
e11b4aa
DLSV2-447 and DLSV2-448, including user interface and logics for sett…
daniel-manta-hee Jan 5, 2022
ddb49d4
Merge remote-tracking branch 'origin/master' into Develop/Features/DL…
daniel-manta-hee Jan 5, 2022
3290009
DLSV2-443 Merge from master and changes for supporting database migra…
daniel-manta-hee Jan 5, 2022
b25749e
DLSV2-443 Implement friendly urls in all stages of the signposting pa…
daniel-manta-hee Jan 6, 2022
c8d3425
DLSV2-443 Allows to manage or add new resource parameters from user i…
daniel-manta-hee Jan 7, 2022
1df8dea
DLSV2-443 Fixing bugs and supporting all requirements for comparing s…
daniel-manta-hee Jan 10, 2022
76bcb20
Merge remote-tracking branch 'origin/master' into Develop/Features/DL…
daniel-manta-hee Jan 10, 2022
cddb71b
DLSV2-443 Changed summary page so it displays level descriptor labels…
daniel-manta-hee Jan 11, 2022
dd261fe
DLSV2-443 Minor changes
daniel-manta-hee Jan 11, 2022
df50feb
DLSV2-443 Fixes problem with url routing
daniel-manta-hee Jan 12, 2022
b42b530
DLSV2-443 Fixes bug, passing framework competency id where competency…
daniel-manta-hee Jan 12, 2022
5371ce3
DLSV2-443 Fixes wrong parameter value on link, although the link shou…
daniel-manta-hee Jan 12, 2022
d1c7ce7
DLSV2-443 Manage different scenarios from zero to one or more questio…
daniel-manta-hee Jan 13, 2022
fe701a0
DLSV2-443 Amendments requested in code review for pull request 850.
daniel-manta-hee Jan 13, 2022
f1c1392
Fixes to typos in CompareSelfAssessmentResult.cshtml
kevwhitt-hee Jan 14, 2022
1570df6
Tweaks label of status to "Optional/Recommended"
kevwhitt-hee Jan 14, 2022
9abd11f
Tweak to hint text in SignpostingParametersSetTriggerValues.cshtml
kevwhitt-hee Jan 14, 2022
883e3dc
Tweaks radio option label to make consistent
kevwhitt-hee Jan 14, 2022
8b9c85b
DLSV2-443 Merged from master
daniel-manta-hee Jan 14, 2022
e8bb366
Merge branch 'Develop/Features/DLSV2-443-SignpostingParametersFlow' o…
daniel-manta-hee Jan 14, 2022
ef17b21
DLSV2 Bug fixing
daniel-manta-hee Jan 14, 2022
94947a7
DLSV2 Fixes problem with assessment question id not mandatory in para…
daniel-manta-hee Jan 14, 2022
5f80eea
DLSV2 When no role requirements are found for a question and user cli…
daniel-manta-hee Jan 14, 2022
fa7dcc4
Merge branch 'Develop/Features/DLSV2-443-SignpostingParametersFlow' o…
daniel-manta-hee Jan 17, 2022
3a096ed
DLSV2-443 If compare to is set to role requirements or don't compare,…
daniel-manta-hee Jan 17, 2022
242e0d2
DLSV2-443 Bug fixing and changed the way redirection is done dependin…
daniel-manta-hee Jan 18, 2022
77fe24c
Tweak to summary title on card
kevwhitt-hee Jan 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace DigitalLearningSolutions.Data.Migrations
{
using FluentMigrator;
[Migration(202201121604)]
public class _202201121604_AllowNullAssessmentQuestionIdOnTableCompetencyResourceAssessmentQuestionParameters : Migration
{
public override void Up()
{
Alter.Column("AssessmentQuestionID")
.OnTable("CompetencyResourceAssessmentQuestionParameters")
.AsInt32()
.Nullable();
}
public override void Down()
{
Delete.FromTable("CompetencyResourceAssessmentQuestionParameters")
.Row(new { AssessmentQuestionID = (int?)null });

Alter.Column("AssessmentQuestionID")
.OnTable("CompetencyResourceAssessmentQuestionParameters")
.AsInt32()
.NotNullable();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,8 @@ public interface ICompetencyLearningResourcesDataService

IEnumerable<CompetencyLearningResource> GetCompetencyLearningResourcesByCompetencyId(int competencyId);

void AddCompetencyLearningResource(
int resourceRefId,
string originalResourceName,
int competencyId,
int adminId
);

IEnumerable<CompetencyResourceAssessmentQuestionParameter> GetCompetencyResourceAssessmentQuestionParameters(
IEnumerable<int> competencyLearningResourceIds
);
IEnumerable<CompetencyResourceAssessmentQuestionParameter> GetCompetencyResourceAssessmentQuestionParameters(IEnumerable<int> competencyLearningResourceIds);
int AddCompetencyLearningResource(int resourceRefID, string originalResourceName, int competencyID, int adminId);
}

public class CompetencyLearningResourcesDataService : ICompetencyLearningResourcesDataService
Expand Down Expand Up @@ -60,15 +52,10 @@ FROM CompetencyLearningResources AS clr
);
}

public void AddCompetencyLearningResource(
int resourceRefId,
string originalResourceName,
int competencyId,
int adminId
)
public int AddCompetencyLearningResource(int resourceRefID, string originalResourceName, int competencyID, int adminId)
{
connection.Execute(
@" DECLARE @learningResourceReferenceID int
return connection.ExecuteScalar<int>(
@$" DECLARE @learningResourceReferenceID int
IF NOT EXISTS(SELECT * FROM LearningResourceReferences WHERE @resourceRefID = resourceRefID)
BEGIN
INSERT INTO LearningResourceReferences(ResourceRefID, OriginalResourceName, AdminID, Added)
Expand All @@ -82,13 +69,13 @@ FROM LearningResourceReferences
WHERE @resourceRefID = resourceRefID
END
INSERT INTO CompetencyLearningResources(CompetencyID, LearningResourceReferenceID, AdminID)
VALUES (@competencyID, @learningResourceReferenceID, @adminID)",
new { resourceRefID = resourceRefId, originalResourceName, competencyID = competencyId, adminId }
VALUES (@competencyID, @learningResourceReferenceID, @adminID)
SELECT SCOPE_IDENTITY() AS CompetencyLearningResourceId",
new { resourceRefID, originalResourceName, competencyID, adminId }
);
}

public IEnumerable<CompetencyResourceAssessmentQuestionParameter>
GetCompetencyResourceAssessmentQuestionParameters(IEnumerable<int> competencyLearningResourceIds)
public IEnumerable<CompetencyResourceAssessmentQuestionParameter>GetCompetencyResourceAssessmentQuestionParameters(IEnumerable<int> competencyLearningResourceIds)
{
return connection.Query<CompetencyResourceAssessmentQuestionParameter>(
@"SELECT
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace DigitalLearningSolutions.Data.Models.Frameworks
{
public class CompetencyResourceAssessmentQuestionParameter
{
public int? AssessmentQuestionId { get; set; }
public int CompetencyLearningResourceId { get; set; }
public int MinResultMatch { get; set; }
public int MaxResultMatch { get; set; }
public bool Essential { get; set; }
public int? RelevanceAssessmentQuestionId { get; set; }
public bool CompareToRoleRequirements { get; set; }
public string OriginalResourceName { get; set; }
public string Question { get; set; }
public string CompareResultTo { get; set; }
public AssessmentQuestion AssessmentQuestion { get; set; }
public AssessmentQuestion RelevanceAssessmentQuestion { get; set; }
public bool IsNew { get; set; }

public CompetencyResourceAssessmentQuestionParameter(bool isNew)
{
this.IsNew = isNew;
}
public CompetencyResourceAssessmentQuestionParameter()
{

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace DigitalLearningSolutions.Data.Models.Frameworks
{
public class LearningResourceReference
{
public int Id { get; set; }
public int ResourceRefID { get; set; }
public string OriginalResourceName { get; set; }
public int AdminID { get; set; }
public DateTime Added { get; set; }
}
}
110 changes: 110 additions & 0 deletions DigitalLearningSolutions.Data/Services/FrameworkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using DigitalLearningSolutions.Data.Models.Common;
using Microsoft.Extensions.Logging;
using DigitalLearningSolutions.Data.Models.Email;
using System;

public interface IFrameworkService
{
Expand Down Expand Up @@ -65,8 +66,12 @@ public interface IFrameworkService
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId);
int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify);
void AddFrameworkDefaultQuestion(int frameworkId, int assessmentQuestionId, int adminId, bool addToExisting);
CompetencyResourceAssessmentQuestionParameter? GetCompetencyResourceAssessmentQuestionParameterByCompetencyLearningResourceId(int competencyResourceAssessmentQuestionParameterId);
LearningResourceReference GetLearningResourceReferenceByCompetencyLearningResouceId(int competencyLearningResourceID);
int EditCompetencyResourceAssessmentQuestionParameter(CompetencyResourceAssessmentQuestionParameter parameter);
void AddCompetencyAssessmentQuestion(int frameworkCompetencyId, int assessmentQuestionId, int adminId);
int InsertAssessmentQuestion(string question, int assessmentQuestionInputTypeId, string? maxValueDescription, string? minValueDescription, string? scoringInstructions, int minValue, int maxValue, bool includeComments, int adminId, string? commentsPrompt, string? commentsHint);
int GetCompetencyAssessmentQuestionRoleRequirementsCount(int assessmentQuestionId, int competencyId);
void InsertLevelDescriptor(int assessmentQuestionId, int levelValue, string levelLabel, string? levelDescription, int adminId);
int InsertComment(int frameworkId, int adminId, string comment, int? replyToCommentId);
void InsertFrameworkReview(int frameworkId, int frameworkCollaboratorId, bool required);
Expand Down Expand Up @@ -94,6 +99,7 @@ public interface IFrameworkService
void DeleteFrameworkCompetency(int frameworkCompetencyId, int adminId);
void DeleteFrameworkDefaultQuestion(int frameworkId, int assessmentQuestionId, int adminId, bool deleteFromExisting);
void DeleteCompetencyAssessmentQuestion(int frameworkCompetencyId, int assessmentQuestionId, int adminId);
IEnumerable<CompetencyResourceAssessmentQuestionParameter> GetSignpostingResourceParametersByFrameworkAndCompetencyId(int frameworkId, int competencyId);
}
public class FrameworkService : IFrameworkService
{
Expand Down Expand Up @@ -1602,5 +1608,109 @@ public int GetMaxFrameworkCompetencyGroupID()
"SELECT MAX(ID) FROM FrameworkCompetencyGroups"
).Single();
}

public CompetencyResourceAssessmentQuestionParameter? GetCompetencyResourceAssessmentQuestionParameterByCompetencyLearningResourceId(int competencyLearningResourceId)
{
var resource = connection.Query<CompetencyResourceAssessmentQuestionParameter>(
$@"SELECT p.AssessmentQuestionId, clr.ID AS CompetencyLearningResourceId, p.MinResultMatch, p.MaxResultMatch, p.Essential,
p.RelevanceAssessmentQuestionId, p.CompareToRoleRequirements, lrr.OriginalResourceName,
CASE
WHEN p.CompetencyLearningResourceId IS NULL THEN 1
ELSE 0
END AS IsNew
FROM CompetencyLearningResources AS clr
INNER JOIN LearningResourceReferences AS lrr ON clr.LearningResourceReferenceID = lrr.ID
LEFT OUTER JOIN CompetencyResourceAssessmentQuestionParameters AS p ON p.CompetencyLearningResourceID = clr.ID
WHERE clr.ID = @competencyLearningResourceId",
new { competencyLearningResourceId }).FirstOrDefault();
var questions = connection.Query<AssessmentQuestion>(
$@"SELECT * FROM AssessmentQuestions
WHERE ID IN ({resource.AssessmentQuestionId ?? 0}, {resource.RelevanceAssessmentQuestionId ?? 0})");
resource.AssessmentQuestion = questions.FirstOrDefault(q => q.ID == resource.AssessmentQuestionId);
resource.RelevanceAssessmentQuestion = questions.FirstOrDefault(q => q.ID == resource.RelevanceAssessmentQuestionId);
return resource;
}

public IEnumerable<CompetencyResourceAssessmentQuestionParameter> GetSignpostingResourceParametersByFrameworkAndCompetencyId(int frameworkId, int competencyId)
{
return connection.Query<CompetencyResourceAssessmentQuestionParameter>(
$@"SELECT clr.ID AS CompetencyLearningResourceID, lrr.OriginalResourceName, p.Essential, q.Question, p.MinResultMatch, p.MaxResultMatch,
CASE
WHEN p.CompareToRoleRequirements = 1 THEN 'Role requirements'
WHEN p.RelevanceAssessmentQuestionID IS NOT NULL THEN raq.Question
ELSE 'Don''t compare result'
END AS CompareResultTo,
CASE
WHEN p.CompetencyLearningResourceId IS NULL THEN 1
ELSE 0
END AS IsNew
FROM FrameworkCompetencies AS fc
INNER JOIN Competencies AS c ON fc.CompetencyID = c.ID
INNER JOIN CompetencyLearningResources AS clr ON clr.CompetencyID = c.ID
INNER JOIN LearningResourceReferences AS lrr ON clr.LearningResourceReferenceID = lrr.ID
LEFT JOIN CompetencyResourceAssessmentQuestionParameters AS p ON p.CompetencyLearningResourceID = clr.ID
LEFT JOIN AssessmentQuestions AS q ON p.AssessmentQuestionID = q.ID
LEFT JOIN AssessmentQuestions AS raq ON p.RelevanceAssessmentQuestionID = raq.ID
WHERE fc.FrameworkID = @FrameworkId AND clr.CompetencyID = @CompetencyId",
new { frameworkId, competencyId });
}

public LearningResourceReference GetLearningResourceReferenceByCompetencyLearningResouceId(int competencyLearningResouceId)
{
return connection.Query<LearningResourceReference>(
$@"SELECT * FROM LearningResourceReferences lrr
INNER JOIN CompetencyLearningResources clr ON clr.LearningResourceReferenceID = lrr.ID
WHERE clr.ID = @competencyLearningResouceId",
new { competencyLearningResouceId }).FirstOrDefault();
}

public int GetCompetencyAssessmentQuestionRoleRequirementsCount(int assessmentQuestionId, int competencyId)
{
var count = connection.ExecuteScalar(
$@"SELECT COUNT(*) FROM CompetencyAssessmentQuestionRoleRequirements
WHERE AssessmentQuestionID = @assessmentQuestionId AND CompetencyID = @competencyId",
new { assessmentQuestionId, competencyId });
return Convert.ToInt32(count);
}

public int EditCompetencyResourceAssessmentQuestionParameter(CompetencyResourceAssessmentQuestionParameter parameter)
{
int rowsAffected;
if (parameter.IsNew)
{
rowsAffected = connection.Execute(
$@"INSERT INTO CompetencyResourceAssessmentQuestionParameters(
CompetencyLearningResourceID,
AssessmentQuestionID,
MinResultMatch,
MaxResultMatch,
Essential,
RelevanceAssessmentQuestionID,
CompareToRoleRequirements)
VALUES(
{parameter.CompetencyLearningResourceId},
{parameter.AssessmentQuestion?.ID.ToString() ?? "null"},
{parameter.MinResultMatch},
{parameter.MaxResultMatch},
{Convert.ToInt32(parameter.Essential)},
{parameter.RelevanceAssessmentQuestion?.ID.ToString() ?? "null"},
{Convert.ToInt32(parameter.CompareToRoleRequirements)})"
);
}
else
{
rowsAffected = connection.Execute(
$@"UPDATE CompetencyResourceAssessmentQuestionParameters
SET AssessmentQuestionID = {parameter.AssessmentQuestion?.ID.ToString() ?? "null" },
MinResultMatch = {parameter.MinResultMatch},
MaxResultMatch = {parameter.MaxResultMatch},
Essential = {Convert.ToInt32(parameter.Essential)},
RelevanceAssessmentQuestionID = {parameter.RelevanceAssessmentQuestion?.ID.ToString() ?? "null"},
CompareToRoleRequirements = {Convert.ToInt32(parameter.CompareToRoleRequirements)}
WHERE CompetencyLearningResourceID = {parameter.CompetencyLearningResourceId}"
);
}
return rowsAffected;
}
}
}
Loading