Skip to content

Conversation

@SahiruWithanage
Copy link

@SahiruWithanage SahiruWithanage commented Aug 31, 2025

Description

This pull request contains the complete front‑end implementation for the Staff Grant Extension feature. It delivers everything required for staff (tutors, convenors and admins) to grant extensions to students from within the Ontrack interface. The back‑end API and email notifications are handled in a separate PR – this PR is purely the UI/UX work.

What’s Included

Full grant extension workflow

  • Dedicated staff page and components – A new page accessible via the unit’s actions dropdown. When a staff member selects “Extensions”, the page displays a two‑column layout: a tasks component on the left listing all tasks for the selected unit and a grant extension form on the right. Selecting a task enables the form.
  • Grant extension form – Built with Angular reactive forms and Material UI, the form allows staff to:
    • Search and select one or multiple students for the chosen task.
    • Enter the number of weeks requested and a short reason (character limit enforced).
    • Submit the request, which sends a structured payload to the back end and resets after completion.
  • Summary component – After submission, a summary panel shows which students received extensions and which requests failed, providing immediate feedback to staff.

Notifications and communication

  • In‑system notifications for students – The feature integrates with an in‑system notification panel so that students see extension approvals directly in the UI.
  • Summary component for staff – Staff receive feedback via the summary component described above, rather than student‑style notifications.
  • Email notifications (back end) – A separate back‑end system sends detailed email notifications to students and staff about the extensions. The email integration is outside the scope of this PR but noted for completeness.

Services and integration

  • Extension service – Added a new Angular service to handle API calls for granting extensions. The form uses this service to submit requests and updates the summary upon completion.
  • Dynamic data loading – The page loads tasks and student lists based on the currently selected unit and task.

Validation and user experience

  • Validation rules ensure required fields are filled and text stays within character limits.
  • The form unlocks automatically if an error occurs(to be editable) and refreshes the summary to reflect the current state.
  • The new UI uses Angular Material for a responsive, consistent look and feel.

Type of change

  • Bug fix (non‑breaking change which fixes an issue)
  • New feature (non‑breaking change which adds functionality)
  • Refactor/Cleanup (code improvement without changing external behaviour)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  1. Accessing the feature

    • Log in as a tutor, convenor or admin.
    • Select a unit and choose “Extension” from the unit actions dropdown. Confirm the grant extension page loads with tasks on the left and the form on the right.
  2. Task and student selection

    • Choose a task from the left panel; confirm the form becomes active and loads the list of students.
    • Search for and select multiple students to receive the same extension.
  3. Form behaviour

    • Verify that required fields (students, weeks and reason) enforce input and character limits.
    • Submit valid and invalid data to ensure validation messages appear when appropriate.
  4. Extension summary and notifications

    • Submit a valid request and confirm the summary component lists successes and failures.
    • Log in as a student and verify that in‑system notifications reflect the outcome of their request.
  5. Other checks

    • Verify the tasks component refreshes when the unit or task is changed.
    • Confirm that the page works across Chrome, Safari and Firefox.

Testing Checklist:

  • Tested as admin, tutor, convenor and student
  • Verified multi‑student selection and summary display
  • Confirmed student notifications show correct outcomes
  • Checked validation behaviour and form reset
  • Tested across latest Chrome, Safari and Firefox

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 in hard‑to‑understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Folders and Files Added/Modified

Added:

  • src/app/api/services/extension.service.ts – new service for grant extension API calls.
  • src/app/units/states/tasks/staff-grant-extension/ – new directory containing:
    • tasks.component.* – displays tasks for the selected unit (left panel).
    • grant-extension-form/ component – the reactive form for requesting extensions (right panel).
    • grant-extension-summary/ component – displays results after submission.
    • staff-grant-extension.component.* – page container and routing.
  • Supporting models and tests for the new components.

Modified:

  • src/app/common/header/header.component.html – added integration point for in‑system notifications.
  • Various dashboard and task components – removed references to the old form modal and wired in the new page.
  • src/app/units/states/tasks/… – updated to pass unit and task data into the new form and summary components.

Deleted:

  • src/app/admin/modals/grant-extension-form/ – removed the old modal‑based grant extension form.
  • Obsolete tests and back‑end Ruby files related to extensions.

samindiii and others added 20 commits May 18, 2025 16:52
…ant extension form

This commit adds the Student Search and Select feature to the Staff Grant Extension form,
enhancing the form's usability by allowing staff to search for individual students and select
multiple students for bulk extension grants. This update integrates directly with the existing
extension form backend, improving the overall user experience for staff handling large classes.

Changes include:
- Added student search input for filtering student lists.
- Implemented multi-student selection support for bulk operations.
- Improved UI components for efficient student selection.
- Integrated with the existing form backend for seamless data flow.

References:
- Related to JoeMacl's Grant Extension Form PR thoth-tech#330
- Addresses requirements for bulk extension management.
- Create new Staff Grant Extension page with two-column layout
- Left panel: Task list using FUnitTaskListComponent
- Right panel: Embedded grant extension form (copied from admin modals)
- Form is disabled until a task is selected
- Form resets after successful submission
- Accessible via /#/staff-grant-extension URL
- Add proper routing and module configuration
- Include comprehensive form validation with visual feedback
- Add blue-tinted styling for containers
- Remove old grant extension form files that were duplicating functionality
- Add character limits to staff grant extension form: reason (300 chars), notes (500 chars)
- Clean up task status card component to remove old form dependencies
samindiii and others added 7 commits September 7, 2025 16:54
- WIP commit for adding Angular UIRouter routing for the `Staff Grant Extension` feature
- add Angular UIRouter declaration for the `Staff Grant Extension` `TaskDropdown` item
- conditionally render the `Staff Grant Extension` `TaskDropdown` item based on the user's `role`
- remove test code
@rashi-agrawal29 rashi-agrawal29 force-pushed the feature/staff-grant-extension-page-merge branch from e718b1f to 5a456ef Compare September 10, 2025 04:27
Remove the notes field from the staff grant extension feature as it was
not being used in the backend implementation. This simplifies the form
and payload structure by removing the unused functionality.

Changes made:
- Remove notes field from GrantExtensionPayload interface
- Remove notes form control from grant extension form
- Remove notes textarea from form template
- Remove notes field from form reset and payload creation

The feature now only includes essential fields: student_ids,
task_definition_id, weeks_requested and comment.
rashi-agrawal29 and others added 9 commits September 11, 2025 21:20
- Fix error handling to properly extract specific error messages from API responses
- Handle cases where error is directly a string (most common case)
- Add debugging logs to help troubleshoot error structures

Resolves issue where generic 'Error granting extensions' message was shown
instead of specific errors like 'Extensions cannot be granted beyond task deadline'
- Remove development console.log statements used for debugging error extraction
- Keep console.error for proper error logging
- Clean up code now that error handling is working correctly
@SahiruWithanage SahiruWithanage changed the title Feature/Staff Grant Extension Page Merge Feature/Staff Grant Extension - Complete Front-end work Sep 16, 2025
Copy link

@vaghelaparth05 vaghelaparth05 left a comment

Choose a reason for hiding this comment

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

Can you please paste some screenshot of this feature working on the frontend with multiple views on Desktop, Tablet and Mobile if possible.

</div>

<!-- Student List -->
<div *ngIf="showStudentList"

Choose a reason for hiding this comment

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

We can use @if directive here as using *ngif is outdated way of using angular. It won't break the code though because this is still supported.

</div>

<!-- Student Selection Error -->
<div *ngIf="grantExtensionForm.get('students')?.touched && grantExtensionForm.get('students')?.invalid" style="color: #f44336; font-size: 12px; margin-top: 4px; margin-bottom: 24px;">

Choose a reason for hiding this comment

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

We can use @if directive here as using *ngif is outdated way of using angular. It won't break the code though because this is still supported.

let errorMessage = 'Error granting extensions. Please try again.';

// Check if error is directly a string (most common case)
if (typeof error === 'string') {

Choose a reason for hiding this comment

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

Just a suggestion here, you can use this :
let errorMessage =
(typeof error === 'string' && error) ??
(typeof error?.error === 'string' && error.error) ??
error?.error?.error ??
error?.error?.message ??
error?.message ??
'An unknown error occurred';

Its called Nullish Coalescing Operator.

@@ -0,0 +1,31 @@
export interface SuccessfulResult {

Choose a reason for hiding this comment

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

All of these values are mandatory values and none of them are optional. If one of them is somehow missing, this might result in undefined/null error and break js. You can use ?: to define a value if its going to be optional.

like extension_response?: number.

task_status: string;
}

export interface FailedResult {

Choose a reason for hiding this comment

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

All of these values are mandatory values and none of them are optional. If one of them is somehow missing, this might result in undefined/null error and break js. You can use ?: to define a value if its going to be optional.

like extension_response?: number.

skipped: SkippedResult[];
}

export interface ExtensionSummaryPayload {

Choose a reason for hiding this comment

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

All of these values are mandatory values and none of them are optional. If one of them is somehow missing, this might result in undefined/null error and break js. You can use ?: to define a value if its going to be optional.

like extension_response?: number.

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.

6 participants