Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 11 additions & 9 deletions DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ bool zeroBased

IEnumerable<FrameworkCompetency> GetAllCompetenciesForAdminId(string name, int adminId);

int InsertCompetency(string name, string? description, int adminId);
int InsertCompetency(string name, string? description, int adminId, bool alwaysShowDescription = false);

int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool alwaysShowDescription = false);
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool addDefaultQuestions = true);

int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify, int? centreID);

Expand Down Expand Up @@ -618,7 +618,7 @@ FROM [FrameworkCompetencyGroups]
return existingId;
}

public int InsertCompetency(string name, string? description, int adminId)
public int InsertCompetency(string name, string? description, int adminId, bool alwaysShowDescription = false)
{
if ((name.Length == 0) | (adminId < 1))
{
Expand All @@ -630,10 +630,10 @@ public int InsertCompetency(string name, string? description, int adminId)
description = (description?.Trim() == "" ? null : description);

var existingId = connection.QuerySingle<int>(
@"INSERT INTO Competencies ([Name], [Description], UpdatedByAdminID)
@"INSERT INTO Competencies ([Name], [Description], UpdatedByAdminID, AlwaysShowDescription)
OUTPUT INSERTED.Id
VALUES (@name, @description, @adminId)",
new { name, description, adminId }
VALUES (@name, @description, @adminId, @alwaysShowDescription)",
new { name, description, adminId, alwaysShowDescription }
);

return existingId;
Expand All @@ -644,7 +644,7 @@ public int InsertFrameworkCompetency(
int? frameworkCompetencyGroupID,
int adminId,
int frameworkId,
bool alwaysShowDescription = false
bool addDefaultQuestions = true
)
{
if ((competencyId < 1) | (adminId < 1) | (frameworkId < 1))
Expand Down Expand Up @@ -706,8 +706,10 @@ FROM [FrameworkCompetencies]
new { competencyId, frameworkCompetencyGroupID }
);
}

AddDefaultQuestionsToCompetency(competencyId, frameworkId);
if(addDefaultQuestions)
{
AddDefaultQuestionsToCompetency(competencyId, frameworkId);
}
return existingId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,16 @@ public IActionResult AddAssessmentQuestions()
public IActionResult AddAssessmentQuestions(AddAssessmentQuestionsFormData model)
{
var data = GetBulkUploadData();
data.AddDefaultAssessmentQuestions = model.AddDefaultAssessmentQuestions;

if (model.AddDefaultAssessmentQuestions)
{
data.DefaultQuestionIDs = model.DefaultAssessmentQuestionIDs;
data.DefaultQuestionIDs = model.DefaultAssessmentQuestionIDs ?? [];
}
else
{
data.DefaultQuestionIDs = [];
}
data.AddDefaultAssessmentQuestions = (data.DefaultQuestionIDs.Count > 0 && model.AddDefaultAssessmentQuestions);
data.AddCustomAssessmentQuestion = model.AddCustomAssessmentQuestion;
if (model.AddCustomAssessmentQuestion)
{
Expand All @@ -198,9 +199,8 @@ public IActionResult AddAssessmentQuestions(AddAssessmentQuestionsFormData model
{
data.CustomAssessmentQuestionID = null;
}
if (data.CompetenciesToUpdateCount > 0)
if (data.CompetenciesToUpdateCount > 0 && (data.DefaultQuestionIDs.Count + (data.CustomAssessmentQuestionID != null ? 1 : 0) > 0))
{
data.AddAssessmentQuestionsOption = 2;
setBulkUploadData(data);
return RedirectToAction("AddQuestionsToWhichCompetencies", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName });
}
Expand Down Expand Up @@ -260,11 +260,6 @@ public IActionResult ImportSummarySubmit()
var workbook = new XLWorkbook(filePath);
var results = importCompetenciesFromFileService.ProcessCompetenciesFromFile(workbook, adminId, data.FrameworkId, data.FrameworkVocubulary, data.ReorderCompetenciesOption, data.AddAssessmentQuestionsOption, data.AddCustomAssessmentQuestion ? (int)data.CustomAssessmentQuestionID : 0, data.AddDefaultAssessmentQuestions ? data.DefaultQuestionIDs : []);
data.ImportCompetenciesResult = results;
//TO DO apply ordering changes if required:
if (data.ReorderCompetenciesOption == 2 && data.CompetenciesToReorderCount > 0)
{

}
setBulkUploadData(data);
return RedirectToAction("UploadResults", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public BulkCompetenciesData(DetailFramework framework, int adminUserId, string c
public bool AddCustomAssessmentQuestion { get; set; } = false;
public List<int> DefaultQuestionIDs { get; set; } = [];
public int? CustomAssessmentQuestionID { get; set; }
public int AddAssessmentQuestionsOption { get; set; } = 1; //1 = only added, 2 = added and updated, 3 = all uploaded
public int AddAssessmentQuestionsOption { get; set; } = 2; //1 = only added, 2 = added and updated, 3 = all uploaded
public int CompetenciesToProcessCount { get; set; }
public int CompetenciesToAddCount { get; set; }
public int CompetenciesToUpdateCount { get; set; }
Expand Down
12 changes: 6 additions & 6 deletions DigitalLearningSolutions.Web/Services/FrameworkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ bool zeroBased

int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId, int? frameworkId = null);

int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool alwaysShowDescription = false);
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool addDefaultQuestions = true);

IEnumerable<FrameworkCompetency> GetAllCompetenciesForAdminId(string name, int adminId);

int InsertCompetency(string name, string? description, int adminId);
int InsertCompetency(string name, string? description, int adminId, bool alwaysShowDescription = false);

int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId);

Expand Down Expand Up @@ -594,19 +594,19 @@ public int InsertComment(int frameworkId, int adminId, string comment, int? repl
return frameworkDataService.InsertComment(frameworkId, adminId, comment, replyToCommentId);
}

public int InsertCompetency(string name, string? description, int adminId)
public int InsertCompetency(string name, string? description, int adminId, bool alwaysShowDescription = false)
{
return frameworkDataService.InsertCompetency(name, description, adminId);
return frameworkDataService.InsertCompetency(name, description, adminId, alwaysShowDescription);
}

public int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId, int? frameworkId)
{
return frameworkDataService.InsertCompetencyGroup(groupName, groupDescription, adminId, frameworkId);
}

