forked from doubtfire-lms/doubtfire-api
-
Notifications
You must be signed in to change notification settings - Fork 129
Feature/Staff Grant Extension - Complete Back-end work #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SahiruWithanage
wants to merge
11
commits into
thoth-tech:9.x
Choose a base branch
from
SahiruWithanage:feature/staff-grant-extension-backend-t1-complete
base: 9.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/Staff Grant Extension - Complete Back-end work #77
SahiruWithanage
wants to merge
11
commits into
thoth-tech:9.x
from
SahiruWithanage:feature/staff-grant-extension-backend-t1-complete
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enable staff to grant extensions to multiple students without formal requests. Reuse existing student extension logic through a new service for consistency. Supports flexible academic support and streamlines staff workflows. Relates to the OnTrack Staff Grant Extension design documentation.
…rpolated strings This aligns the test file with the string formatting convention used in the rest of the codebase. Single quotes are preferred when string interpolation is not needed, improving consistency. Reviewed as part of peer feedback.
Linked extension_comments_api (student-requested extensions) to use the shared ExtensionService, previously set up for staff-granted extensions. This refactor ensures both student and staff extension flows use the same logic, improving consistency and reducing duplication.
Implemented backend logic to send emails to tutor and student when extensions are granted. Also enable it so the front end can use the returned information from the api to display notifications.
A comment line change made in the staff grant extension feature branch that hasn't been updated here. Changing to keep the consistency.
- Fix delivery method consistency (deliver_now vs deliver_later) - Fix ExtensionComment retrieval logic to prevent race conditions - Add proper error handling for email failures - Fix mailer method calls (class methods vs instance methods) - Add input validation for API parameters - Improve error logging and debugging - Ensure thread-safe extension processing The email notification system now works correctly: - Staff receive summary emails for all granted extensions - Students receive individual notification emails - Proper error handling prevents API failures on email issues - All email delivery methods are consistent across the project
- Change notification message from unit.name to unit.code for better consistency - Unit codes are more concise and standardized (e.g., 'SITXXX') - Improves readability of extension grant notifications
11 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request provides the complete back‑end implementation for the Staff Grant Extension feature. It introduces a dedicated API that allows staff (tutors, convenors and admins) to grant extensions to one or more students on a given task directly from the Ontrack system. All UI/UX work is handled in a separate PR – this branch focuses on the API, model and mailer changes needed to support the new workflow.
What’s Included
New API for staff‑granted extensions
StaffGrantExtensionApiendpoint – A new Grape API mounted under/staff‑grant‑extension(and protected by existing authentication helpers). ThePOSTroute enables staff to grant extensions to multiple students without formal requests. The endpoint accepts a list of student IDs, a task identifier, the number of weeks to extend and a reason, and returns a result object listing successes and failures.ExtensionServiceoriginally used for student‑requested extensions, ensuring both staff and student flows use the same business rules and validations. This avoids duplication and keeps extension handling consistent across the codebase.Notifications system
Notificationmodel and underlying table with a relationship toUser. Notifications store a message, a target user and a read/unread status.Email delivery improvements
deliver_nowvs.deliver_later) and handle errors gracefully. A summary email is sent to the staff member listing all extensions granted and individual emails are sent to each student.config/environmentwill need to be updated with the proper SMTP details so that emails are actually sent.Refactoring and shared services
extension_comments_apito use a shared service so that both student and staff extension flows call the same business logic. This reduces duplication and improves maintainability.Type of change
Testing Checklist (the front‑end exercising this API serves as the primary way to verify functionality)
Checklist
Folders and Files Added/Modified
Added:
app/api/staff_grant_extension_api.rb– New Grape API withPOSTendpoint to grant extensions to multiple students.app/models/notification.rband associated migration – Defines theNotificationmodel and database table.app/api/notifications_api.rb– ProvidesGETandDELETEendpoints for notifications.Modified:
app/api/api_root.rb– Mounted theStaffGrantExtensionApiandNotificationsApiand added authentication hooks.app/services/extension_service.rb– Updated to support staff‑initiated extensions and reuse logic for student‑requested extensions.app/mailers/extension_mailer.rb– Corrected sender configuration, added summary email method and improved error handling.app/api/staff_grant_extension_api.rb– Updated in subsequent commits to refine email sending logic and handle race conditions.test/api/staff_grant_extension_test.rb) – Added new cases for multiple students and notifications; refactored to follow single‑quote conventions.Deleted: