-
Notifications
You must be signed in to change notification settings - Fork 14
#5190 - Appeals and forms analysis work - Assessment History and Student View #5846
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
andrewsignori-aot
wants to merge
8
commits into
main
Choose a base branch
from
feature/#5190-new-unified-data-path-for-appeals-and-forms-ministry-assessment-request-and-history
base: main
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.
+1,230
−419
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2179481
Navigating and loading student view
andrewsignori-aot 66228b2
Enabled institution and student views
andrewsignori-aot c69907b
Navigation for Ministry, Institution, and Student
andrewsignori-aot 7a6d00d
Pre-review adjustments
andrewsignori-aot a6785dd
Pre-review adjustments and copilot fixes
andrewsignori-aot 716115d
Minor DTO fix.
andrewsignori-aot 0a83dae
PR fix
andrewsignori-aot 32df990
PR changes
andrewsignori-aot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
94 changes: 94 additions & 0 deletions
94
...kend/apps/api/src/route-controllers/form-submission/form-submission.controller.service.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import { Injectable, NotFoundException } from "@nestjs/common"; | ||
| import { FormSubmissionService } from "../../services"; | ||
| import { | ||
| FormSubmissionDecisionStatus, | ||
| FormSubmissionItem, | ||
| FormSubmissionStatus, | ||
| } from "@sims/sims-db"; | ||
| import { | ||
| FormSubmissionAPIOutDTO, | ||
| FormSubmissionItemDecisionAPIOutDTO, | ||
| } from "./models/form-submission.dto"; | ||
|
|
||
| @Injectable() | ||
| export class FormSubmissionControllerService { | ||
| constructor(private readonly formSubmissionService: FormSubmissionService) {} | ||
|
|
||
| /** | ||
| * Get the details of a form submission, including the individual form items and their details. | ||
| * @param formSubmissionId ID of the form submission to retrieve the details for. | ||
| * @param options. | ||
| * - `studentId`: optional ID used to validate the institution access to the student data. | ||
| * - `includeBasicDecisionDetails`: optional flag to include basic decision details, besides | ||
| * the decision status. Used for institutions to have access to more details than the student | ||
| * to better support them. | ||
| * @returns form submission details. | ||
| */ | ||
| async getFormSubmission( | ||
| formSubmissionId: number, | ||
| studentId: number, | ||
| options?: { | ||
| includeBasicDecisionDetails?: boolean; | ||
| applicationId?: number; | ||
| }, | ||
| ): Promise<FormSubmissionAPIOutDTO> { | ||
| const submission = await this.formSubmissionService.getFormSubmissionById( | ||
| formSubmissionId, | ||
| studentId, | ||
| { applicationId: options?.applicationId }, | ||
| ); | ||
| if (!submission) { | ||
| throw new NotFoundException( | ||
| `Form submission with ID ${formSubmissionId} not found.`, | ||
| ); | ||
| } | ||
| return { | ||
| id: submission.id, | ||
| formCategory: submission.formCategory, | ||
| status: submission.submissionStatus, | ||
| applicationId: submission.application?.id, | ||
| applicationNumber: submission.application?.applicationNumber, | ||
| submittedDate: submission.submittedDate, | ||
| submissionItems: submission.formSubmissionItems.map((item) => ({ | ||
| id: item.id, | ||
| formType: item.dynamicFormConfiguration.formType, | ||
| formCategory: item.dynamicFormConfiguration.formCategory, | ||
| dynamicFormConfigurationId: item.dynamicFormConfiguration.id, | ||
| submissionData: item.submittedData, | ||
| formDefinitionName: item.dynamicFormConfiguration.formDefinitionName, | ||
| currentDecision: this.mapCurrentDecision( | ||
| submission.submissionStatus, | ||
| item, | ||
| !!options?.includeBasicDecisionDetails, | ||
| ), | ||
| })), | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Define the decision to be returned. | ||
| * The decision and its details are determined based on the form submission status | ||
| * and the access to the decision details that the consumer has. | ||
| * @param submissionStatus form submission status. | ||
| * @param submissionItem form submission to determine the decision details to be returned. | ||
| * @param includeBasicDecisionDetails flag to indicate if the basic decision details should be included in the response, | ||
| * besides the status that is always included. | ||
| * @returns the decision that must be exposed the consumer. | ||
| */ | ||
| private mapCurrentDecision( | ||
| submissionStatus: FormSubmissionStatus, | ||
| submissionItem: FormSubmissionItem, | ||
| includeBasicDecisionDetails: boolean, | ||
| ): FormSubmissionItemDecisionAPIOutDTO { | ||
| if (submissionStatus === FormSubmissionStatus.Pending) { | ||
| // For pending submissions, the decision details should not be returned. | ||
| return { decisionStatus: FormSubmissionDecisionStatus.Pending }; | ||
| } | ||
| return { | ||
| decisionStatus: submissionItem.currentDecision.decisionStatus, | ||
| decisionNoteDescription: includeBasicDecisionDetails | ||
| ? submissionItem.currentDecision.decisionNote.description | ||
| : undefined, | ||
| }; | ||
| } | ||
| } | ||
52 changes: 52 additions & 0 deletions
52
...apps/api/src/route-controllers/form-submission/form-submission.institutions.controller.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { Controller, Get, Param, ParseIntPipe } from "@nestjs/common"; | ||
| import { AuthorizedParties } from "../../auth"; | ||
| import { | ||
| AllowAuthorizedParty, | ||
| HasStudentDataAccess, | ||
| IsBCPublicInstitution, | ||
| } from "../../auth/decorators"; | ||
| import { ApiNotFoundResponse, ApiTags } from "@nestjs/swagger"; | ||
| import BaseController from "../BaseController"; | ||
| import { ClientTypeBaseRoute } from "../../types"; | ||
| import { FormSubmissionControllerService } from "./form-submission.controller.service"; | ||
| import { FormSubmissionAPIOutDTO } from "./models/form-submission.dto"; | ||
|
|
||
| @AllowAuthorizedParty(AuthorizedParties.institution) | ||
| @IsBCPublicInstitution() | ||
| @Controller("form-submission") | ||
| @ApiTags(`${ClientTypeBaseRoute.Institution}-form-submission`) | ||
| export class FormSubmissionInstitutionsController extends BaseController { | ||
| constructor( | ||
| private readonly formSubmissionControllerService: FormSubmissionControllerService, | ||
| ) { | ||
| super(); | ||
| } | ||
|
|
||
| /** | ||
| * Get the details of a form submission, including the individual form items and their details. | ||
| * Please note currently the institution can only access form submissions related to their students | ||
| * and applications. | ||
| * @param formSubmissionId ID of the form submission to retrieve the details for. | ||
dheepak-aot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @param studentId student ID for authorization and to ensure the form submission belongs | ||
| * to the institution's student. | ||
| * @param applicationId application ID to ensure the institution has access to the | ||
| * student's application related to the form submission. | ||
| * @returns form submission details including individual form items and their details. | ||
| */ | ||
| @ApiNotFoundResponse({ description: "Form submission not found." }) | ||
| @HasStudentDataAccess("studentId", "applicationId") | ||
| @Get( | ||
| "student/:studentId/application/:applicationId/form-submission/:formSubmissionId", | ||
| ) | ||
| async getFormSubmission( | ||
| @Param("studentId", ParseIntPipe) studentId: number, | ||
| @Param("applicationId", ParseIntPipe) applicationId: number, | ||
| @Param("formSubmissionId", ParseIntPipe) formSubmissionId: number, | ||
| ): Promise<FormSubmissionAPIOutDTO> { | ||
| return this.formSubmissionControllerService.getFormSubmission( | ||
| formSubmissionId, | ||
| studentId, | ||
| { includeBasicDecisionDetails: true, applicationId }, | ||
| ); | ||
| } | ||
andrewsignori-aot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the studentId also be under options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method requires the student ID.