public int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool alwaysShowDescription = false)
public int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool addDefaultQuestions = true)
{
return frameworkDataService.InsertFrameworkCompetency(competencyId, frameworkCompetencyGroupID, adminId, frameworkId, alwaysShowDescription);
return frameworkDataService.InsertFrameworkCompetency(competencyId, frameworkCompetencyGroupID, adminId, frameworkId, addDefaultQuestions);
}

public int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ CompetencyTableRow competencyRow
else
{
//Check if competency already exists in framework competency group and add if not
newCompetencyId = frameworkService.InsertCompetency(competencyRow.Competency, competencyRow.CompetencyDescription, adminId);
newCompetencyId = frameworkService.InsertCompetency(competencyRow.Competency, competencyRow.CompetencyDescription, adminId, competencyRow.AlwaysShowDescription ?? false);
if (newCompetencyId > 0)
{
newFrameworkCompetencyId = frameworkService.InsertFrameworkCompetency(newCompetencyId, frameworkCompetencyGroupId, adminId, frameworkId, competencyRow.AlwaysShowDescription ?? false); //including always show desc flag
newFrameworkCompetencyId = frameworkService.InsertFrameworkCompetency(newCompetencyId, frameworkCompetencyGroupId, adminId, frameworkId, false);
if (newFrameworkCompetencyId > maxFrameworkCompetencyId)
{
competencyRow.RowStatus = (competencyRow.RowStatus == RowStatus.CompetencyGroupInserted ? RowStatus.CompetencyGroupAndCompetencyInserted : RowStatus.CompetencyInserted);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DigitalLearningSolutions.Web.Helpers;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;

namespace DigitalLearningSolutions.Web.ViewModels.Frameworks.Import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
@if (Model.CompetenciesToAddCount > 0)
{
<div class="nhsuk-radios__item">
<input class="nhsuk-radios__input" id="option-1" asp-for="@Model.AddAssessmentQuestionsOption" type="radio" value="1" aria-describedby="option-1-hint">
<input class="nhsuk-radios__input" id="option-1" asp-for="AddAssessmentQuestionsOption" type="radio" value="1" aria-describedby="option-1-hint">
<label class="nhsuk-label nhsuk-radios__label" for="option-1">
Only add questions to new @Model.FrameworkVocabularyPlural.ToLower()
</label>
Expand All @@ -57,7 +57,7 @@
</div>
}
<div class="nhsuk-radios__item">
<input class="nhsuk-radios__input" id="option-2" asp-for="@Model.AddAssessmentQuestionsOption" type="radio" value="2" aria-describedby="option-2-hint">
<input class="nhsuk-radios__input" id="option-2" asp-for="AddAssessmentQuestionsOption" type="radio" value="2" aria-describedby="option-2-hint">
<label class="nhsuk-label nhsuk-radios__label" for="option-2">
Only add questions to @(Model.CompetenciesToAddCount > 0 ? " new and " : "") modified @Model.FrameworkVocabularyPlural.ToLower()
</label>
Expand All @@ -66,7 +66,7 @@
</div>
</div>
<div class="nhsuk-radios__item">
<input class="nhsuk-radios__input" id="option-3" asp-for="@Model.AddAssessmentQuestionsOption" type="radio" value="3" aria-describedby="option-3-hint">
<input class="nhsuk-radios__input" id="option-3" asp-for="AddAssessmentQuestionsOption" type="radio" value="3" aria-describedby="option-3-hint">
<label class="nhsuk-label nhsuk-radios__label" for="option-3">
Add questions to all @Model.FrameworkVocabularyPlural.ToLower() in my uploaded sheet
</label>
Expand Down
Loading