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: remind pending assignment functionality #325

Closed
wants to merge 11 commits into from
Closed

Conversation

kiram15
Copy link
Contributor

@kiram15 kiram15 commented Nov 9, 2023

Description

Create a remind functionality that the admin of an enterprise learner credit wants to remind them of their pending assignment. The learner will receive a email with course details of their pending assignment. This PR is similar to Katrina's here but for the remind functionality

Solution

Add a celery task to the send out a braze email campaign to the learner to remind them

JIRA Ticket

@kiram15 kiram15 marked this pull request as draft November 9, 2023 23:02
@kiram15 kiram15 marked this pull request as ready for review November 13, 2023 21:27
braze_trigger_properties["course_title"] = assignment.content_title
braze_trigger_properties["enrollment_deadline"] = course_metadata['normalized_metadata']['enroll_by_date']
braze_trigger_properties["start_date"] = course_metadata['normalized_metadata']['start_date']
braze_trigger_properties["course_partner"] = course_metadata['owners'][0]['name']
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only taking the first owner's name to send, is that an OK default to have? Or should I create a method that loops through if there's multiple and do "Harvard and Stanford" or something?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's fine for now. We can circle back on this with relative ease in the future.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, we generally show all partners (when there are multiple) on the course cards in the UIs, comma-separated. I feel we should likely include all partner names in the email, for consistency with what's shown in the UI for admins/learners (similar to what you suggested, Kira). Main concern is that don't tackle this, we'd intentionally be favoring one course partner over another, which isn't great.

If supporting multiple partners is deferred for this PR, I feel it should be tackled as a follow-up for sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that's a good point!

braze_trigger_properties["course_title"] = assignment.content_title
braze_trigger_properties["enrollment_deadline"] = course_metadata['normalized_metadata']['enroll_by_date']
braze_trigger_properties["start_date"] = course_metadata['normalized_metadata']['start_date']
braze_trigger_properties["course_partner"] = course_metadata['owners'][0]['name']
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, we generally show all partners (when there are multiple) on the course cards in the UIs, comma-separated. I feel we should likely include all partner names in the email, for consistency with what's shown in the UI for admins/learners (similar to what you suggested, Kira). Main concern is that don't tackle this, we'd intentionally be favoring one course partner over another, which isn't great.

If supporting multiple partners is deferred for this PR, I feel it should be tackled as a follow-up for sure.

enterprise_access/apps/content_assignments/api.py Outdated Show resolved Hide resolved
enterprise_access/apps/content_assignments/api.py Outdated Show resolved Hide resolved
Copy link
Contributor

@iloveagent57 iloveagent57 left a comment

Choose a reason for hiding this comment

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

Good changes! I left a couple minor suggestions, then this should be good to merge.

Comment on lines 199 to 200
if len(assignments) < len(request.data['assignment_uuids']):
return Response(status=status.HTTP_404_NOT_FOUND)
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a check we'd want to do before calling cancel_assignments(), right? If this condition were true, it'd mean we couldn't find all of the assignments given the assignment uuids provided by the caller in our filter() above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because if we call it before then if any of the assignments are not found, it will just return before it hit the cancel rather than canceling the remaining ones.

Copy link
Contributor

Choose a reason for hiding this comment

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

for posterity: we decided offline to leave the condition as-is, but change the response status to 422 here.

Comment on lines 201 to 202
if response.get('non_cancelable'):
return Response(status=status.HTTP_422_UNPROCESSABLE_ENTITY)
Copy link
Contributor

Choose a reason for hiding this comment

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

The assignments in response['non_cancelable'] aren't related to errors, really - they are just the assignments that are not in a cancellable state (e.g. they're already cancelled, or they're already accepted). I might change this around a little to be like

if not response.get('cancelled'):
    return Response(status=422)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this I know they're not related to errors, but wouldn't it mean that some of the uuids were unprocessable?

Copy link
Contributor

Choose a reason for hiding this comment

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

for posterity: we decided offline to leave this condition and response as-is. If we need more fine-grained detail about un-cancellable assignments later, we can modify.

@iloveagent57
Copy link
Contributor

closing in favor of the other PR with commits all squashed down

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