Skip to content
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

feat: MI Assign home screen (M2-7405) #530

Merged
merged 9 commits into from
Sep 5, 2024

Conversation

farmerpaul
Copy link
Contributor

@farmerpaul farmerpaul commented Aug 30, 2024

  • Tests for the changes have been added
  • Related documentation has been added / updated
  • OSS packages added to MindLogger open source credit page

📝 Description

🔗 Jira Ticket M2-7405

Adds support for displaying assigned activities and flows in the Web App, including:

  • Displays new TargetSubjectLabel chip component on multi-informant assignments
  • Lists multiple instances of ActivityCard for the same activity/flow when user has multiple assignments for that activity/flow
    • Currently, an activity can both be set to autoAssign: true as well as have manual assignments, and the web app respects this possibility. In a future Admin App ticket, UI restrictions will be imposed to make auto-assign and manual assignments mutually exclusive.
  • Tracks distinct in-progress state of each activity/flow for each assignment
  • For those activities/flows that are scheduled for one-time completion or on a daily schedule: Uses new targetSubjectId returned by the /answers/applet/{applet_id}/completions endpoint to compare assignment has already been completed that day

Also fixes a couple missing translations and incorrect usage of i18next plural forms.

Tip

Although many files were touched in this PR, many of those constituted tying targetSubjectId to activity progress in this commit, and on the whole were somewhat repetitive. Strongly typing the targetSubject and targetSubjectId props to be required prop (cannot be undefined) made it easier to make that change in a comprehensive way. I attempted to group other related changes into their own commits and it may be easiest to review commit-by-commit.

📸 Screenshots

CleanShot.2024-08-30.at.11.37.22.mp4

🪤 Peer Testing

Note

This feature depends on the enableActivityAssign feature flag. This should already be enabled in dev/local environments. It would also be worth testing this with that feature flag disabled to confirm that existing behaviour is preserved with the MI Assign feature disabled, by adding features.enableActivityAssign = false prior to the return statement here in useFeatureFlags.

Please refer to ticket's AC for the main peer testing steps.

In addition, after completing a multi-informant assigned activity, confirm that the POST to the answers endpoint includes the appropriate targetSubjectId. Also confirm that for self-reports, that property is not included.

In prep for adjusting `ActivityGroupsBuildManager` to accommodate
assignments, refactor logic slightly to eliminate multiple calls to
`filter`. Also rename identifiers to be make logic easier to follow
and stay consistent with use of `EventEntity` type elsewhere in app.

Also remove debug statement in `useFeatureFlags`.
Update logic to take into account both auto-assigned and manually
assigned activities and flows when generating list of activities/flows
available on the applet's home screen. Falls back to existing approach
if `enableActivityAssign` feature flag is disabled.

Refactor activity/flow sorting into a single array `sort` call using a
custom comparer, instead of the less efficient and harder to read
approach involving multiple `filter` calls, a custom `sort`, followed by
recominbation.

This change doesn't account for tracking distinct in-progress states for
each assignment of the same activity, or assignment-specific one-time
completion status; that will be done in an upcoming commit.
Make shared `TargetSubjectLabel` component which will also be used in
the activity screens.

Also fix missing translations and missing/incorrect use of i18next
plural forms in several `ActivityLabel` subcomponents.
Made widespread change to incorporate `targetSubjectId` into activity
progres tracking, when assignments feature is enabled. Anytime `eventId`
is used, now `targetSubjectid` also needs to be passed to identify which
activity assignment is the active assessment. This value is also passed
to the `answers` POST endpoint to ensure the submission is also properly
associated with the `targetSubjectId`.

For self-reports, and when assignments feature is disabled,
`targetSubjectId` is set to `null`, effectively inheriting existing
functionality.

For `PublicSurvey` and `PublicAutoCompletion`, `targetSubjectId` stays
`null` since public assessments do not support activity assignments.
@farmerpaul farmerpaul force-pushed the feature/M2-7405-mi-assign-home-screen branch from 2c818e6 to 60f9071 Compare August 30, 2024 14:33
@farmerpaul farmerpaul marked this pull request as ready for review August 30, 2024 14:50
@farmerpaul farmerpaul requested review from sultanofcardio and qiushihe and removed request for sultanofcardio August 30, 2024 14:50
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-530.d15zn9do8xbzga.amplifyapp.com

@farmerpaul farmerpaul force-pushed the feature/M2-7405-mi-assign-home-screen branch from ebbd36b to 8f14baf Compare August 30, 2024 17:54
Copy link
Contributor

@qiushihe qiushihe left a comment

Choose a reason for hiding this comment

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

Seems to be mostly adding an extra parameter/attribute to all the places, plus some renaming/refactoring of variables and types.

But the code looks good nonetheless 👍

@farmerpaul please let me know when you're done with the tests, and I'll give this another go.

src/shared/constants/routes.ts Show resolved Hide resolved
@farmerpaul farmerpaul force-pushed the feature/M2-7405-mi-assign-home-screen branch from 951533e to 909efa3 Compare September 3, 2024 21:13
Also fix tsconfig.node.json to exclude node_modules from tsc.
@farmerpaul farmerpaul force-pushed the feature/M2-7405-mi-assign-home-screen branch from 909efa3 to a3cf7d9 Compare September 3, 2024 21:13
Copy link
Contributor

@mbanting mbanting left a comment

Choose a reason for hiding this comment

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

Amazing work @farmerpaul! Have not reviewed the code but performed a round of peer testing which was mostly successful. All passing with followup fix:

Auto-assigned activities & flows display

Manually assigned activities & flows don't display when not assigned

Manually assigned activities & flows display when assigned

Manually assigned activities & flows inherit the existing global schedule

Manually assigned activities & flows inherit the existing individual schedule

Assigned activity (non self-report) sees a badge with question counter

  • Expected "13 Questions" as specified in Figma. Actual "13 questions" (lower case 'q'). Is Figma incorrect?

Assigned flow (non self-report) sees a badge with activity counter

  • Expected same as above, "2 Activities" (couldn't find example in Figma but inferring from activities). Actual "2 activities" (lower case 'a'). Is Figma incorrect?

Multiple assignments for the same activity / flow displayed for each subject

Sorting available->scheduled, activity/flow order in admin panel, self report -> additional subjects

Each assignment preserves its own unique in-progress state

  • Works for self-reports, but could not test with MI assigned activities. Starting activity results in BE returning 403 on call to /subjects/{_id} endpoint. Is this to be implemented in M2-7475 to skip calling this endpoint in favor of getting subject info from assignment?

One time completion, single assignment activity disappears after being completed

  • Works for self-reports, but could not test with MI assigned activities (same issue as above)

One time completion, multiple assignment activity disappears after being completed (per assignment)

  • Works for self-reports, but could not test with MI assigned activities (same issue as above)

Copy link
Contributor

@mbanting mbanting left a comment

Choose a reason for hiding this comment

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

Will leave to @qiushihe to complete their review of the code. Peer tested successfully 🎉 🎉 🎉

Copy link
Contributor

@qiushihe qiushihe left a comment

Choose a reason for hiding this comment

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

LGTM

@farmerpaul farmerpaul merged commit 26d0036 into dev Sep 5, 2024
3 checks passed
@farmerpaul farmerpaul deleted the feature/M2-7405-mi-assign-home-screen branch September 5, 2024 13:16
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.

3 participants