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
114 changes: 69 additions & 45 deletions DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class FrameworkCompetency : BaseSearchableItem
public int AssessmentQuestions { get; set; }
public int CompetencyLearningResourcesCount { get; set; }
public string? FrameworkName { get; set; }
public bool? AlwaysShowDescription { get; set; }

public override string SearchableName
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public CompetencyTableRow(IXLTable table, IXLRangeRow row)
RowStatus = RowStatus.NotYetProcessed;
}
public int RowNumber { get; set; }
public int CompetencyOrderNumber { get; set; }
public string? AlwaysShowDescriptionRaw { get; set; }
public ImportCompetenciesResult.ErrorReason? Error { get; set; }
public RowStatus RowStatus { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public IActionResult AddEditFrameworkCompetencyGroup(int frameworkId, Competency
(competencyGroupBase.Description), adminId);
return new RedirectResult(Url.Action("ViewFramework", new { tabname = "Structure", frameworkId }) + "#fcgroup-" + frameworkCompetencyGroupId.ToString());
}
var newCompetencyGroupId = frameworkService.InsertCompetencyGroup(competencyGroupBase.Name, SanitizerHelper.SanitizeHtmlData(competencyGroupBase.Description), adminId);
var newCompetencyGroupId = frameworkService.InsertCompetencyGroup(competencyGroupBase.Name, SanitizerHelper.SanitizeHtmlData(competencyGroupBase.Description), adminId, frameworkId);
if (newCompetencyGroupId > 0)
{
var newFrameworkCompetencyGroupId = frameworkService.InsertFrameworkCompetencyGroup(newCompetencyGroupId, frameworkId, adminId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ public IActionResult AddAssessmentQuestions(AddAssessmentQuestionsFormData model
public IActionResult AddQuestionsToWhichCompetencies()
{
var data = GetBulkUploadData();
if (data.DefaultQuestionIDs.Count ==0 && data.CustomAssessmentQuestionID == null)
{
return RedirectToAction("ImportSummary", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName });
}
var model = new AddQuestionsToWhichCompetenciesViewModel
(
data.FrameworkId,
Expand Down Expand Up @@ -224,6 +228,34 @@ public IActionResult ImportSummary()
var model = new ImportSummaryViewModel(data);
return View("Developer/Import/ImportSummary", model);
}
[HttpPost]
[Route("/Framework/{frameworkId}/{tabname}/Import/Summary")]
public IActionResult ImportSummarySubmit()
{
var data = GetBulkUploadData();
var adminId = GetAdminId();
var uploadDir = Path.Combine(webHostEnvironment.WebRootPath, "Uploads\\");
var filePath = Path.Combine(uploadDir, data.CompetenciesFileName);
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 });
}
[Route("/Framework/{frameworkId}/{tabname}/Import/Results")]
public IActionResult UploadResults()
{
var data = GetBulkUploadData();
FileHelper.DeleteFile(webHostEnvironment, data.CompetenciesFileName);
TempData.Clear();
var model = new ImportCompetenciesResultsViewModel(data.ImportCompetenciesResult, data.FrameworkId, data.FrameworkName, data.FrameworkVocubulary);
return View("Developer/Import/UploadResults", model);
}
[Route("CancelImport")]
public IActionResult CancelImport()
{
Expand Down
2 changes: 2 additions & 0 deletions DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DigitalLearningSolutions.Data.Models.Frameworks;
using DigitalLearningSolutions.Data.Models.Frameworks.Import;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -42,5 +43,6 @@ public BulkCompetenciesData(DetailFramework framework, int adminUserId, string c
public int SubtotalCompetenciesUpdated { get; set; }
public int SubTotalSkipped { get; set; }
public IEnumerable<(int RowNumber, string ErrorMessage)> Errors { get; set; } = Enumerable.Empty<(int, string)>();
public ImportCompetenciesResult ImportCompetenciesResult { get;set;}
}
}
34 changes: 17 additions & 17 deletions DigitalLearningSolutions.Web/Services/FrameworkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ bool zeroBased
//INSERT DATA
BrandedFramework CreateFramework(DetailFramework detailFramework, int adminId);

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

int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId);
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool alwaysShowDescription = false);

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

