Skip to content

Commit e1f0f26

Browse files
committed
TD-5155 Adds view model and constructor
1 parent a0fa229 commit e1f0f26

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

DigitalLearningSolutions.Web/Controllers/FrameworksController/ImportCompetencies.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
using DigitalLearningSolutions.Web.ViewModels.Frameworks.Import;
77
using GDS.MultiPageFormData.Enums;
88
using Microsoft.AspNetCore.Mvc;
9+
using Microsoft.AspNetCore.Mvc.Rendering;
910
using System.IO;
11+
using System.Linq;
1012

1113
namespace DigitalLearningSolutions.Web.Controllers.FrameworksController
1214
{
@@ -94,8 +96,24 @@ public IActionResult ImportCompleted()
9496
public IActionResult AddAssessmentQuestions()
9597
{
9698
var data = GetBulkUploadData();
97-
98-
return View();
99+
var adminId = GetAdminId();
100+
var defaultQuestions = frameworkService.GetFrameworkDefaultQuestionsById(data.FrameworkId, adminId);
101+
var questionList = frameworkService.GetAssessmentQuestions(data.FrameworkId, adminId).ToList();
102+
var questionSelectList = new SelectList(questionList, "ID", "Label");
103+
var model = new AddAssessmentQuestionsViewModel
104+
(
105+
data.FrameworkId,
106+
data.FrameworkName,
107+
data.FrameworkVocubulary,
108+
data.PublishStatusID,
109+
data.CompetenciesToAddCount,
110+
data.CompetenciesToUpdateCount,
111+
defaultQuestions,
112+
questionSelectList
113+
);
114+
model.DefaultAssessmentQuestionIDs = data.DefaultQuestionIDs;
115+
model.OtherAssessmentQuestionIDs = data.AssessmentQuestionIDs;
116+
return View(model);
99117
}
100118
private void setupBulkUploadData(int frameworkId, int adminUserID, string competenciessFileName, string tabName, bool isNotBlank)
101119
{

DigitalLearningSolutions.Web/Models/BulkCompetenciesData.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public BulkCompetenciesData(DetailFramework framework, int adminUserId, string c
2727
public int AdminUserId { get; set; }
2828
public bool IsNotBlank { get; set; }
2929
public string CompetenciesFileName { get; set; }
30+
public List<int> DefaultQuestionIDs { get; set; }
3031
public List<int> AssessmentQuestionIDs { get; set; }
3132
public int? AddAssessmentQuestionOption { get; set; }
3233
public int CompetenciesToProcessCount { get; set; }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Collections.Generic;
2+
3+
namespace DigitalLearningSolutions.Web.ViewModels.Frameworks.Import
4+
{
5+
public class AddAssessmentQuestionsFormData
6+
{
7+
public List<int> DefaultAssessmentQuestionIDs { get; set; }
8+
public List<int> OtherAssessmentQuestionIDs { get; set; }
9+
}
10+
}
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
using DigitalLearningSolutions.Data.Models.Frameworks;
2+
using DigitalLearningSolutions.Web.Helpers;
23
using Microsoft.AspNetCore.Mvc.Rendering;
34
using System.Collections.Generic;
45

56
namespace DigitalLearningSolutions.Web.ViewModels.Frameworks.Import
67
{
7-
public class AddAssessmentQuestionsViewModel
8+
public class AddAssessmentQuestionsViewModel(
9+
DetailFramework framework,
10+
int newCompetencies,
11+
int existingCompetencies,
12+
IEnumerable<AssessmentQuestion> defaultQuestions,
13+
SelectList questionSelectList
14+
) : AddAssessmentQuestionsFormData
815
{
9-
public DetailFramework Framework { get; set; }
10-
public IEnumerable<AssessmentQuestion>? FrameworkDefaultQuestions { get; set; }
11-
public SelectList? QuestionSelectList { get; set; }
16+
public int FrameworkID { get; set; } = framework.ID;
17+
public string FrameworkName { get; set; } = framework.FrameworkName;
18+
public string FrameworkVocabularySingular { get; set; } = FrameworkVocabularyHelper.VocabularySingular(framework.FrameworkConfig);
19+
public string FrameworkVocabularyPlural { get; set; } = FrameworkVocabularyHelper.VocabularyPlural(framework.FrameworkConfig);
20+
public int PublishStatusID { get; set; } = framework.PublishStatusID;
21+
public int NewCompetencies { get; set; } = newCompetencies;
22+
public int ExistingCompetencies { get; set; } = existingCompetencies;
23+
public IEnumerable<AssessmentQuestion>? DefaultQuestions { get; set; } = defaultQuestions;
24+
public SelectList? QuestionSelectList { get; set; } = questionSelectList;
1225
}
1326
}

0 commit comments

Comments
 (0)