diff --git a/DigitalLearningSolutions.Data.Migrations/202201121604_AllowNullAssessmentQuestionIdOnTableCompetencyResourceAssessmentQuestionParameters.cs b/DigitalLearningSolutions.Data.Migrations/202201121604_AllowNullAssessmentQuestionIdOnTableCompetencyResourceAssessmentQuestionParameters.cs new file mode 100644 index 0000000000..5262e61cba --- /dev/null +++ b/DigitalLearningSolutions.Data.Migrations/202201121604_AllowNullAssessmentQuestionIdOnTableCompetencyResourceAssessmentQuestionParameters.cs @@ -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(); + } + } +} diff --git a/DigitalLearningSolutions.Data/DataServices/CompetencyLearningResourcesDataService.cs b/DigitalLearningSolutions.Data/DataServices/CompetencyLearningResourcesDataService.cs index e594c73092..99a119f0cc 100644 --- a/DigitalLearningSolutions.Data/DataServices/CompetencyLearningResourcesDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/CompetencyLearningResourcesDataService.cs @@ -12,16 +12,8 @@ public interface ICompetencyLearningResourcesDataService IEnumerable GetCompetencyLearningResourcesByCompetencyId(int competencyId); - void AddCompetencyLearningResource( - int resourceRefId, - string originalResourceName, - int competencyId, - int adminId - ); - - IEnumerable GetCompetencyResourceAssessmentQuestionParameters( - IEnumerable competencyLearningResourceIds - ); + IEnumerable GetCompetencyResourceAssessmentQuestionParameters(IEnumerable competencyLearningResourceIds); + int AddCompetencyLearningResource(int resourceRefID, string originalResourceName, int competencyID, int adminId); } public class CompetencyLearningResourcesDataService : ICompetencyLearningResourcesDataService @@ -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( + @$" DECLARE @learningResourceReferenceID int IF NOT EXISTS(SELECT * FROM LearningResourceReferences WHERE @resourceRefID = resourceRefID) BEGIN INSERT INTO LearningResourceReferences(ResourceRefID, OriginalResourceName, AdminID, Added) @@ -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 - GetCompetencyResourceAssessmentQuestionParameters(IEnumerable competencyLearningResourceIds) + public IEnumerableGetCompetencyResourceAssessmentQuestionParameters(IEnumerable competencyLearningResourceIds) { return connection.Query( @"SELECT diff --git a/DigitalLearningSolutions.Data/Models/Frameworks/CompetencyResourceAssessmentQuestionParameter.cs b/DigitalLearningSolutions.Data/Models/Frameworks/CompetencyResourceAssessmentQuestionParameter.cs new file mode 100644 index 0000000000..af58705450 --- /dev/null +++ b/DigitalLearningSolutions.Data/Models/Frameworks/CompetencyResourceAssessmentQuestionParameter.cs @@ -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() + { + + } + } +} diff --git a/DigitalLearningSolutions.Data/Models/Frameworks/LearningResourceReference.cs b/DigitalLearningSolutions.Data/Models/Frameworks/LearningResourceReference.cs new file mode 100644 index 0000000000..b01af4ce94 --- /dev/null +++ b/DigitalLearningSolutions.Data/Models/Frameworks/LearningResourceReference.cs @@ -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; } + } +} diff --git a/DigitalLearningSolutions.Data/Services/FrameworkService.cs b/DigitalLearningSolutions.Data/Services/FrameworkService.cs index cd22cad364..a3074f7b76 100644 --- a/DigitalLearningSolutions.Data/Services/FrameworkService.cs +++ b/DigitalLearningSolutions.Data/Services/FrameworkService.cs @@ -8,6 +8,7 @@ using DigitalLearningSolutions.Data.Models.Common; using Microsoft.Extensions.Logging; using DigitalLearningSolutions.Data.Models.Email; + using System; public interface IFrameworkService { @@ -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); @@ -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 GetSignpostingResourceParametersByFrameworkAndCompetencyId(int frameworkId, int competencyId); } public class FrameworkService : IFrameworkService { @@ -1602,5 +1608,109 @@ public int GetMaxFrameworkCompetencyGroupID() "SELECT MAX(ID) FROM FrameworkCompetencyGroups" ).Single(); } + + public CompetencyResourceAssessmentQuestionParameter? GetCompetencyResourceAssessmentQuestionParameterByCompetencyLearningResourceId(int competencyLearningResourceId) + { + var resource = connection.Query( + $@"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( + $@"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 GetSignpostingResourceParametersByFrameworkAndCompetencyId(int frameworkId, int competencyId) + { + return connection.Query( + $@"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( + $@"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; + } } } diff --git a/DigitalLearningSolutions.Web/Controllers/FrameworksController/Signposting.cs b/DigitalLearningSolutions.Web/Controllers/FrameworksController/Signposting.cs index f6bb112e0e..a39698a189 100644 --- a/DigitalLearningSolutions.Web/Controllers/FrameworksController/Signposting.cs +++ b/DigitalLearningSolutions.Web/Controllers/FrameworksController/Signposting.cs @@ -9,6 +9,10 @@ using System.Net.Http; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; +using DigitalLearningSolutions.Web.Extensions; +using DigitalLearningSolutions.Data.Models.Frameworks; +using DigitalLearningSolutions.Web.Models.Enums; +using DigitalLearningSolutions.Web.Models; namespace DigitalLearningSolutions.Web.Controllers.FrameworksController { @@ -17,9 +21,9 @@ public partial class FrameworksController private static IConfiguration SignpostingConfiguration { get; set; } [Route("/Frameworks/{frameworkId}/Competency/{frameworkCompetencyId}/CompetencyGroup/{frameworkCompetencyGroupId}/Signposting")] - public IActionResult EditCompetencyLearningResources(int frameworkId, int? frameworkCompetencyGroupId = null, int? frameworkCompetencyId = null) + public IActionResult EditCompetencyLearningResources(int frameworkId, int frameworkCompetencyGroupId, int frameworkCompetencyId) { - var model = PopulatedModel(frameworkId, frameworkCompetencyId, frameworkCompetencyId); + var model = GetSignpostingResourceParameters(frameworkId, frameworkCompetencyId); return View("Developer/EditCompetencyLearningResources", model); } @@ -29,7 +33,7 @@ public async Task SearchLearningResourcesAsync(int frameworkId, i var response = new CompetencyResourceSignpostingViewModel(frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId); if (frameworkCompetencyGroupId.HasValue) { - var competency = frameworkService.GetCompetencyGroupBaseById(frameworkCompetencyGroupId.Value); + var competency = frameworkService.GetFrameworkCompetencyById(frameworkCompetencyId); response.NameOfCompetency = competency?.Name ?? ""; } if (searchText?.Trim().Length > 1) @@ -60,34 +64,259 @@ public IActionResult AddCompetencyLearningResourceSummary(CompetencyResourceSumm [HttpPost] public IActionResult ConfirmAddCompetencyLearningResourceSummary(CompetencyResourceSummaryViewModel model) { - competencyLearningResourcesDataService.AddCompetencyLearningResource(model.ReferenceId, model.ResourceName, model.FrameworkCompetencyId.Value, GetAdminId()); - return Redirect($"~/Frameworks/{model.FrameworkId}/Competency/{model.FrameworkCompetencyId}/CompetencyGroup/{model.FrameworkCompetencyGroupId}/Signposting/AddResource?searchText={model.SearchText}&page=1"); + var frameworkCompetency = frameworkService.GetFrameworkCompetencyById(model.FrameworkCompetencyId.Value); + int competencyLearningResourceId = competencyLearningResourcesDataService.AddCompetencyLearningResource(model.ReferenceId, model.ResourceName, frameworkCompetency.CompetencyID, GetAdminId()); + return RedirectToAction("StartSignpostingParametersSession", "Frameworks", new { model.FrameworkId, model.FrameworkCompetencyId, model.FrameworkCompetencyGroupId, competencyLearningResourceId }); } - private CompetencyResourceSignpostingViewModel PopulatedModel(int frameworkId, int? frameworkCompetencyGroupId = null, int? frameworkCompetencyId = null) + [Route("/Frameworks/{frameworkId}/Competency/{frameworkCompetencyId}/CompetencyGroup/{frameworkCompetencyGroupId}/SignpostingParameters")] + public IActionResult StartSignpostingParametersSession(int frameworkId, int frameworkCompetencyId, int frameworkCompetencyGroupId, int? competencyLearningResourceID) { - var model = new CompetencyResourceSignpostingViewModel(frameworkId, frameworkCompetencyId, frameworkCompetencyId); - model.NameOfCompetency = "I can organise my information and content using files and folders (either on my device, across multiple devices, or on the Cloud)"; - model.CompetencyResourceLinks = new List() + var adminId = GetAdminId(); + var frameworkCompetency = frameworkService.GetFrameworkCompetencyById(frameworkCompetencyId); + var userRole = frameworkService.GetAdminUserRoleForFrameworkId(adminId, frameworkId); + if (userRole < 2) { - new SignpostingCardViewModel() - { - Id = 1, - Name = "Cloud storage", - AssessmentQuestion = "Where are you now?", - MinimumResultMatch = 6, - MaximumResultMatch = 9, - CompareResultTo = "Where do you need to be?" - }, - new SignpostingCardViewModel() + return StatusCode(403); + } + var parameter = frameworkService.GetCompetencyResourceAssessmentQuestionParameterByCompetencyLearningResourceId(competencyLearningResourceID.Value) ?? new CompetencyResourceAssessmentQuestionParameter(true); + var questionType = parameter.RelevanceAssessmentQuestion != null ? CompareAssessmentQuestionType.CompareToOtherQuestion + : parameter.CompareToRoleRequirements ? CompareAssessmentQuestionType.CompareToRole + : CompareAssessmentQuestionType.DontCompare; + var session = new SessionCompetencyLearningResourceSignpostingParameter( + CookieName, Request.Cookies, Response.Cookies, + frameworkCompetency: frameworkCompetency, + resource: frameworkService.GetLearningResourceReferenceByCompetencyLearningResouceId(parameter.CompetencyLearningResourceId), + questions: frameworkService.GetCompetencyAssessmentQuestionsByFrameworkCompetencyId(frameworkCompetencyId, adminId).ToList(), + selectedQuestion: parameter.AssessmentQuestion, + selectedCompareQuestionType: questionType, + parameter); + TempData.Clear(); + TempData.Set(session); + + if(session.Questions.Count() == 0) + return RedirectToAction("SignpostingSetStatus", new { frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId }); + else + return RedirectToAction("EditSignpostingParameters", "Frameworks", new { frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId, competencyLearningResourceID }); + } + + [Route("/Frameworks/{frameworkId}/Competency/{frameworkCompetencyId}/CompetencyGroup/{frameworkCompetencyGroupId}/SignpostingParameters/Compare")] + public IActionResult CompareSelfAssessmentResult(int frameworkId, int frameworkCompetencyId, int frameworkCompetencyGroupId) + { + return ViewFromSession("Developer/CompareSelfAssessmentResult", frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId); + } + + [HttpPost] + public IActionResult CompareSelfAssessmentResultNext(CompareAssessmentQuestionType compareQuestionType, int? compareToQuestionId, int frameworkId, int frameworkCompetencyId, int frameworkCompetencyGroupId) + { + var session = TempData.Peek(); + var parameter = session.AssessmentQuestionParameter; + session.SelectedCompareQuestionType = compareQuestionType; + session.CompareQuestionConfirmed = true; + switch (compareQuestionType) + { + case CompareAssessmentQuestionType.DontCompare: + parameter.RelevanceAssessmentQuestion = null; + parameter.RelevanceAssessmentQuestionId = null; + parameter.CompareToRoleRequirements = false; + break; + case CompareAssessmentQuestionType.CompareToRole: + parameter.RelevanceAssessmentQuestion = null; + parameter.RelevanceAssessmentQuestionId = null; + parameter.CompareToRoleRequirements = true; + break; + case CompareAssessmentQuestionType.CompareToOtherQuestion: + parameter.RelevanceAssessmentQuestion = session.Questions.FirstOrDefault(q => q.ID == compareToQuestionId); + parameter.RelevanceAssessmentQuestionId = parameter.RelevanceAssessmentQuestion?.ID; + parameter.CompareToRoleRequirements = false; + break; + } + TempData.Set(session); + return RedirectToAction("SignpostingSetStatus", new { frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId }); + } + + [Route("/Frameworks/{frameworkId}/Competency/{frameworkCompetencyId}/CompetencyGroup/{frameworkCompetencyGroupId}/SignpostingParameters/SetStatus")] + public IActionResult SignpostingSetStatus(int frameworkId, int frameworkCompetencyId, int frameworkCompetencyGroupId) + { + return ViewFromSession("Developer/SignpostingSetStatus", frameworkId, frameworkCompetencyId, frameworkCompetencyId); + } + + private IActionResult ViewFromSession(string view, int frameworkId, int frameworkCompetencyId, int frameworkCompetencyGroupId) + { + var session = TempData.Peek(); + var model = new CompetencyLearningResourceSignpostingParametersViewModel(frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId) + { + FrameworkCompetency = session.FrameworkCompetency?.Name, + ResourceName = session.LearningResourceReference?.OriginalResourceName, + AssessmentQuestionParameter = session.AssessmentQuestionParameter, + Questions = session.Questions, + SelectedQuestion = session.Questions.FirstOrDefault(q => q.ID == session.SelectedQuestion?.ID), + SelectedLevelValues = session.SelectedLevelValues, + SelectedCompareToQuestion = session.AssessmentQuestionParameter.RelevanceAssessmentQuestion, + SelectedCompareQuestionType = session.SelectedCompareQuestionType, + AssessmentQuestionLevelDescriptors = session.LevelDescriptors, + TriggerValuesConfirmed = session.TriggerValuesConfirmed, + CompareQuestionConfirmed = session.CompareQuestionConfirmed, + SelectedQuestionRoleRequirements = session.SelectedQuestionRoleRequirements + }; + if (session.SelectedQuestion != null) + { + model.AssessmentQuestionParameter.AssessmentQuestion = session.AssessmentQuestionParameter.AssessmentQuestion; + model.AssessmentQuestionLevelDescriptors = frameworkService.GetLevelDescriptorsForAssessmentQuestionId( + session.SelectedQuestion.ID, + GetAdminId(), + session.SelectedQuestion.MinValue, + session.SelectedQuestion.MaxValue, + session.SelectedQuestion.MinValue == 0).ToList(); + }; + return View(view, model); + } + + [HttpPost] + public IActionResult SignpostingSetStatusNext(CompetencyLearningResourceSignpostingParametersViewModel model) + { + var session = TempData.Peek(); + session.AssessmentQuestionParameter.Essential = model.AssessmentQuestionParameter.Essential; + TempData.Set(session); + return RedirectToAction("AddSignpostingParametersSummary", new { model.FrameworkId, model.FrameworkCompetencyId, model.FrameworkCompetencyGroupId }); + } + + [Route("/Frameworks/{frameworkId}/Competency/{frameworkCompetencyId}/CompetencyGroup/{frameworkCompetencyGroupId}/SignpostingParameters/Summary")] + public IActionResult AddSignpostingParametersSummary(int frameworkId, int frameworkCompetencyId, int? frameworkCompetencyGroupId) + { + var session = TempData.Peek(); + if (!session.CompareQuestionConfirmed) + { + session.AssessmentQuestionParameter.RelevanceAssessmentQuestion = null; + session.AssessmentQuestionParameter.RelevanceAssessmentQuestionId = null; + } + if (!session.TriggerValuesConfirmed) + { + session.AssessmentQuestionParameter.MinResultMatch = session.AssessmentQuestionParameter.AssessmentQuestion.MinValue; + session.AssessmentQuestionParameter.MaxResultMatch = session.AssessmentQuestionParameter.AssessmentQuestion.MaxValue; + } + TempData.Set(session); + return ViewFromSession("Developer/AddSignpostingParametersSummary", frameworkId, frameworkCompetencyId, frameworkCompetencyId); + } + + [HttpPost] + public IActionResult AddSignpostingParametersSummaryConfirm(int frameworkId, int frameworkCompetencyId, int? frameworkCompetencyGroupId) + { + var session = TempData.Peek(); + frameworkService.EditCompetencyResourceAssessmentQuestionParameter(session.AssessmentQuestionParameter); + return RedirectToAction("EditCompetencyLearningResources", "Frameworks", new { frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId }); + } + + [Route("/Frameworks/{frameworkId}/Competency/{frameworkCompetencyId}/CompetencyGroup/{frameworkCompetencyGroupId}/SignpostingParameters/Edit")] + public IActionResult EditSignpostingParameters(int frameworkId, int frameworkCompetencyId, int? frameworkCompetencyGroupId, int? competencyLearningResourceId) + { + var adminId = GetAdminId(); + var userRole = frameworkService.GetAdminUserRoleForFrameworkId(adminId, frameworkId); + if (userRole < 2) + { + return StatusCode(403); + } + var session = TempData.Peek(); + var model = new CompetencyLearningResourceSignpostingParametersViewModel(frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId) + { + FrameworkCompetency = session.FrameworkCompetency.Name, + ResourceName = session.LearningResourceReference?.OriginalResourceName, + Questions = session.Questions, + SelectedQuestion = session.SelectedQuestion, + AssessmentQuestionParameter = session.AssessmentQuestionParameter + }; + TempData.Set(session); + return View("Developer/EditSignpostingParameters", model); + } + + [Route("/Frameworks/{frameworkId}/Competency/{frameworkCompetencyId}/CompetencyGroup/{frameworkCompetencyGroupId}/SignpostingParameters/Skip")] + public IActionResult EditSignpostingParametersSkip(int frameworkId, int frameworkCompetencyId, int frameworkCompetencyGroupId) + { + var session = TempData.Peek(); + session.TriggerValuesConfirmed = false; + session.CompareQuestionConfirmed = false; + TempData.Set(session); + return RedirectToAction("SignpostingSetStatus", new { frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId }); + } + + [HttpPost] + public IActionResult EditSignpostingParametersNext(CompetencyLearningResourceSignpostingParametersViewModel model) + { + if (model.SelectedQuestion?.ID != null) + { + var session = TempData.Peek(); + session.CompareQuestionConfirmed = false; + session.SelectedQuestion = session.Questions.FirstOrDefault(q => q.ID == model.SelectedQuestion.ID); + session.AssessmentQuestionParameter.AssessmentQuestion = session.SelectedQuestion; + session.LevelDescriptors = frameworkService.GetLevelDescriptorsForAssessmentQuestionId( + session.SelectedQuestion.ID, + GetAdminId(), + session.SelectedQuestion.MinValue, + session.SelectedQuestion.MaxValue, + session.SelectedQuestion.MinValue == 0).ToList(); + session.SelectedQuestionRoleRequirements = frameworkService.GetCompetencyAssessmentQuestionRoleRequirementsCount(session.SelectedQuestion.ID, session.FrameworkCompetency.CompetencyID); + TempData.Set(session); + return RedirectToAction("SignpostingParametersSetTriggerValues", new { model.FrameworkId, model.FrameworkCompetencyId, model.FrameworkCompetencyGroupId }); + } + else + { + return RedirectToAction("EditSignpostingParameters", "Frameworks", new { - Id = 2, - Name = "A guide to online file storage", - AssessmentQuestion = "Where are you now?", - MinimumResultMatch = 1, - MaximumResultMatch = 10, - CompareResultTo = "Where do you need to be?" - }, + model.FrameworkId, + model.FrameworkCompetencyId, + model.FrameworkCompetencyGroupId, + model.AssessmentQuestionParameter?.CompetencyLearningResourceId + }); + } + } + + [Route("/Frameworks/{frameworkId}/Competency/{frameworkCompetencyId}/CompetencyGroup/{frameworkCompetencyGroupId}/SignpostingParameters/SetTriggerValues")] + public IActionResult SignpostingParametersSetTriggerValues(int frameworkId, int frameworkCompetencyId, int frameworkCompetencyGroupId) + { + return ViewFromSession("Developer/SignpostingParametersSetTriggerValues", frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId); + } + + [HttpPost] + public IActionResult SignpostingParametersSetTriggerValuesNext(CompetencyResourceAssessmentQuestionParameter assessmentParameter, int[] selectedLevelValues, int frameworkId, int frameworkCompetencyId, int frameworkCompetencyGroupId) + { + var session = TempData.Peek(); + var updateSelectedValuesFromSlider = session.SelectedQuestion.AssessmentQuestionInputTypeID == 2; + bool skipCompare = session.Questions.Count() < 2 && session.SelectedQuestionRoleRequirements == 0; + session.AssessmentQuestionParameter.MinResultMatch = updateSelectedValuesFromSlider ? assessmentParameter.MinResultMatch : selectedLevelValues.Min(); + session.AssessmentQuestionParameter.MaxResultMatch = updateSelectedValuesFromSlider ? assessmentParameter.MaxResultMatch : selectedLevelValues.Max(); + session.TriggerValuesConfirmed = true; + TempData.Set(session); + if (skipCompare) + { + session.CompareQuestionConfirmed = false; + TempData.Set(session); + return RedirectToAction("SignpostingSetStatus", new { frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId }); + } + else + return RedirectToAction("CompareSelfAssessmentResult", new { frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId }); + } + + private CompetencyResourceSignpostingViewModel GetSignpostingResourceParameters(int frameworkId, int frameworkCompetencyId) + { + var frameworkCompetency = frameworkService.GetFrameworkCompetencyById(frameworkCompetencyId); + var parameters = frameworkService.GetSignpostingResourceParametersByFrameworkAndCompetencyId(frameworkId, frameworkCompetency.CompetencyID); + var model = new CompetencyResourceSignpostingViewModel(frameworkId, frameworkCompetencyId, frameworkCompetencyId) + { + NameOfCompetency = frameworkCompetency.Name, + CompetencyResourceLinks = parameters.Select(p => + new SignpostingCardViewModel() + { + AssessmentQuestionId = p.AssessmentQuestionId, + CompetencyLearningResourceId = p.CompetencyLearningResourceId, + Name = p.OriginalResourceName, + AssessmentQuestion = p.Question, + MinimumResultMatch = p.MinResultMatch, + MaximumResultMatch = p.MaxResultMatch, + CompareResultTo = p.CompareResultTo, + Essential = p.Essential, + ParameterHasNotBeenSet = p.IsNew + } + ).ToList() }; return model; } diff --git a/DigitalLearningSolutions.Web/Models/Enums/CompareAssessmentQuestionType.cs b/DigitalLearningSolutions.Web/Models/Enums/CompareAssessmentQuestionType.cs new file mode 100644 index 0000000000..5cace43dcc --- /dev/null +++ b/DigitalLearningSolutions.Web/Models/Enums/CompareAssessmentQuestionType.cs @@ -0,0 +1,9 @@ +namespace DigitalLearningSolutions.Web.Models.Enums +{ + public enum CompareAssessmentQuestionType + { + DontCompare, + CompareToRole, + CompareToOtherQuestion + } +} diff --git a/DigitalLearningSolutions.Web/Models/SessionCompetencyLearningResourceSignpostingParameter.cs b/DigitalLearningSolutions.Web/Models/SessionCompetencyLearningResourceSignpostingParameter.cs new file mode 100644 index 0000000000..a62941acd1 --- /dev/null +++ b/DigitalLearningSolutions.Web/Models/SessionCompetencyLearningResourceSignpostingParameter.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using DigitalLearningSolutions.Data.Models.Frameworks; +using Microsoft.AspNetCore.Http; +using DigitalLearningSolutions.Web.Models.Enums; + +namespace DigitalLearningSolutions.Web.Models +{ + public class SessionCompetencyLearningResourceSignpostingParameter + { + public Guid Id { get; set; } + public LearningResourceReference LearningResourceReference { get; set; } + public List Questions { get; set; } + public AssessmentQuestion SelectedQuestion { get; set; } + public int SelectedQuestionRoleRequirements { get; set; } + public int[] SelectedLevelValues { get; set; } + public CompetencyResourceAssessmentQuestionParameter AssessmentQuestionParameter { get; set; } + public FrameworkCompetency FrameworkCompetency { get; set; } + + public CompareAssessmentQuestionType? SelectedCompareQuestionType { get; set; } + public List LevelDescriptors { get; set; } + public bool TriggerValuesConfirmed { get; set; } + public bool CompareQuestionConfirmed { get; set; } + + public SessionCompetencyLearningResourceSignpostingParameter() + { + } + public SessionCompetencyLearningResourceSignpostingParameter(string cookieName, IRequestCookieCollection requestCookies, IResponseCookies responseCookies, FrameworkCompetency frameworkCompetency, LearningResourceReference resource, List questions, AssessmentQuestion selectedQuestion, CompareAssessmentQuestionType selectedCompareQuestionType, CompetencyResourceAssessmentQuestionParameter assessmentQuestionParameter) + { + var options = new CookieOptions { Expires = DateTimeOffset.UtcNow.AddDays(30) }; + FrameworkCompetency = frameworkCompetency; + LearningResourceReference = resource; + Questions = questions; + AssessmentQuestionParameter = assessmentQuestionParameter; + SelectedQuestion = selectedQuestion; + SelectedCompareQuestionType = selectedCompareQuestionType; + TriggerValuesConfirmed = false; + CompareQuestionConfirmed = false; + + if (requestCookies.ContainsKey(cookieName) && requestCookies.TryGetValue(cookieName, out string id)) + { + this.Id = Guid.Parse(id); + } + else + { + var guid = Guid.NewGuid(); + responseCookies.Append(cookieName, guid.ToString(), options); + this.Id = guid; + } + } + } +} diff --git a/DigitalLearningSolutions.Web/Scripts/frameworks/signposting.ts b/DigitalLearningSolutions.Web/Scripts/frameworks/signposting.ts new file mode 100644 index 0000000000..f0b9379e2e --- /dev/null +++ b/DigitalLearningSolutions.Web/Scripts/frameworks/signposting.ts @@ -0,0 +1,19 @@ +import * as Checkboxes from '../checkboxes'; + +function onSliderUpdate(inputElement: HTMLInputElement) { + const selectedRatio = parseInt(inputElement.value, 10) / parseInt(inputElement.max, 10); + // eslint-disable-next-line no-param-reassign + inputElement.style.background = `linear-gradient(to right, #005eb8 0%, #005eb8 ${100 * selectedRatio}%, #fff ${100 * selectedRatio}%, white 100%)`; + const output = document.querySelector(`span[for="${inputElement.id}"]`); + if (output !== null) { + output.textContent = inputElement.value; + } +} + +const inputs = Array.from(document.getElementsByTagName('input')); +inputs.forEach((e) => onSliderUpdate(e)); +inputs.forEach((e) => { + e.addEventListener('change', () => onSliderUpdate(e)); +}); + +Checkboxes.default.setUpSelectAndDeselectInGroupButtons(); diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/BaseSignpostingViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/BaseSignpostingViewModel.cs new file mode 100644 index 0000000000..5310c3e16a --- /dev/null +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/BaseSignpostingViewModel.cs @@ -0,0 +1,20 @@ +namespace DigitalLearningSolutions.Web.ViewModels.Frameworks +{ + public class BaseSignpostingViewModel + { + public int FrameworkId { get; set; } + public int? FrameworkCompetencyId { get; set; } + public int? FrameworkCompetencyGroupId { get; set; } + public BaseSignpostingViewModel(int frameworkId, int? frameworkCompetencyId, int? frameworkCompetencyGroupId) + { + FrameworkId = frameworkId; + FrameworkCompetencyId = frameworkCompetencyId; + FrameworkCompetencyGroupId = frameworkCompetencyGroupId; + } + + public BaseSignpostingViewModel() + { + + } + } +} diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyLearningResourceSignpostingParametersViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyLearningResourceSignpostingParametersViewModel.cs new file mode 100644 index 0000000000..02038b38e4 --- /dev/null +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyLearningResourceSignpostingParametersViewModel.cs @@ -0,0 +1,38 @@ +using DigitalLearningSolutions.Data.Models.Frameworks; +using DigitalLearningSolutions.Web.Models.Enums; +using System.Collections.Generic; +using System.Linq; + +namespace DigitalLearningSolutions.Web.ViewModels.Frameworks +{ + public class CompetencyLearningResourceSignpostingParametersViewModel : BaseSignpostingViewModel + { + public CompetencyResourceAssessmentQuestionParameter AssessmentQuestionParameter { get; set; } + public string FrameworkCompetency { get; set; } + public string ResourceName { get; set; } + public List Questions { get; set; } + public AssessmentQuestion SelectedQuestion { get; set; } + public AssessmentQuestion SelectedCompareToQuestion { get; set; } + public int SelectedQuestionRoleRequirements { get; set; } + public CompareAssessmentQuestionType? SelectedCompareQuestionType { get; set; } + public List AssessmentQuestionLevelDescriptors { get; set; } + public int[] SelectedLevelValues { get; set; } + public bool CompetencyAssessmentQuestionRoleRequirements { get; set; } + public bool TriggerValuesConfirmed { get; set; } + public bool CompareQuestionConfirmed { get; set; } + public CompetencyLearningResourceSignpostingParametersViewModel(int frameworkId, int? frameworkCompetencyId, int? frameworkCompetencyGroupId) : base(frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId) + { + + } + public CompetencyLearningResourceSignpostingParametersViewModel() + { + + } + + public string GetLevelLabel(int value) + { + return AssessmentQuestionLevelDescriptors[value].LevelLabel ?? value.ToString(); + } + + } +} diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyResourceSignpostingViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyResourceSignpostingViewModel.cs index 9e1870bca5..4a6acd9d6f 100644 --- a/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyResourceSignpostingViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyResourceSignpostingViewModel.cs @@ -4,14 +4,11 @@ namespace DigitalLearningSolutions.Web.ViewModels.Frameworks { - public class CompetencyResourceSignpostingViewModel + public class CompetencyResourceSignpostingViewModel : BaseSignpostingViewModel { public const int ItemsPerPage = 10; public string NameOfCompetency { get; set; } public string Title { get; set; } - public int FrameworkId { get; set; } - public int? FrameworkCompetencyId { get; set; } - public int? FrameworkCompetencyGroupId { get; set; } public List CompetencyResourceLinks { get; set; } public IEnumerable Delegates { get; set; } public string SearchText { get; set; } @@ -38,7 +35,7 @@ public static explicit operator CompetencyResourceSignpostingViewModel(Competenc return new CompetencyResourceSignpostingViewModel(model.FrameworkId, model.FrameworkCompetencyId, model.FrameworkCompetencyGroupId); } - public CompetencyResourceSignpostingViewModel(int frameworkId, int? frameworkCompetencyId, int? frameworkCompetencyGroupId) + public CompetencyResourceSignpostingViewModel(int frameworkId, int? frameworkCompetencyId, int? frameworkCompetencyGroupId) : base(frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId) { FrameworkId = frameworkId; FrameworkCompetencyId = frameworkCompetencyId; diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyResourceSummaryViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyResourceSummaryViewModel.cs index 8fdb691f66..f28b7713c6 100644 --- a/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyResourceSummaryViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/CompetencyResourceSummaryViewModel.cs @@ -6,7 +6,7 @@ namespace DigitalLearningSolutions.Web.ViewModels.Frameworks { - public class CompetencyResourceSummaryViewModel + public class CompetencyResourceSummaryViewModel : BaseSignpostingViewModel { public int ReferenceId { get; set; } @@ -15,14 +15,8 @@ public class CompetencyResourceSummaryViewModel public string Description => Resource?.Description ?? String.Empty; public string Catalogue { get; set; } public string NameOfCompetency { get; set; } - public int FrameworkId { get; set; } - public int? FrameworkCompetencyId { get; set; } - public int? FrameworkCompetencyGroupId { get; set; } - public string SearchText { get; set; } - public ResourceMetadata Resource { get; set; } - public CompetencyResourceSummaryViewModel() { @@ -32,11 +26,8 @@ public CompetencyResourceSummaryViewModel(ResourceMetadata resource) Resource = resource; } - public CompetencyResourceSummaryViewModel(int frameworkId, int frameworkCompetencyId, int frameworkCompetencyGroupId) + public CompetencyResourceSummaryViewModel(int frameworkId, int frameworkCompetencyId, int frameworkCompetencyGroupId) : base(frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId) { - FrameworkId = frameworkId; - FrameworkCompetencyId = frameworkCompetencyId; - FrameworkCompetencyGroupId = frameworkCompetencyGroupId; } } } diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/SignpostingCardViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/SignpostingCardViewModel.cs index 21bece9283..eb84b191e0 100644 --- a/DigitalLearningSolutions.Web/ViewModels/Frameworks/SignpostingCardViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/SignpostingCardViewModel.cs @@ -2,11 +2,14 @@ { public class SignpostingCardViewModel { - public int Id { get; set; } + public int? AssessmentQuestionId { get; set; } + public int? CompetencyLearningResourceId { get; set; } public string Name { get; set; } public string AssessmentQuestion { get; set; } public int MinimumResultMatch { get; set; } public int MaximumResultMatch { get; set; } public string CompareResultTo { get; set; } + public bool Essential { get; set; } + public bool ParameterHasNotBeenSet { get; set; } } } diff --git a/DigitalLearningSolutions.Web/ViewModels/Frameworks/SignpostingParametersSetTriggerValuesViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Frameworks/SignpostingParametersSetTriggerValuesViewModel.cs new file mode 100644 index 0000000000..46e8b2d714 --- /dev/null +++ b/DigitalLearningSolutions.Web/ViewModels/Frameworks/SignpostingParametersSetTriggerValuesViewModel.cs @@ -0,0 +1,23 @@ +using DigitalLearningSolutions.Data.Models.Frameworks; +using System.Collections.Generic; +using SelfAssessmentQuestion = DigitalLearningSolutions.Data.Models.SelfAssessments.AssessmentQuestion; + +namespace DigitalLearningSolutions.Web.ViewModels.Frameworks +{ + public class SignpostingParametersSetTriggerValuesViewModel : BaseSignpostingViewModel + { + public SelfAssessmentQuestion MinimumQuestion { get; set; } + public SelfAssessmentQuestion MaximumQuestion { get; set; } + public AssessmentQuestion SelectedQuestion { get; set; } + public List AssessmentQuestionLevelDescriptors { get; set; } + + public SignpostingParametersSetTriggerValuesViewModel(int frameworkId, int? frameworkCompetencyId, int? frameworkCompetencyGroupId): base(frameworkId, frameworkCompetencyId, frameworkCompetencyGroupId) + { + + } + public SignpostingParametersSetTriggerValuesViewModel() + { + + } + } +} diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddCompetencyLearningResourceSummary.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddCompetencyLearningResourceSummary.cshtml index 57bef5b384..1119801a16 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddCompetencyLearningResourceSummary.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddCompetencyLearningResourceSummary.cshtml @@ -21,7 +21,7 @@
  • Add Resource
  • Summary
  • -

    Back to Add Resource

    +

    Back to Add Resource

    } diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddCompetencyLearningResources.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddCompetencyLearningResources.cshtml index b148e05890..d9d0f57b07 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddCompetencyLearningResources.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddCompetencyLearningResources.cshtml @@ -30,7 +30,7 @@ @Model.NameOfCompetency

    -
    +

    Search the Learning Hub

    diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddSignpostingParametersSummary.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddSignpostingParametersSummary.cshtml new file mode 100644 index 0000000000..3d2d053a2a --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/AddSignpostingParametersSummary.cshtml @@ -0,0 +1,159 @@ +@using DigitalLearningSolutions.Web.ViewModels.Frameworks +@using DigitalLearningSolutions.Web.Models.Enums +@model CompetencyLearningResourceSignpostingParametersViewModel +@{ + var addOrEdit = Model.AssessmentQuestionParameter.IsNew ? "Add" : "Edit"; + bool displayRange = Model.SelectedQuestion?.AssessmentQuestionInputTypeID == 2; + ViewData["Title"] = $"{addOrEdit} Signposting Parameter"; + ViewData["Application"] = "Framework Service"; +} +@section NavMenuItems { + +} +@section NavBreadcrumbs { + +} + +

    @addOrEdit Signposting Parameters

    +
    +
    +
    + Competency +
    +
    + @Model.FrameworkCompetency +
    +
    +
    +
    +
    + Resource name +
    +
    + @Model.ResourceName +
    +
    +
    + @if (Model.SelectedQuestion != null) + { +
    +
    + Assessment question +
    +
    + @Model.AssessmentQuestionParameter.AssessmentQuestion?.Question +
    +
    + + Change + +
    +
    + } + @if (Model.TriggerValuesConfirmed) + { +
    +
    + Trigger @(displayRange ? "range" : "responses") +
    +
    + @if (displayRange) + { + + } + else + { + + @if (Model.AssessmentQuestionParameter.MaxResultMatch != Model.AssessmentQuestionParameter.MinResultMatch) + { + + } + } +
    +
    + + Change + +
    +
    + } + @if (Model.CompareQuestionConfirmed) + { +
    +
    + Compare value to +
    +
    + @(Model.SelectedCompareQuestionType == CompareAssessmentQuestionType.CompareToRole ? "Role requirements" + : Model.AssessmentQuestionParameter.RelevanceAssessmentQuestion != null ? Model.AssessmentQuestionParameter.RelevanceAssessmentQuestion.Question + : "Don''t compare result") +
    +
    + + Change + +
    +
    + } +
    +
    + Signposting status +
    +
    + @(Model.AssessmentQuestionParameter?.Essential == true ? "Essential" + : Model.AssessmentQuestionParameter?.Essential == false ? "Optional/Recommended" + : String.Empty) +
    +
    + + Change + +
    +
    +
    + +
    + +
    + @Html.HiddenFor(m => m.FrameworkId) + @Html.HiddenFor(m => m.FrameworkCompetencyGroupId) + @Html.HiddenFor(m => m.FrameworkCompetencyId) + + diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/CompareSelfAssessmentResult.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/CompareSelfAssessmentResult.cshtml new file mode 100644 index 0000000000..38c7efb56b --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/CompareSelfAssessmentResult.cshtml @@ -0,0 +1,105 @@ +@using DigitalLearningSolutions.Web.ViewModels.Frameworks; +@using DigitalLearningSolutions.Web.Models.Enums; +@model CompetencyLearningResourceSignpostingParametersViewModel +@{ + var addOrEdit = Model.AssessmentQuestionParameter.IsNew ? "Add" : "Edit"; + ViewData["Title"] = $"{addOrEdit} Signposting Parameters"; + ViewData["Application"] = "Framework Service"; +} +@section NavMenuItems { + +} +@section NavBreadcrumbs { + +} + + + +

    Compare self-assessment result to

    + +
    +
    +
    +
    + + +
    + @if(Model.SelectedQuestionRoleRequirements > 0) + { +
    + + +
    + } + @if (Model.Questions?.Count > 1) + { +
    + + +
    + +
    + +
    + } +
    +
    +
    + + Back + + +
    + @Html.HiddenFor(m => m.FrameworkId) + @Html.HiddenFor(m => m.FrameworkCompetencyGroupId) + @Html.HiddenFor(m => m.FrameworkCompetencyId) +
    + diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/EditCompetencyLearningResources.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/EditCompetencyLearningResources.cshtml index 9b2e595eb3..d8d7c20020 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/EditCompetencyLearningResources.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/EditCompetencyLearningResources.cshtml @@ -1,8 +1,8 @@ @using DigitalLearningSolutions.Web.ViewModels.Frameworks; @model CompetencyResourceSignpostingViewModel @{ - ViewData["Title"] = "Competency Resource Signposting"; - ViewData["Application"] = "Framework Service"; + ViewData["Title"] = "Competency Resource Signposting"; + ViewData["Application"] = "Framework Service"; } @section NavMenuItems { @@ -27,37 +27,28 @@

    Competency Resource Links

    - @if (Model.CompetencyResourceLinks.Any()) { foreach (var link in Model.CompetencyResourceLinks) { - + } - - - - } else if (!Model.CompetencyResourceLinks.Any()) { -
    -

    - - This is an empty competency resource signposting. - -

    -
    +

    No learning resources have been added to this competency.

    } + + diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/EditSignpostingParameters.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/EditSignpostingParameters.cshtml new file mode 100644 index 0000000000..83dd2af67f --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/EditSignpostingParameters.cshtml @@ -0,0 +1,86 @@ +@using DigitalLearningSolutions.Web.ViewModels.Frameworks; +@model CompetencyLearningResourceSignpostingParametersViewModel +@{ + var addOrEdit = Model.AssessmentQuestionParameter.IsNew ? "Add" : "Edit"; + ViewData["Title"] = $"{addOrEdit} Signposting Parameters"; + ViewData["Application"] = "Framework Service"; +} +@section NavMenuItems { + +} +@section NavBreadcrumbs { + +} + + + +

    Choose assessment question for signposting

    + +
    + +
    +
    + @foreach (var question in Model.Questions) + { +
    + + +
    + } +
    +
    +
    + + Back + + + Skip + + +
    + @Html.HiddenFor(m => m.FrameworkId) + @Html.HiddenFor(m => m.FrameworkCompetencyGroupId) + @Html.HiddenFor(m => m.FrameworkCompetencyId) + @Html.HiddenFor(m => m.SelectedQuestion.ID) + +
    +
    + + + +@section scripts { + +} diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SignpostingParametersSetTriggerValues.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SignpostingParametersSetTriggerValues.cshtml new file mode 100644 index 0000000000..4d76fa6667 --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SignpostingParametersSetTriggerValues.cshtml @@ -0,0 +1,79 @@ +@using DigitalLearningSolutions.Web.ViewModels.Frameworks; +@model CompetencyLearningResourceSignpostingParametersViewModel +@{ + var addOrEdit = Model.AssessmentQuestionParameter.IsNew ? "Add" : "Edit"; + var question = Model.Questions.Count() <= 1 ? Model.Questions.FirstOrDefault() : Model.SelectedQuestion; + ViewData["Title"] = $"{addOrEdit} Signposting Parameters"; + ViewData["Application"] = "Framework Service"; +} +@section NavMenuItems { + +} +@section NavBreadcrumbs { + +} + + + +

    Choose trigger range for - @question.Question

    + +
    +
    + @if (question.AssessmentQuestionInputTypeID == 2) + { + + } + else + { + foreach (var levelDescriptor in Model.AssessmentQuestionLevelDescriptors.Where(d => !string.IsNullOrEmpty(d.LevelLabel))) + { + bool isChecked = levelDescriptor.LevelValue == Model.AssessmentQuestionParameter.MinResultMatch || levelDescriptor.LevelValue == Model.AssessmentQuestionParameter.MaxResultMatch; +
    + + +
    + } + } +
    +
    + + Back + + +
    + @Html.HiddenFor(m => m.FrameworkId) + @Html.HiddenFor(m => m.FrameworkCompetencyGroupId) + @Html.HiddenFor(m => m.FrameworkCompetencyId) +
    + + + +@section scripts { + +} diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SignpostingSetStatus.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SignpostingSetStatus.cshtml new file mode 100644 index 0000000000..673a66ee0d --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SignpostingSetStatus.cshtml @@ -0,0 +1,77 @@ +@using DigitalLearningSolutions.Web.ViewModels.Frameworks; +@model CompetencyLearningResourceSignpostingParametersViewModel +@{ + var addOrEdit = Model.AssessmentQuestionParameter.IsNew ? "Add" : "Edit"; + var backToAction = Model.CompareQuestionConfirmed ? "CompareSelfAssessmentResult" + : !Model.TriggerValuesConfirmed ? "EditSignpostingParameters" + : "SignpostingParametersSetTriggerValues"; + ViewData["Title"] = $"{addOrEdit} Signposting Parameter"; + ViewData["Application"] = "Framework Service"; +} +@section NavMenuItems { + +} +@section NavBreadcrumbs { + +} + + + +

    Signposting status

    + +
    +
    +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + Back + + +
    + @Html.HiddenFor(m => m.FrameworkId) + @Html.HiddenFor(m => m.FrameworkCompetencyGroupId) + @Html.HiddenFor(m => m.FrameworkCompetencyId) +
    + diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/_SignpostingCard.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/_SignpostingCard.cshtml index 08fb86b1e1..fe24df2bef 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/_SignpostingCard.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/_SignpostingCard.cshtml @@ -1,5 +1,8 @@ -@using DigitalLearningSolutions.Web.ViewModels.Frameworks; -@model SignpostingCardViewModel; +@using DigitalLearningSolutions.Web.ViewModels.Frameworks +@model SignpostingCardViewModel +@{ + var parent = (CompetencyResourceSignpostingViewModel)ViewData["parent"]; +}
    @@ -7,48 +10,70 @@
    -
    +
    + @if (Model.Essential) + { +
    Essential
    + } + else + {
    Recommended
    -
    Digital Learn
    -
    + } + @*
    Digital Learn
    *@ +
    + @if(Model.ParameterHasNotBeenSet) + { +
    This resource has no signposting parameters set.
    + } + else + {

    Signposting Parameters

    + @if(!String.IsNullOrEmpty(Model.AssessmentQuestion)) + { +
    +
    + Assessment Question +
    +
    + @Model.AssessmentQuestion +
    +
    +
    +
    + Minimum result match +
    +
    + @Model.MinimumResultMatch +
    +
    +
    +
    + Maximum result match +
    +
    + @Model.MaximumResultMatch +
    +
    + }
    -
    - Assessment Question -
    -
    - @Model.AssessmentQuestion -
    -
    -
    -
    - Minimum result match -
    -
    - @Model.MinimumResultMatch -
    -
    -
    -
    - Maximum result match -
    -
    - @Model.MaximumResultMatch -
    -
    -
    -
    - Compare result to -
    -
    - @Model.CompareResultTo -
    -
    -
    +
    + Compare result to +
    +
    + @Model.CompareResultTo +
    +
    + + }
    diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/_SignpostingParametersHeader.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/_SignpostingParametersHeader.cshtml new file mode 100644 index 0000000000..0015f7756e --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/_SignpostingParametersHeader.cshtml @@ -0,0 +1,25 @@ +@using DigitalLearningSolutions.Web.ViewModels.Frameworks +@model CompetencyLearningResourceSignpostingParametersViewModel +@{ + var addOrEdit = Model.AssessmentQuestionParameter.IsNew ? "Add" : "Edit"; +} + +

    @addOrEdit Signposting Parameter

    +
    +
    +
    + Competency +
    +
    + @Model.FrameworkCompetency +
    +
    +
    +
    + Resource name +
    +
    + @Model.ResourceName +
    +
    +
    diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/_SignpostingQuestionSlider.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/_SignpostingQuestionSlider.cshtml new file mode 100644 index 0000000000..6531b5fc45 --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/_SignpostingQuestionSlider.cshtml @@ -0,0 +1,50 @@ +@using DigitalLearningSolutions.Data.Models.Frameworks +@model CompetencyResourceAssessmentQuestionParameter + + + + +
    + Minimum +
    +
    +
    + +
    +
    + @Model.MinResultMatch +
    + +
    +
    + Maximum +
    +
    +
    + +
    +
    + @Model.MaxResultMatch +
    + +
    diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Shared/_CompetencyCard.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Shared/_CompetencyCard.cshtml index e6c73f61be..8d0b65e6a1 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Shared/_CompetencyCard.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Shared/_CompetencyCard.cshtml @@ -28,7 +28,7 @@ + asp-route-frameworkCompetencyId="@Model.FrameworkCompetency.Id"> Manage resource signposting (@(Model.FrameworkCompetency.CompetencyLearningResourcesCount == 0 ? "No" : Model.FrameworkCompetency.CompetencyLearningResourcesCount.ToString()) resources) }