Skip to content

Conversation

@dheepak-aot
Copy link
Collaborator

@dheepak-aot dheepak-aot commented Aug 11, 2025

Reverse scholastic standing API

Keycloak role

  • Created a new keycloak role student-reverse-scholastic-standing and added the role to the group aest-business-administrators in DEV

API

  • Created new API to reverse a scholastic standing change.
  • This API will handle the reversal process based on the scholastic standing change type. For e.g. when the change type is Unsuccessful completion, only the reversal date, reversal_by and reversal_note is added without any re-assessment or updating the archiving status. But otherwise additionally re-assessment and updating archive status to false is also done.

Service

  • Created a new service ScholasticStandingReversalService to handle all the operations for reversal.
  • Added the property versions to offering similar to applications to get it's current version.

E2E Tests

  • E2E Tests added for the reverse scholastic standing API to cover all major scenarios. Few more tests for different errors will be added in the upcoming PR.
image
  • E2E tests added for UC summary API for students to ensure UC weeks from a reversed scholastic standing is ignored.

@dheepak-aot dheepak-aot marked this pull request as ready for review August 13, 2025 19:35
Comment on lines +117 to +118
default:
throw error;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor, the default is not required.

SCHOLASTIC_STANDING_REVERSAL_NOT_UPDATED,
} from "../../constants";
import { DataSource, IsNull, Repository } from "typeorm";
/**
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a blank line.

{ id: scholasticStandingId, reversalDate: IsNull() },
{ reversalDate: now, reversalBy: auditUser, reversalNote: note },
);
if (updateResult.affected !== 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor, just a suggestion, I found the check as if (!updateResult.affected) better to read 😉
We have both ways in the solution, no need for change.

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

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

Great work with the different scenarions, looks good 👍

@bidyashish bidyashish requested a review from Copilot August 13, 2025 20:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a reverse scholastic standing API that allows authorized users to reverse student scholastic standing changes. The implementation handles different reversal scenarios based on the type of scholastic standing change, including creating re-assessments and updating application archive status when necessary.

Key Changes:

  • Added new Keycloak role student-reverse-scholastic-standing for authorization
  • Created new service ScholasticStandingReversalService to handle reversal logic
  • Implemented API endpoint to reverse scholastic standings with appropriate error handling
  • Added comprehensive E2E tests covering various reversal scenarios

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sources/packages/web/src/types/contracts/aest/roles.ts Added new role constant for scholastic standing reversal
sources/packages/backend/libs/test-utils/src/factories/student-scholastic-standing.ts Enhanced factory to support reversal date initialization
sources/packages/backend/libs/test-utils/src/factories/education-program-offering.ts Added offering versioning support for testing
sources/packages/backend/libs/sims-db/src/entities/education-program-offering.model.ts Added versions relationship to track offering changes
sources/packages/backend/apps/api/src/services/student-scholastic-standings/scholastic-standing-reversal.service.ts Core service implementing reversal business logic
sources/packages/backend/apps/api/src/route-controllers/student-scholastic-standings/student-scholastic-standings.aest.controller.ts API endpoint for reversing scholastic standings
sources/packages/backend/apps/api/src/route-controllers/student-scholastic-standings/models/student-scholastic-standings.dto.ts Request DTO for reversal payload
sources/packages/backend/apps/api/src/constants/error-code.constants.ts Added error constants for reversal operations
sources/packages/backend/apps/api/src/auth/roles.enum.ts Added role enum for backend authorization
sources/packages/backend/apps/api/src/app.aest.module.ts Registered new service in DI container

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

if (isReAssessmentAndArchiveUpdateRequired) {
// Current version of the offering that was associated with the application before the scholastic standing was reported.
const [offeringBeforeScholasticStanding] =
scholasticStanding.referenceOffering.parentOffering.versions;
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Using array destructuring to get the first element assumes the array has at least one element, but there's no validation that versions array is not empty. This could cause runtime errors if no versions exist.

Suggested change
scholasticStanding.referenceOffering.parentOffering.versions;
const versions = scholasticStanding.referenceOffering.parentOffering.versions;
if (!Array.isArray(versions) || versions.length === 0) {
throw new CustomNamedError(
"No offering versions found for the parent offering when attempting to reverse scholastic standing.",
SCHOLASTIC_STANDING_REVERSAL_NOT_ALLOWED,
);
}
const [offeringBeforeScholasticStanding] = versions;

Copilot uses AI. Check for mistakes.

it(
"Should get scholastic standing summary for a student excluding the details from reversed scholastic standing(s)" +
" when a student has one ore more reversed scholastic standings.",
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

There is a spelling error: 'ore' should be 'or'.

Suggested change
" when a student has one ore more reversed scholastic standings.",
" when a student has one or more reversed scholastic standings.",

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

@dheepak-aot please review spelling check

@sonarqubecloud
Copy link

@github-actions
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 21.45% ( 4114 / 19181 )
Methods: 9.55% ( 234 / 2449 )
Lines: 24.82% ( 3561 / 14350 )
Branches: 13.39% ( 319 / 2382 )

@github-actions
Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 74.3% ( 896 / 1206 )
Methods: 77.14% ( 108 / 140 )
Lines: 77.16% ( 696 / 902 )
Branches: 56.1% ( 92 / 164 )

Copy link
Contributor

@bidyashish bidyashish left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 86.43% ( 1548 / 1791 )
Methods: 84.62% ( 176 / 208 )
Lines: 88.75% ( 1278 / 1440 )
Branches: 65.73% ( 94 / 143 )

@github-actions
Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 73.84% ( 7344 / 9946 )
Methods: 71.62% ( 901 / 1258 )
Lines: 77.3% ( 5687 / 7357 )
Branches: 56.8% ( 756 / 1331 )

@dheepak-aot dheepak-aot added this pull request to the merge queue Aug 13, 2025
Merged via the queue into main with commit eb285ce Aug 13, 2025
22 checks passed
@dheepak-aot dheepak-aot deleted the feature/#4877-reverse-scholastic-standing-api branch August 13, 2025 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants