Skip to content

feat(training): Add edit functionality for training module#319

Open
waylonkenning wants to merge 102 commits intoResgrid:developfrom
waylonkenning:feature/training-edit-functionality
Open

feat(training): Add edit functionality for training module#319
waylonkenning wants to merge 102 commits intoResgrid:developfrom
waylonkenning:feature/training-edit-functionality

Conversation

@waylonkenning
Copy link
Copy Markdown

Summary

This PR implements editable training articles as requested in #180, allowing department admins to modify training content after creation.

Fixes #180

Changes

New Features

  • Edit Training Page: Department admins can now edit training name, description, training text, minimum score, and due date
  • Attachment Management: Existing attachments are preserved and new attachments can be added
  • User Assignment: Shows currently assigned users; allows adding new users, groups, or roles (existing assignments preserved)
  • Question Editor: Full editing of questions and answers with correct answer selection

Files Added

  • Tests/Resgrid.Tests/Mocks/MockTrainingRepository.cs - In-memory repository for unit tests
  • Tests/Resgrid.Tests/Mocks/MockTrainingAttachmentRepository.cs - Mock for attachment queries
  • Tests/Resgrid.Tests/Mocks/MockTrainingQuestionRepository.cs - Mock for question queries
  • Tests/Resgrid.Tests/Mocks/MockTrainingUserRepository.cs - Mock for user assignment queries
  • Tests/Resgrid.Tests/Services/TrainingServiceTests.cs - 15 unit tests for service layer
  • Web/Resgrid.Web/Areas/User/Models/Training/EditTrainingModel.cs - View model
  • Web/Resgrid.Web/Areas/User/Views/Trainings/Edit.cshtml - Edit form view
  • Web/Resgrid.Web/wwwroot/js/app/internal/training/resgrid.training.edittraining.js - JavaScript for edit page

Files Modified

  • Web/Resgrid.Web/Areas/User/Controllers/TrainingsController.cs - Added Edit GET/POST actions
  • Web/Resgrid.Web/Areas/User/Views/Trainings/Index.cshtml - Added Edit button for admins

Issue Requirements Addressed

From #180:

Requirement Status Notes
Edit training articles ✅ Done Admins can edit all training fields
Preserve questions when editing ✅ Done Questions/answers preserved and editable
Add users/groups/roles after creation ✅ Done Can add assignments to existing training

Future Enhancements (Not in this PR)

  • Notification system when training updated
  • Revision history tracking

Testing

Unit Tests (15 tests)

  • GetTrainingByIdAsync - Returns training with questions/attachments
  • GetAllTrainingsForDepartmentAsync - Filters by department
  • SaveAsync - Create/update with questions, HTML sanitization
  • DeleteTrainingAsync - Removes training
  • SetTrainingAsViewedAsync - Marks viewed, auto-completes when no questions
  • RecordTrainingQuizResultAsync - Records score and completion
  • ResetUserAsync - Resets user progress
  • GetTrainingUsersForUserAsync - Gets user's assigned trainings

Manual Testing Checklist

  • Edit button appears on training index (admin only)
  • Form pre-populates with existing data
  • Existing attachments shown as download links
  • New attachments added without removing existing
  • Existing user assignments preserved, new users can be added
  • Questions and answers editable, correct answer selectable
  • Authorization: non-admins receive 401 Unauthorized
  • NotFound for non-existent training

Screenshots

Edit button added to training index page next to Report and Delete buttons for department admins

Edit form pre-populates all existing training data including attachments, questions, and user assignments

ucswift added 30 commits August 18, 2024 11:27
CU-3wen6jw fixing worker issue
CU-3wen6jw adding permission checks for users
CU-868a1kgf7 update for android push
CU-868a1kgf7 fixing iOS critical notification bug.
CU-868a3neq0 trying to fix eventing issue.
CU-868a5nz1n fixed wrong url for messages email
CU-868a5nz1n setting new default for error logger (console)
CU-868a5nz1n trying to fix pricing page.
CU-868a7khdq making subscription page a bit more clear.
CU-868a7khdq Changing how stripeCustomerId empty are handled
CU-868a7khdq trying to fix sub bug
CU-868ba84kp fixing bug with db container reg
CU-8687aj3gt Adjusting angular build
CU-8687aj3gt Working on Novu api call provider
CU-8687aj3gt Working on more Novu push work
CU-3w8z67w Fixing docker paths
CU-3w8z67w Working on lib issue.
CU-868d85dv8 Fixed missing connection string issues.
CU-868d85dv8 Fixing docker typo
CU-868d85dv8 More upgrade work and posthog work.
CU-868d85dv8 fixed url shortner to use kutt
ucswift and others added 27 commits February 12, 2026 10:55
RE1-T102 Moving MCP config to normal Resgrid.Confg structure.
RE1-T102 Fixing MCP server issue.
RE1-T102 MCP server over HTTP fix
RE1-T60 Updated to SCIM and SSO flow
RE1-T46 Fixing bug with action logs query.
RE1-T46 Flagged report, select unit and report bug fix.
RE1-T46 Trying to fix Sentry issue
RE1-T106 Notification page fix
RE1-T105 More custom maps work
RE1-T105 Fixing issues with routes.
RE1-T105 Added Languages to missing pages, gdpr support for export, e…
RE1-T107 Added checkin timers to calls
…all/Station

The commit RE1-T104 switched from Kendo UI Windows to Bootstrap modals
but didn't add the required modal HTML structure. Kendo's kendoWindow()
could auto-create the window on empty divs, but Bootstrap modals require
actual HTML with .modal, .modal-dialog, .modal-content classes.

This fix adds proper Bootstrap modal HTML for both respondToACallWindow
and respondToAStationWindow modals in Dashboard.cshtml.

Fixes Resgrid#317
Add ability for department admins to edit existing trainings:

- Add Edit GET/POST actions to TrainingsController
- Create EditTrainingModel view model
- Create Edit.cshtml view with form for editing training details
- Add Edit button to training index page (admin only)
- Preserve existing attachments, questions, and user assignments
- Support adding new attachments, users, groups, and roles
- Add comprehensive unit tests for TrainingService

Files added:
- Tests/Resgrid.Tests/Mocks/MockTrainingRepository.cs
- Tests/Resgrid.Tests/Mocks/MockTrainingAttachmentRepository.cs
- Tests/Resgrid.Tests/Mocks/MockTrainingQuestionRepository.cs
- Tests/Resgrid.Tests/Mocks/MockTrainingUserRepository.cs
- Tests/Resgrid.Tests/Services/TrainingServiceTests.cs
- Web/Resgrid.Web/Areas/User/Models/Training/EditTrainingModel.cs
- Web/Resgrid.Web/Areas/User/Views/Trainings/Edit.cshtml
- Web/Resgrid.Web/wwwroot/js/app/internal/training/resgrid.training.edittraining.js

Files modified:
- Web/Resgrid.Web/Areas/User/Controllers/TrainingsController.cs
- Web/Resgrid.Web/Areas/User/Views/Trainings/Index.cshtml
@welcome
Copy link
Copy Markdown

welcome bot commented Apr 5, 2026

Thanks for opening this pull request! A contributor should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: df909969-ffb1-49dd-ab11-5889c4655187

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gitguardian
Copy link
Copy Markdown

gitguardian bot commented Apr 5, 2026

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
27318226 Triggered Generic Password f509d38 Tests/Resgrid.Tests/Web/Mcp/SensitiveDataRedactorTests.cs View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants