Skip to content

Commit 3b5f619

Browse files
authored
Merge pull request #3058 from TechnologyEnhancedLearning/Develop/Features/TD-5163-CompetencyProcessing
TD-5163 competency processing and processing complete page
2 parents 8a6cb20 + 81817ba commit 3b5f619

File tree

15 files changed

+316
-90
lines changed

15 files changed

+316
-90
lines changed

DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs

Lines changed: 69 additions & 45 deletions
Large diffs are not rendered by default.

DigitalLearningSolutions.Data/Models/Frameworks/FrameworkCompetency.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class FrameworkCompetency : BaseSearchableItem
1414
public int AssessmentQuestions { get; set; }
1515
public int CompetencyLearningResourcesCount { get; set; }
1616
public string? FrameworkName { get; set; }
17+
public bool? AlwaysShowDescription { get; set; }
1718

1819
public override string SearchableName
1920
{

DigitalLearningSolutions.Data/Models/Frameworks/Import/CompetencyTableRow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public CompetencyTableRow(IXLTable table, IXLRangeRow row)
3838
RowStatus = RowStatus.NotYetProcessed;
3939
}
4040
public int RowNumber { get; set; }
41+
public int CompetencyOrderNumber { get; set; }
4142
public string? AlwaysShowDescriptionRaw { get; set; }
4243
public ImportCompetenciesResult.ErrorReason? Error { get; set; }
4344
public RowStatus RowStatus { get; set; }

DigitalLearningSolutions.Web/Controllers/FrameworksController/Competencies.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public IActionResult AddEditFrameworkCompetencyGroup(int frameworkId, Competency
7171
(competencyGroupBase.Description), adminId);
7272
return new RedirectResult(Url.Action("ViewFramework", new { tabname = "Structure", frameworkId }) + "#fcgroup-" + frameworkCompetencyGroupId.ToString());
7373
}
74-
var newCompetencyGroupId = frameworkService.InsertCompetencyGroup(competencyGroupBase.Name, SanitizerHelper.SanitizeHtmlData(competencyGroupBase.Description), adminId);
74+
var newCompetencyGroupId = frameworkService.InsertCompetencyGroup(competencyGroupBase.Name, SanitizerHelper.SanitizeHtmlData(competencyGroupBase.Description), adminId, frameworkId);
7575
if (newCompetencyGroupId > 0)
7676
{
7777
var newFrameworkCompetencyGroupId = frameworkService.InsertFrameworkCompetencyGroup(newCompetencyGroupId, frameworkId, adminId);

DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ public IActionResult AddAssessmentQuestions(AddAssessmentQuestionsFormData model
194194
public IActionResult AddQuestionsToWhichCompetencies()
195195
{
196196
var data = GetBulkUploadData();
197+
if (data.DefaultQuestionIDs.Count ==0 && data.CustomAssessmentQuestionID == null)
198+
{
199+
return RedirectToAction("ImportSummary", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName });
200+
}
197201
var model = new AddQuestionsToWhichCompetenciesViewModel
198202
(
199203
data.FrameworkId,
@@ -224,6 +228,34 @@ public IActionResult ImportSummary()
224228
var model = new ImportSummaryViewModel(data);
225229
return View("Developer/Import/ImportSummary", model);
226230
}
231+
[HttpPost]
232+
[Route("/Framework/{frameworkId}/{tabname}/Import/Summary")]
233+
public IActionResult ImportSummarySubmit()
234+
{
235+
var data = GetBulkUploadData();
236+
var adminId = GetAdminId();
237+
var uploadDir = Path.Combine(webHostEnvironment.WebRootPath, "Uploads\\");
238+
var filePath = Path.Combine(uploadDir, data.CompetenciesFileName);
239+
var workbook = new XLWorkbook(filePath);
240+
var results = importCompetenciesFromFileService.ProcessCompetenciesFromFile(workbook, adminId, data.FrameworkId, data.FrameworkVocubulary, data.ReorderCompetenciesOption, data.AddAssessmentQuestionsOption, data.AddCustomAssessmentQuestion ? (int)data.CustomAssessmentQuestionID : 0, data.AddDefaultAssessmentQuestions ? data.DefaultQuestionIDs : []);
241+
data.ImportCompetenciesResult = results;
242+
//TO DO apply ordering changes if required:
243+
if (data.ReorderCompetenciesOption == 2 && data.CompetenciesToReorderCount > 0)
244+
{
245+
246+
}
247+
setBulkUploadData(data);
248+
return RedirectToAction("UploadResults", "Frameworks", new { frameworkId = data.FrameworkId, tabname = data.TabName });
249+
}
250+
[Route("/Framework/{frameworkId}/{tabname}/Import/Results")]
251+
public IActionResult UploadResults()
252+
{
253+
var data = GetBulkUploadData();
254+
FileHelper.DeleteFile(webHostEnvironment, data.CompetenciesFileName);
255+
TempData.Clear();
256+
var model = new ImportCompetenciesResultsViewModel(data.ImportCompetenciesResult, data.FrameworkId, data.FrameworkName, data.FrameworkVocubulary);
257+
return View("Developer/Import/UploadResults", model);
258+
}
227259
[Route("CancelImport")]
228260
public IActionResult CancelImport()
229261
{

DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using DigitalLearningSolutions.Data.Models.Frameworks;
2+
using DigitalLearningSolutions.Data.Models.Frameworks.Import;
23
using System.Collections;
34
using System.Collections.Generic;
45
using System.Linq;
@@ -42,5 +43,6 @@ public BulkCompetenciesData(DetailFramework framework, int adminUserId, string c
4243
public int SubtotalCompetenciesUpdated { get; set; }
4344
public int SubTotalSkipped { get; set; }
4445
public IEnumerable<(int RowNumber, string ErrorMessage)> Errors { get; set; } = Enumerable.Empty<(int, string)>();
46+
public ImportCompetenciesResult ImportCompetenciesResult { get;set;}
4547
}
4648
}

DigitalLearningSolutions.Web/Services/FrameworkService.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,18 @@ bool zeroBased
117117
//INSERT DATA
118118
BrandedFramework CreateFramework(DetailFramework detailFramework, int adminId);
119119

120-
int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId);
120+
int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId, int? frameworkId = null);
121121

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

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

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

128-
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId);
128+
int InsertFrameworkCompetencyGroup(int groupId, int frameworkID, int adminId);
129129

130130
int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify);
131-
void AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass);
131+
int AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass);
132132
void UpdateFrameworkCustomFlag(int frameworkId, int id, string flagName, string flagGroup, string flagTagClass);
133133

134134
void AddFrameworkDefaultQuestion(int frameworkId, int assessmentQuestionId, int adminId, bool addToExisting);
@@ -199,8 +199,8 @@ void UpdateFrameworkCompetencyGroup(
199199
int adminId
200200
);
201201

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

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

@@ -277,9 +277,9 @@ public void AddCompetencyAssessmentQuestion(int frameworkCompetencyId, int asses
277277
frameworkDataService.AddCompetencyAssessmentQuestion(frameworkCompetencyId, assessmentQuestionId, adminId);
278278
}
279279

280-
public void AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass)
280+
public int AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass)
281281
{
282-
frameworkDataService.AddCustomFlagToFramework(frameworkId, flagName, flagGroup, flagTagClass);
282+
return frameworkDataService.AddCustomFlagToFramework(frameworkId, flagName, flagGroup, flagTagClass);
283283
}
284284

285285
public void AddFrameworkDefaultQuestion(int frameworkId, int assessmentQuestionId, int adminId, bool addToExisting)
@@ -597,14 +597,14 @@ public int InsertCompetency(string name, string? description, int adminId)
597597
return frameworkDataService.InsertCompetency(name, description, adminId);
598598
}
599599

600-
public int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId)
600+
public int InsertCompetencyGroup(string groupName, string? groupDescription, int adminId, int? frameworkId)
601601
{
602-
return frameworkDataService.InsertCompetencyGroup(groupName, groupDescription, adminId);
602+
return frameworkDataService.InsertCompetencyGroup(groupName, groupDescription, adminId, frameworkId);
603603
}
604604

605-
public int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId)
605+
public int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId, bool alwaysShowDescription = false)
606606
{
607-
return frameworkDataService.InsertFrameworkCompetency(competencyId, frameworkCompetencyGroupID, adminId, frameworkId);
607+
return frameworkDataService.InsertFrameworkCompetency(competencyId, frameworkCompetencyGroupID, adminId, frameworkId, alwaysShowDescription);
608608
}
609609

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

665-
public void UpdateCompetencyFlags(int frameworkId, int competencyId, int[] selectedFlagIds)
665+
public int UpdateCompetencyFlags(int frameworkId, int competencyId, int[] selectedFlagIds)
666666
{
667-
frameworkDataService.UpdateCompetencyFlags(frameworkId, competencyId, selectedFlagIds);
667+
return frameworkDataService.UpdateCompetencyFlags(frameworkId, competencyId, selectedFlagIds);
668668
}
669669

670670
public BrandedFramework? UpdateFrameworkBranding(int frameworkId, int brandId, int categoryId, int topicId, int adminId)
671671
{
672672
return frameworkDataService.UpdateFrameworkBranding(frameworkId, brandId, categoryId, topicId, adminId);
673673
}
674674

675-
public void UpdateFrameworkCompetency(int frameworkCompetencyId, string name, string? description, int adminId)
676-
{
677-
frameworkDataService.UpdateFrameworkCompetency(frameworkCompetencyId, name, description, adminId);
675+
public void UpdateFrameworkCompetency(int frameworkCompetencyId, string name, string? description, int adminId, bool? alwaysShowDescription)
676+
{
677+
frameworkDataService.UpdateFrameworkCompetency(frameworkCompetencyId, name, description, adminId, alwaysShowDescription);
678678
}
679679

680680
public void UpdateFrameworkCompetencyGroup(int frameworkCompetencyGroupId, int competencyGroupId, string name, string? description, int adminId)

0 commit comments

Comments
 (0)