int InsertCompetency(string name, string? description, int adminId);

int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId);
int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId);

int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify);
void AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass);
int AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass);
void UpdateFrameworkCustomFlag(int frameworkId, int id, string flagName, string flagGroup, string flagTagClass);

void AddFrameworkDefaultQuestion(int frameworkId, int assessmentQuestionId, int adminId, bool addToExisting);
Expand Down Expand Up @@ -199,8 +199,8 @@ void UpdateFrameworkCompetencyGroup(
int adminId
);

void UpdateFrameworkCompetency(int frameworkCompetencyId, string name, string? description, int adminId);
void UpdateCompetencyFlags(int frameworkId, int competencyId, int[] selectedFlagIds);
void UpdateFrameworkCompetency(int frameworkCompetencyId, string name, string? description, int adminId, bool? alwaysShowDescription = false);
int UpdateCompetencyFlags(int frameworkId, int competencyId, int[] selectedFlagIds);

void MoveFrameworkCompetencyGroup(int frameworkCompetencyGroupId, bool singleStep, string direction);

Expand Down Expand Up @@ -277,9 +277,9 @@ public void AddCompetencyAssessmentQuestion(int frameworkCompetencyId, int asses
frameworkDataService.AddCompetencyAssessmentQuestion(frameworkCompetencyId, assessmentQuestionId, adminId);
}

public void AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass)
public int AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass)
{
frameworkDataService.AddCustomFlagToFramework(frameworkId, flagName, flagGroup, flagTagClass);
return frameworkDataService.AddCustomFlagToFramework(frameworkId, flagName, flagGroup, flagTagClass);
}

public void AddFrameworkDefaultQuestion(int frameworkId, int assessmentQuestionId, int adminId, bool addToExisting)
Expand Down Expand Up @@ -597,14 +597,14 @@ public int InsertCompetency(string name, string? description, int adminId)
return frameworkDataService.InsertCompetency(name, description, adminId);
}

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

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

public int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId)
Expand Down Expand Up @@ -662,19 +662,19 @@ public void UpdateAssessmentQuestion(int id, string question, int assessmentQues
frameworkDataService.UpdateAssessmentQuestion(id, question, assessmentQuestionInputTypeId, maxValueDescription, minValueDescription, scoringInstructions, minValue, maxValue, includeComments, adminId, commentsPrompt, commentsHint);
}

public void UpdateCompetencyFlags(int frameworkId, int competencyId, int[] selectedFlagIds)
public int UpdateCompetencyFlags(int frameworkId, int competencyId, int[] selectedFlagIds)
{
frameworkDataService.UpdateCompetencyFlags(frameworkId, competencyId, selectedFlagIds);
return frameworkDataService.UpdateCompetencyFlags(frameworkId, competencyId, selectedFlagIds);
}

public BrandedFramework? UpdateFrameworkBranding(int frameworkId, int brandId, int categoryId, int topicId, int adminId)
{
return frameworkDataService.UpdateFrameworkBranding(frameworkId, brandId, categoryId, topicId, adminId);
}

public void UpdateFrameworkCompetency(int frameworkCompetencyId, string name, string? description, int adminId)
{
frameworkDataService.UpdateFrameworkCompetency(frameworkCompetencyId, name, description, adminId);
public void UpdateFrameworkCompetency(int frameworkCompetencyId, string name, string? description, int adminId, bool? alwaysShowDescription)
{
frameworkDataService.UpdateFrameworkCompetency(frameworkCompetencyId, name, description, adminId, alwaysShowDescription);
}

public void UpdateFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int competencyGroupId, string name, string? description, int adminId)
Expand Down
Loading
Loading