-
Training Attachments
+
@localizer["TrainingAttachmentsHeader"]
- Below are the files (attachments) for this training. Please download, open and review all of these attachments as well as the training text. Information in these attachments can be questions in the training quiz.
+ @localizer["AttachmentsHelpText"]
-
Training files
+
@localizer["TrainingFilesHeader"]
@if (Model.Training.Attachments != null && Model.Training.Attachments.Count > 0)
{
@@ -120,12 +121,12 @@
@if (Model.Training.Questions != null && Model.Training.Questions.Count > 0 && (currentUser != null && !currentUser.Complete))
{
-
Training Quiz
+
@localizer["TrainingQuizHeader"]
- This training has a quiz. Please review all the of the training text and all attachments to the training before you take the quiz.
+ @localizer["QuizHelpText"]
-
-
Take Quiz
+
+
@localizer["TakeQuizButton"]
}
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..6a37da64
--- /dev/null
+++ b/Web/Resgrid.Web/wwwroot/js/app/internal/training/resgrid.training.edittraining.js
@@ -0,0 +1,121 @@
+var resgrid;
+(function (resgrid) {
+ var training;
+ (function (training) {
+ var edittraining;
+ (function (edittraining) {
+ var i18n = (typeof resgridTrainingsI18n !== 'undefined') ? resgridTrainingsI18n : {};
+
+ function escapeHtml(str) {
+ if (!str) return '';
+ return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''');
+ }
+
+ $(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');
+ }
+ }).trigger('change');
+
+ 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', i18n.selectGroups || 'Select groups...', resgrid.absoluteBaseUrl + '/User/Department/GetRecipientsForGrid?filter=1');
+ initSelect2('#rolesToAdd', i18n.selectRoles || 'Select roles...', resgrid.absoluteBaseUrl + '/User/Department/GetRecipientsForGrid?filter=2');
+ initSelect2('#usersToAdd', i18n.selectUsers || 'Select users...', resgrid.absoluteBaseUrl + '/User/Department/GetRecipientsForGrid?filter=3&filterSelf=true');
+ // Derive questionsCount from existing server-rendered question rows to avoid index collisions
+ var maxIndex = 0;
+ $('#questions tbody').first().find('input[name^="question_"], textarea[name^="question_"]').each(function () {
+ var match = $(this).attr('name').match(/^question_(\d+)$/);
+ if (match) {
+ var idx = parseInt(match[1], 10);
+ if (idx > maxIndex) maxIndex = idx;
+ }
+ });
+ resgrid.training.edittraining.questionsCount = maxIndex;
+ });
+ function addQuestion() {
+ var removeTooltip = escapeHtml(i18n.removeQuestionTooltip || 'Remove this question');
+ resgrid.training.edittraining.questionsCount++;
+ $('#questions tbody').first().append(" | " + resgrid.training.edittraining.generateAnswersTable(edittraining.questionsCount) + " | |
");
+ }
+ edittraining.addQuestion = addQuestion;
+ function generateAnswersTable(count) {
+ var addAnswerLabel = escapeHtml(i18n.addAnswer || 'Add Answer');
+ var addAnswerTooltip = escapeHtml(i18n.addAnswerTooltip || 'Add Answers to Question');
+ var correctLabel = escapeHtml(i18n.correct || 'Correct');
+ var answerTextLabel = escapeHtml(i18n.answerText || 'Answer Text');
+ var answersTable = '';
+ return answersTable;
+ }
+ edittraining.generateAnswersTable = generateAnswersTable;
+ function addAnswer(count) {
+ var id = generate(4);
+ var answerRequired = escapeHtml(i18n.answerRequired || 'Answer is required');
+ var removeAnswerTooltip = escapeHtml(i18n.removeAnswerTooltip || 'Remove this answer from the question');
+ $('#answersTable_' + count + ' tbody').append(" | | |
");
+ }
+ edittraining.addAnswer = addAnswer;
+ function removeQuestion(index) {
+ $('#questionRow_' + index).remove();
+ }
+ edittraining.removeQuestion = removeQuestion;
+ var _answerIdCounter = 0;
+ function generate() {
+ return ++_answerIdCounter;
+ }
+ edittraining.generate = generate;
+ })(edittraining = training.edittraining || (training.edittraining = {}));
+ })(training = resgrid.training || (resgrid.training = {}));
+})(resgrid || (resgrid = {}));
diff --git a/Web/Resgrid.Web/wwwroot/js/app/internal/training/resgrid.training.newtraining.js b/Web/Resgrid.Web/wwwroot/js/app/internal/training/resgrid.training.newtraining.js
index a703eb69..fda46166 100644
--- a/Web/Resgrid.Web/wwwroot/js/app/internal/training/resgrid.training.newtraining.js
+++ b/Web/Resgrid.Web/wwwroot/js/app/internal/training/resgrid.training.newtraining.js
@@ -5,6 +5,13 @@ var resgrid;
(function (training) {
var newtraining;
(function (newtraining) {
+ var i18n = (typeof resgridTrainingsI18n !== 'undefined') ? resgridTrainingsI18n : {};
+
+ function escapeHtml(str) {
+ if (!str) return '';
+ return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''');
+ }
+
$(document).ready(function () {
resgrid.common.analytics.track('Training - New');
@@ -65,37 +72,36 @@ var resgrid;
});
}
- 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');
+ initSelect2('#groupsToAdd', i18n.selectGroups || 'Select groups...', resgrid.absoluteBaseUrl + '/User/Department/GetRecipientsForGrid?filter=1');
+ initSelect2('#rolesToAdd', i18n.selectRoles || 'Select roles...', resgrid.absoluteBaseUrl + '/User/Department/GetRecipientsForGrid?filter=2');
+ initSelect2('#usersToAdd', i18n.selectUsers || 'Select users...', resgrid.absoluteBaseUrl + '/User/Department/GetRecipientsForGrid?filter=3&filterSelf=true');
resgrid.training.newtraining.questionsCount = 0;
});
function addQuestion() {
+ var removeTooltip = escapeHtml(i18n.removeQuestionTooltip || 'Remove this question');
resgrid.training.newtraining.questionsCount++;
- $('#questions tbody').first().append(" | " + resgrid.training.newtraining.generateAnswersTable(newtraining.questionsCount) + " | |
");
+ $('#questions tbody').first().append(" | " + resgrid.training.newtraining.generateAnswersTable(newtraining.questionsCount) + " | |
");
}
newtraining.addQuestion = addQuestion;
function generateAnswersTable(count) {
- var answersTable = '';
+ var addAnswerLabel = escapeHtml(i18n.addAnswer || 'Add Answer');
+ var addAnswerTooltip = escapeHtml(i18n.addAnswerTooltip || 'Add Answers to Question');
+ var correctLabel = escapeHtml(i18n.correct || 'Correct');
+ var answerTextLabel = escapeHtml(i18n.answerText || 'Answer Text');
+ var answersTable = '';
return answersTable;
}
newtraining.generateAnswersTable = generateAnswersTable;
function addAnswer(count) {
var id = generate(4);
- $('#answersTable_' + count + ' tbody').append(" | | |
");
- //addGroupRoleField('answerForQuestion_' + count + '_' + timestamp.getUTCMilliseconds());
+ var answerRequired = escapeHtml(i18n.answerRequired || 'Answer is required');
+ var removeAnswerTooltip = escapeHtml(i18n.removeAnswerTooltip || 'Remove this answer from the question');
+ $('#answersTable_' + count + ' tbody').append(" | | |
");
}
newtraining.addAnswer = addAnswer;
- 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('');
+ var _answerIdCounter = 0;
+ function generate() {
+ return ++_answerIdCounter;
}
newtraining.generate = generate;
})(newtraining = training.newtraining || (training.newtraining = {}));