Skip to content

feat(api): Staff Grant Extension - Upstream Rebase#565

Open
SteveDala wants to merge 27 commits intodoubtfire-lms:10.0.xfrom
SteveDala:SGE-rebase-upstream
Open

feat(api): Staff Grant Extension - Upstream Rebase#565
SteveDala wants to merge 27 commits intodoubtfire-lms:10.0.xfrom
SteveDala:SGE-rebase-upstream

Conversation

@SteveDala
Copy link

@SteveDala SteveDala commented Jan 19, 2026

Description

This pull request is a complete rebase of the Staff Grant Extension (SGE) API functionality introduced in #77. The initial feature was built on 9.x, and this PR migrates the feature to the new 10.0.x development branch.

All credit for development of the feature API goes to @samindiii and @SahiruWithanage.

Sister branches

Run OnTrack with the latest version of these branches to recreate the environment.

Sister Pull Requests

  • doubtfire-lms/doubtfire-web #1074: Front-end that interacts with this feature
  • thoth-tech/doubtfire-api #82: Forked version to be closed if this is merged

Repo cleanup

Merging this PR should be followed by closing the following open PRs with a comment that they have been merged into 10.0.x:

Merging this PR should also be followed by closing the forked version PR mentioned above with a comment that it has been merged into 10.0.x upstream:

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Test A

While the development container is running, connect and run rails test from the directory /workspace/doubtfire-api. This runs all unit tests. For the last successful GitHub Action run of this branch, see here.

Test B

To strictly test the API, head to localhost's API docs while your Docker server is running.

Open "auth : Operations about auths" and go to "POST /api/auth". Enter the following JSON for the postApiAuth value:

{"username": "aconvenor", "password":"password"}

Then click "Try it out!". From the response, grab the auth_token value.

Open "units : Operations about units" further down the page then go to "POST /api/units/{unit_id}/staff-grant-extension". Enter the following values for each parameter:

  • unit_id: 1
  • Username: aconvenor
  • Auth_token: (The one you received from POST /api/auth)
  • postApiUnitsUnitIdStaffGrantExtension:
{
  "student_ids": [
    24
  ],
  "task_definition_id": 1,
  "weeks_requested": 1,
  "comment": "string"
}

You should receive a "successful" result in the Response Body.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if appropriate
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have created or extended unit tests to address my new additions
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

SteveDala and others added 26 commits November 30, 2025 13:29
The document still said "documentaion". Nuts. I have also added
the doc version number. I defaulted to the version of the branch.
Also correct the pdf reading test
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.
Also, define relation with user
- 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
@SteveDala SteveDala marked this pull request as ready for review January 23, 2026 14:48
@SteveDala
Copy link
Author

@b0ink please review when you have a moment.

Copy link
Member

@b0ink b0ink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to review the notification workflow a little more in-depth, but here's a few changes that can be made for now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The html template should be more consistent with existing email templates (eg. using the logo and main content border outline), refer to portfolio_ready.html.erb or weekly_student_summary.html.erb - you can preview these by copying the HTML output from one of the students in doubtfire-api/tmp/mails/student_**@doubtfire.com into an HTML previewer online to verify that it looks right

SteveDala added a commit to SteveDala/doubtfire-api that referenced this pull request Feb 4, 2026
SteveDala added a commit to SteveDala/doubtfire-api that referenced this pull request Feb 4, 2026
fix: changes requested to doubtfire-lms#565

fix: db/schema.rb changes requested to doubtfire-lms#565

fix: change approach to institution settings

fix: rubocop nit

fix: test issues
@SteveDala SteveDala force-pushed the SGE-rebase-upstream branch from a5447e0 to 1df9bb2 Compare February 4, 2026 11:05
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.

4 participants