+ {
+ new TrainingQuestionAnswer { Answer = "Answer A", Correct = true },
+ new TrainingQuestionAnswer { Answer = "Answer B", Correct = false }
+ }
+ }
+ }
+ };
+
+ // Act
+ var result = await _trainingService.SaveAsync(training);
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Questions.Should().NotBeNull();
+ result.Questions.Should().HaveCount(1);
+ }
+
+ [Test]
+ public async Task SaveAsync_Should_Sanitize_Html_In_Description_And_Text()
+ {
+ // Arrange
+ var training = new Training
+ {
+ Name = "Training",
+ Description = "Safe content
",
+ TrainingText = "Safe training text
",
+ DepartmentId = 1,
+ CreatedByUserId = TestData.Users.TestUser1Id,
+ CreatedOn = DateTime.UtcNow
+ };
+
+ // Act
+ var result = await _trainingService.SaveAsync(training);
+
+ // Assert
+ result.Description.Should().NotContain("
+}
\ No newline at end of file
diff --git a/Web/Resgrid.Web/Areas/User/Views/Trainings/Index.cshtml b/Web/Resgrid.Web/Areas/User/Views/Trainings/Index.cshtml
index 4a800b19..7a168ef8 100644
--- a/Web/Resgrid.Web/Areas/User/Views/Trainings/Index.cshtml
+++ b/Web/Resgrid.Web/Areas/User/Views/Trainings/Index.cshtml
@@ -104,6 +104,9 @@
@if (ClaimsAuthorizationHelper.IsUserDepartmentAdmin())
{
+
+ Edit
+
Report
diff --git a/Web/Resgrid.Web/wwwroot/js/app/internal/training/resgrid.training.edittraining.js b/Web/Resgrid.Web/wwwroot/js/app/internal/training/resgrid.training.edittraining.js
new file mode 100644
index 00000000..d58e7bd2
--- /dev/null
+++ b/Web/Resgrid.Web/wwwroot/js/app/internal/training/resgrid.training.edittraining.js
@@ -0,0 +1,105 @@
+var resgrid;
+(function (resgrid) {
+ var training;
+ (function (training) {
+ var edittraining;
+ (function (edittraining) {
+ $(document).ready(function () {
+ resgrid.common.analytics.track('Training - Edit');
+
+ var quillDescription = new Quill('#editor-container', {
+ placeholder: '',
+ theme: 'snow'
+ });
+
+ var quillTraining = new Quill('#editor-container2', {
+ placeholder: '',
+ theme: 'snow'
+ });
+
+ $(document).on('submit', '#editTrainingForm', function () {
+ $('#Training_Description').val(quillDescription.root.innerHTML);
+ $('#Training_TrainingText').val(quillTraining.root.innerHTML);
+
+ return true;
+ });
+
+ // Date picker - no time needed
+ $('#Training_ToBeCompletedBy').datetimepicker({
+ timepicker: false,
+ format: 'm/d/Y',
+ scrollMonth: false,
+ scrollInput: false
+ });
+
+ // File upload: use native HTML file input (no Kendo Upload needed)
+
+ $('#SendToAll').change(function () {
+ if (this.checked) {
+ $('#groupsToAdd').prop('disabled', true).trigger('change.select2');
+ $('#rolesToAdd').prop('disabled', true).trigger('change.select2');
+ $('#usersToAdd').prop('disabled', true).trigger('change.select2');
+ } else {
+ $('#groupsToAdd').prop('disabled', false).trigger('change.select2');
+ $('#rolesToAdd').prop('disabled', false).trigger('change.select2');
+ $('#usersToAdd').prop('disabled', false).trigger('change.select2');
+ }
+ });
+
+ function initSelect2(selector, placeholder, url) {
+ $(selector).select2({
+ placeholder: placeholder,
+ allowClear: true,
+ ajax: {
+ url: url,
+ dataType: 'json',
+ processResults: function (data) {
+ return {
+ results: $.map(data, function (item) {
+ return { id: item.Id, text: item.Name };
+ })
+ };
+ }
+ }
+ });
+ }
+
+ initSelect2('#groupsToAdd', 'Select groups...', resgrid.absoluteBaseUrl + '/User/Department/GetRecipientsForGrid?filter=1');
+ initSelect2('#rolesToAdd', 'Select roles...', resgrid.absoluteBaseUrl + '/User/Department/GetRecipientsForGrid?filter=2');
+ initSelect2('#usersToAdd', 'Select users...', resgrid.absoluteBaseUrl + '/User/Department/GetRecipientsForGrid?filter=3&filterSelf=true');
+ resgrid.training.edittraining.questionsCount = 0;
+ });
+ function addQuestion() {
+ resgrid.training.edittraining.questionsCount++;
+ $('#questions tbody').first().append(" | | " + resgrid.training.edittraining.generateAnswersTable(edittraining.questionsCount) + " | |
");
+ }
+ edittraining.addQuestion = addQuestion;
+ function generateAnswersTable(count) {
+ var answersTable = '';
+ return answersTable;
+ }
+ edittraining.generateAnswersTable = generateAnswersTable;
+ function addAnswer(count) {
+ var id = generate(4);
+ $('#answersTable_' + count + ' tbody').append(" | | |
");
+ }
+ edittraining.addAnswer = addAnswer;
+ function removeQuestion(index) {
+ $('#questionRow_' + index).remove();
+ }
+ edittraining.removeQuestion = removeQuestion;
+ function generate(length) {
+ var arr = [];
+ var n;
+ for (var i = 0; i < length; i++) {
+ do
+ n = Math.floor(Math.random() * 20 + 1);
+ while (arr.indexOf(n) !== -1);
+ arr[i] = n;
+ }
+ return arr.join('');
+ }
+ edittraining.generate = generate;
+ })(edittraining = training.edittraining || (training.edittraining = {}));
+ })(training = resgrid.training || (resgrid.training = {}));
+})(resgrid || (resgrid = {}));
\ No newline at end of file